@@ -2,14 +2,22 @@ package cromwell.backend.google.pipelines.v2beta
22
33import java .nio .file .Paths
44import cats .data .NonEmptyList
5+ import cloud .nio .impl .drs .DrsCloudNioFileProvider .DrsReadInterpreter
6+ import cloud .nio .impl .drs .{DrsCloudNioFileSystemProvider , GoogleDrsCredentials }
7+ import com .google .cloud .NoCredentials
8+ import com .typesafe .config .{Config , ConfigFactory }
59import common .assertion .CromwellTimeoutSpec
610import common .mock .MockSugar
711import cromwell .backend .google .pipelines .common .PipelinesApiFileInput
12+ import cromwell .backend .google .pipelines .common .io .{DiskType , PipelinesApiWorkingDisk }
813import cromwell .core .path .DefaultPathBuilder
14+ import cromwell .filesystems .drs .DrsPathBuilder
915import org .mockito .Mockito ._
1016import org .scalatest .flatspec .AnyFlatSpec
1117import org .scalatest .matchers .should .Matchers
1218
19+ import scala .concurrent .duration .DurationInt
20+
1321class PipelinesApiAsyncBackendJobExecutionActorSpec extends AnyFlatSpec with CromwellTimeoutSpec with Matchers
1422 with MockSugar {
1523 behavior of " PipelinesParameterConversions"
@@ -44,4 +52,45 @@ class PipelinesApiAsyncBackendJobExecutionActorSpec extends AnyFlatSpec with Cro
4452
4553 PipelinesApiAsyncBackendJobExecutionActor .groupParametersByGcsBucket(inputs) shouldEqual expected
4654 }
55+
56+ it should " generate a CSV manifest for DRS inputs, ignoring non-DRS inputs" in {
57+ def makeDrsPathBuilder : DrsPathBuilder = {
58+ val marthaConfig : Config = ConfigFactory .parseString(
59+ """ martha {
60+ | url = "http://martha-url"
61+ |}
62+ |""" .stripMargin
63+ )
64+
65+ val fakeCredentials = NoCredentials .getInstance
66+
67+ val drsReadInterpreter : DrsReadInterpreter = (_, _) =>
68+ throw new UnsupportedOperationException (" PipelinesApiAsyncBackendJobExecutionActorSpec doesn't need to use drs read interpreter." )
69+
70+ DrsPathBuilder (
71+ new DrsCloudNioFileSystemProvider (marthaConfig, GoogleDrsCredentials (fakeCredentials, 1 .minutes), drsReadInterpreter),
72+ None ,
73+ )
74+ }
75+
76+ val mount = PipelinesApiWorkingDisk (DiskType .LOCAL , 1 )
77+
78+ def makeDrsInput (name : String , drsUri : String , containerPath : String ): PipelinesApiFileInput = {
79+ val drsPath = makeDrsPathBuilder.build(drsUri).get
80+ val containerRelativePath = DefaultPathBuilder .get(containerPath)
81+ PipelinesApiFileInput (name, drsPath, containerRelativePath, mount)
82+ }
83+
84+ val nonDrsInput : PipelinesApiFileInput = PipelinesApiFileInput (" nnn" ,
85+ DefaultPathBuilder .get(" /local/nnn.bai" ), DefaultPathBuilder .get(" /path/to/nnn.bai" ), mount)
86+
87+ val inputs = List (
88+ makeDrsInput(" aaa" , " drs://drs.example.org/aaa" , " path/to/aaa.bai" ),
89+ nonDrsInput,
90+ makeDrsInput(" bbb" , " drs://drs.example.org/bbb" , " path/to/bbb.bai" )
91+ )
92+
93+ PipelinesApiAsyncBackendJobExecutionActor .generateDrsLocalizerManifest(inputs) shouldEqual
94+ " drs://drs.example.org/aaa,/cromwell_root/path/to/aaa.bai\r\n drs://drs.example.org/bbb,/cromwell_root/path/to/bbb.bai\r\n "
95+ }
4796}
0 commit comments