@@ -739,4 +739,80 @@ class AzBatchServiceTest extends Specification {
739
739
[managedIdentity : [clientId : ' client-123' ]] | ' client-123'
740
740
}
741
741
742
+ def ' should create task for submit without container' () {
743
+ given :
744
+ Global . session = Mock (Session ) { getConfig()>> [:] }
745
+ and :
746
+ def POOL_ID = ' my-pool'
747
+ def SAS = ' 123'
748
+ def CONFIG = [storage : [sasToken : SAS ]]
749
+ def exec = Mock (AzBatchExecutor ) {getConfig() >> new AzConfig (CONFIG ) }
750
+ AzBatchService azure = Spy (new AzBatchService (exec))
751
+ and :
752
+ def TASK = Mock (TaskRun ) {
753
+ getHash() >> HashCode . fromInt(1 )
754
+ getContainer() >> null
755
+ getConfig() >> Mock (TaskConfig )
756
+ }
757
+ and :
758
+ def SPEC = new AzVmPoolSpec (poolId : POOL_ID , vmType : Mock (AzVmType ), opts : new AzPoolOpts ([:]))
759
+
760
+ when :
761
+ def result = azure. createTask(POOL_ID , ' salmon' , TASK )
762
+ then :
763
+ 1 * azure. getPoolSpec(POOL_ID ) >> SPEC
764
+ 1 * azure. computeSlots(TASK , SPEC ) >> 4
765
+ 1 * azure. resourceFileUrls(TASK , SAS ) >> []
766
+ 1 * azure. outputFileUrls(TASK , SAS ) >> []
767
+ and :
768
+ result. id == ' nf-01000000'
769
+ result. requiredSlots == 4
770
+ and :
771
+ result. commandLine == " sh -c 'bash .command.run 2>&1 | tee .command.log'"
772
+ and :
773
+ result. containerSettings == null
774
+ }
775
+
776
+ def ' should create task for submit with container and fusion' () {
777
+ given :
778
+ def SAS = ' 1234567890' * 10
779
+ def AZURE = [storage : [sasToken : SAS , accountName : ' my-account' ]]
780
+ Global . session = Mock (Session ) { getConfig()>> [fusion :[enabled :true ], azure : AZURE ] }
781
+ def WORKDIR = FileSystemPathFactory . parse(' az://foo/work/dir' )
782
+ and :
783
+ def POOL_ID = ' my-pool'
784
+ def exec = Mock (AzBatchExecutor ) {getConfig() >> new AzConfig (AZURE ) }
785
+ AzBatchService azure = Spy (new AzBatchService (exec))
786
+ and :
787
+ def TASK = Mock (TaskRun ) {
788
+ getHash() >> HashCode . fromInt(1 )
789
+ getContainer() >> ' ubuntu:latest'
790
+ getConfig() >> Mock (TaskConfig )
791
+ getWorkDir() >> WORKDIR
792
+ toTaskBean() >> Mock (TaskBean ) {
793
+ getWorkDir() >> WORKDIR
794
+ getInputFiles() >> [:]
795
+ }
796
+ }
797
+ and :
798
+ def SPEC = new AzVmPoolSpec (poolId : POOL_ID , vmType : Mock (AzVmType ), opts : new AzPoolOpts ([:]))
799
+
800
+ when :
801
+ def result = azure. createTask(POOL_ID , ' salmon' , TASK )
802
+ then :
803
+ 1 * azure. getPoolSpec(POOL_ID ) >> SPEC
804
+ 1 * azure. computeSlots(TASK , SPEC ) >> 1
805
+ 1 * azure. resourceFileUrls(TASK , SAS ) >> []
806
+ 1 * azure. outputFileUrls(TASK , SAS ) >> []
807
+ and :
808
+ result. id == ' nf-01000000'
809
+ result. requiredSlots == 1
810
+ and :
811
+ result. commandLine == " /usr/bin/fusion bash /fusion/az/foo/work/dir/.command.run"
812
+ and :
813
+ result. containerSettings. imageName == ' ubuntu:latest'
814
+ result. containerSettings. containerRunOptions. contains(' --privileged' )
815
+ result. containerSettings. containerRunOptions. contains(' -e FUSION_WORK=/fusion/az/foo/work/dir' )
816
+ }
817
+
742
818
}
0 commit comments