Skip to content

Commit

Permalink
fix(provider/oraclebmcs): Handle missing instances (#1566)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlord authored and Matt Duftler committed Apr 13, 2017
1 parent 6f0010d commit a63b028
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class OracleBMCSInstanceProvider implements InstanceProvider<OracleBMCSInstance>
if (identifiers.size() > 1) {
log.warn("There should be at most one identifier!")
}
Set<OracleBMCSInstance> instances = loadInstances(identifiers)
return instances.first()
Set<OracleBMCSInstance> instances = loadInstances(identifiers) ?: null
return instances?.first()
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ class OracleBMCSInstanceProviderSpec extends Specification {
def instanceProvider = new OracleBMCSInstanceProvider(cache, new ObjectMapper(), null)

expect:
instanceProvider.getInstance(account, region, id).name == res.name
instanceProvider.getInstance(account, region, id).healthState == res.healthState
instanceProvider.getInstance(account, region, id).health[0].size() == 3
instanceProvider.getInstance(account, region, id)?.name == res.name
instanceProvider.getInstance(account, region, id)?.healthState == res.healthState
instanceProvider.getInstance(account, region, id)?.health?.first()?.size() == res.hsize

where:
account | region | id || res
"A1" | "R1" | "ocid.instance.1" || [name: "Instance 1", healthState: HealthState.Up]
"A1" | "R1" | "Instance 1" || [name: "Instance 1", healthState: HealthState.Up]
"A2" | "R2" | "ocid.instance.2" || [name: "Instance 2", healthState: HealthState.Starting]
"A2" | "R2" | "Instance 2" || [name: "Instance 2", healthState: HealthState.Starting]
"A2" | "R2" | "Instance 3" || [name: "Instance 3", healthState: HealthState.Starting]
"A1" | "R1" | "ocid.instance.1" || [name: "Instance 1", healthState: HealthState.Up, hsize: 3]
"A1" | "R1" | "Instance 1" || [name: "Instance 1", healthState: HealthState.Up, hsize: 3]
"A2" | "R2" | "ocid.instance.2" || [name: "Instance 2", healthState: HealthState.Starting, hsize: 3]
"A2" | "R2" | "Instance 2" || [name: "Instance 2", healthState: HealthState.Starting, hsize: 3]
"A2" | "R2" | "Instance 3" || [name: "Instance 3", healthState: HealthState.Starting, hsize: 3]
"A2" | "R2" | "Does not exist" || [name: null, healthState: null, hsize: null]
}

def buildInstanceCacheData(def num, def region, def account, Instance.LifecycleState lifecycleState) {
Expand Down

0 comments on commit a63b028

Please sign in to comment.