Skip to content

Commit

Permalink
Are there VMs on Mars?
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Talbot <[email protected]>
  • Loading branch information
adamrtalbot committed Jul 8, 2024
1 parent d9e398c commit bd60be3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,17 @@ class AzBatchService implements Closeable {
if( !location )
throw new IllegalArgumentException("Missing Azure location parameter")
final json = AzBatchService.class.getResourceAsStream("/nextflow/cloud/azure/vm-list-size-${location}.json")
if( !json )
if( !json ) {
log.warn("[AZURE BATCH] Unable to find Azure VM names for location: $location")
return Collections.emptyList()
}

final vmList = (List<Map>) new JsonSlurper().parse(json)

if ( vmList.isEmpty() )
log.warn("[AZURE BATCH] No VM sizes found for location: $location")

log.debug("[AZURE BATCH] vmList: ${vmList}")
return vmList
}

Expand Down Expand Up @@ -208,7 +211,6 @@ class AzBatchService implements Closeable {
if( !matchType(family, entry.name as String) )
continue
def score = computeScore(cpus, mem, entry)
log.debug "[AZURE BATCH] VM family=${entry.name} score=${score}"
if( score != null )
scores.put(score, entry.name as String)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,50 @@ class AzBatchServiceTest extends Specification {
'Standard_D5_v2' in names
}

def 'should list all VMs in region' () {
given:
def exec = Mock(AzBatchExecutor) {
getConfig() >> new AzConfig([:])
}
def svc = new AzBatchService(exec)

when:
def vms = svc.listAllVms('northeurope')

then:
[
maxDataDiskCount: 32,
memoryInMB: 28672,
name: "Standard_D4_v2",
numberOfCores: 8,
osDiskSizeInMB: 1047552,
resourceDiskSizeInMB: 409600
] in vms
[
maxDataDiskCount: 8,
memoryInMB: 7168,
name: "Basic_A3",
numberOfCores: 4,
osDiskSizeInMB: 1047552,
resourceDiskSizeInMB: 122880
] in vms
}

def 'should fail to list VMs in region' () {
given:
def exec = Mock(AzBatchExecutor) {
getConfig() >> new AzConfig([:])
}
def svc = new AzBatchService(exec)

when:
def vms = svc.listAllVms('mars')

then:
vms instanceof List
vms.isEmpty()
}

def 'should get size for vm' () {
given:
def exec = Mock(AzBatchExecutor) {
Expand Down

0 comments on commit bd60be3

Please sign in to comment.