Skip to content

Commit

Permalink
Add tests for Azure Batch createStartTask method
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrtalbot committed Apr 5, 2024
1 parent 4cc83b1 commit f9708b0
Showing 1 changed file with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,71 @@ class AzBatchServiceTest extends Specification {
}


def 'should configure default startTask' () {
given:
def CONFIG = [batch:[copyToolInstallMode: 'node']]
def exec = Mock(AzBatchExecutor) {getConfig() >> new AzConfig(CONFIG) }
def svc = new AzBatchService(exec)

when:
def configuredStartTask = svc.createStartTask( new AzPoolOpts() )
then:
configuredStartTask.commandLine == 'bash -c "chmod +x azcopy && mkdir $AZ_BATCH_NODE_SHARED_DIR/bin/ && cp azcopy $AZ_BATCH_NODE_SHARED_DIR/bin/"'
}

def 'should configure custom startTask' () {
given:
def CONFIG = [batch:[copyToolInstallMode: 'node']]
def exec = Mock(AzBatchExecutor) {getConfig() >> new AzConfig(CONFIG) }
def svc = new AzBatchService(exec)

when:
def configuredStartTask = svc.createStartTask( new AzPoolOpts(startTask: 'echo hello-world') )
then:
configuredStartTask.commandLine == 'bash -c "echo hello-world; chmod +x azcopy && mkdir $AZ_BATCH_NODE_SHARED_DIR/bin/ && cp azcopy $AZ_BATCH_NODE_SHARED_DIR/bin/"'
configuredStartTask.resourceFiles == [
[filePath: 'azcopy', blobSource: 'https://aka.ms/downloadazcopy-v10-linux']
]
}

def 'should configure not install AzCopy because copyToolInstallMode is off' () {
given:
def CONFIG = [batch:[copyToolInstallMode: 'off']]
def exec = Mock(AzBatchExecutor) {getConfig() >> new AzConfig(CONFIG) }
def svc = new AzBatchService(exec)

when:
def configuredStartTask = svc.createStartTask( new AzPoolOpts(startTask: 'echo hello-world') )
then:
configuredStartTask.commandLine == 'bash -c "echo hello-world"'
configuredStartTask.resourceFiles == []
}

def 'should configure not install AzCopy because copyToolInstallMode is task' () {
given:
def CONFIG = [batch:[copyToolInstallMode: 'task']]
def exec = Mock(AzBatchExecutor) {getConfig() >> new AzConfig(CONFIG) }
def svc = new AzBatchService(exec)

when:
def configuredStartTask = svc.createStartTask( new AzPoolOpts(startTask: 'echo hello-world') )
then:
configuredStartTask.commandLine == 'bash -c "echo hello-world"'
configuredStartTask.resourceFiles == []
}

def 'should create null startTask because no options are enabled' () {
given:
def CONFIG = [batch:[copyToolInstallMode: 'off']]
def exec = Mock(AzBatchExecutor) {getConfig() >> new AzConfig(CONFIG) }
def svc = new AzBatchService(exec)

when:
def configuredStartTask = svc.createStartTask( new AzPoolOpts() )
then:
configuredStartTask == null
}

def 'should check scaling formula' () {
given:
def exec = Mock(AzBatchExecutor) { getConfig() >> new AzConfig([:]) }
Expand Down

0 comments on commit f9708b0

Please sign in to comment.