@@ -31,46 +31,87 @@ class TesTaskSpec
3131 false ,
3232 Map .empty
3333 )
34+ val internalPathPrefix = Option (" mock/path/to/tes/task" )
35+ val expectedTuple = " internal_path_prefix" -> internalPathPrefix
3436
3537 it should " create the correct resources when an identity is passed in WorkflowOptions" in {
3638 val wei = Option (" abc123" )
37- TesTask .makeResources(runtimeAttributes, wei) shouldEqual
38- Resources (None , None , None , Option (false ), None , Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" abc123" )))
39+ TesTask .makeResources(runtimeAttributes, wei, internalPathPrefix) shouldEqual
40+ Resources (None , None , None , Option (false ), None ,
41+ Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" abc123" ),
42+ expectedTuple))
3943 )
4044 }
4145
4246 it should " create the correct resources when an empty identity is passed in WorkflowOptions" in {
4347 val wei = Option (" " )
44- TesTask .makeResources(runtimeAttributes, wei) shouldEqual
45- Resources (None , None , None , Option (false ), None , Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" " )))
48+ TesTask .makeResources(runtimeAttributes, wei, internalPathPrefix) shouldEqual
49+ Resources (None , None , None , Option (false ), None ,
50+ Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" " ),
51+ expectedTuple))
4652 )
4753 }
4854
4955 it should " create the correct resources when no identity is passed in WorkflowOptions" in {
5056 val wei = None
51- TesTask .makeResources(runtimeAttributes, wei) shouldEqual
52- Resources (None , None , None , Option (false ), None , Option (Map .empty[String , Option [String ]])
53- )
57+ TesTask .makeResources(runtimeAttributes, wei, internalPathPrefix) shouldEqual
58+ Resources (None , None , None , Option (false ), None , Option (Map (expectedTuple)))
5459 }
5560
5661 it should " create the correct resources when an identity is passed in via backend config" in {
5762 val weic = Option (WorkflowExecutionIdentityConfig (" abc123" ))
5863 val weio = Option (WorkflowExecutionIdentityOption (" def456" ))
5964 val wei = TesTask .getPreferredWorkflowExecutionIdentity(weic, weio)
60- TesTask .makeResources(runtimeAttributes, wei) shouldEqual
61- Resources (None , None , None , Option (false ), None , Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" abc123" )))
65+ TesTask .makeResources(runtimeAttributes, wei, internalPathPrefix) shouldEqual
66+ Resources (None , None , None , Option (false ), None , Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" abc123" ),
67+ expectedTuple))
6268 )
6369 }
6470
6571 it should " create the correct resources when no identity is passed in via backend config" in {
6672 val weic = None
6773 val weio = Option (WorkflowExecutionIdentityOption (" def456" ))
6874 val wei = TesTask .getPreferredWorkflowExecutionIdentity(weic, weio)
69- TesTask .makeResources(runtimeAttributes, wei) shouldEqual
70- Resources (None , None , None , Option (false ), None , Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" def456" )))
75+ TesTask .makeResources(runtimeAttributes, wei, internalPathPrefix) shouldEqual
76+ Resources (None , None , None , Option (false ), None , Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" def456" ),
77+ expectedTuple))
7178 )
7279 }
7380
81+ it should " correctly set the internal path prefix when provided as a backend parameter" in {
82+ val wei = Option (" abc123" )
83+ val internalPathPrefix = Option (" mock/path/to/tes/task" )
84+ TesTask .makeResources(runtimeAttributes, wei, internalPathPrefix) shouldEqual
85+ Resources (None , None , None , Option (false ), None ,
86+ Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" abc123" ),
87+ " internal_path_prefix" -> internalPathPrefix)
88+ ))
89+ }
90+
91+ it should " correctly resolve the path to .../tes_task and add the k/v pair to backend parameters" in {
92+ val emptyWorkflowOptions = WorkflowOptions (JsObject (Map .empty[String , JsValue ]))
93+ val workflowDescriptor = buildWdlWorkflowDescriptor(TestWorkflows .HelloWorld ,
94+ labels = Labels (" foo" -> " bar" ))
95+ val jobDescriptor = jobDescriptorFromSingleCallWorkflow(workflowDescriptor,
96+ Map .empty,
97+ emptyWorkflowOptions,
98+ Set .empty)
99+ val tesPaths = TesJobPaths (jobDescriptor.key,
100+ jobDescriptor.workflowDescriptor,
101+ TestConfig .emptyConfig)
102+
103+ val expectedKey = " internal_path_prefix"
104+ val expectedValue = Option (tesPaths.tesTaskRoot.pathAsString)
105+
106+ // Assert path correctly ends up in the resources
107+ val wei = Option (" abc123" )
108+ TesTask .makeResources(runtimeAttributes, wei, expectedValue) shouldEqual
109+ Resources (None , None , None , Option (false ), None ,
110+ Option (Map (TesWorkflowOptionKeys .WorkflowExecutionIdentity -> Option (" abc123" ),
111+ expectedKey -> expectedValue))
112+ )
113+ }
114+
74115 it should " copy labels to tags" in {
75116 val jobLogger = mock[JobLogger ]
76117 val emptyWorkflowOptions = WorkflowOptions (JsObject (Map .empty[String , JsValue ]))
0 commit comments