Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ class AwsBatchTaskHandler extends TaskHandler implements BatchHandler<String,Job
* @return The number of times this job was retried due to spot instance reclamation
*/
protected Integer getNumSpotInterruptions(String jobId) {
if (!jobId)
if (!jobId || !isCompleted())
return null

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ class AwsBatchTaskHandlerTest extends Specification {
when:
def trace = handler.getTraceRecord()
then:
1 * handler.isCompleted() >> false
2 * handler.isCompleted() >> false
1 * handler.getMachineInfo() >> new CloudMachineInfo('x1.large', 'us-east-1b', PriceModel.spot)

and:
Expand Down Expand Up @@ -1195,12 +1195,14 @@ class AwsBatchTaskHandlerTest extends Specification {
when:
def resultNoAttempts = handler.getNumSpotInterruptions('job-123')
then:
1 * handler.isCompleted() >> true
1 * handler.describeJob('job-123') >> JobDetail.builder().attempts([]).build()
resultNoAttempts == 0

when:
def resultNonSpot = handler.getNumSpotInterruptions('job-456')
then:
1 * handler.isCompleted() >> true
1 * handler.describeJob('job-456') >> JobDetail.builder().attempts([attempt1, attempt2]).build()
resultNonSpot == 0
}
Expand All @@ -1212,18 +1214,21 @@ class AwsBatchTaskHandlerTest extends Specification {
when:
def resultNotCompleted = handler.getNumSpotInterruptions('job-123')
then:
1 * handler.describeJob(_)
1 * handler.isCompleted() >> false
0 * handler.describeJob(_)
resultNotCompleted == null

when:
def resultNullJobId = handler.getNumSpotInterruptions(null)
then:
0 * handler.isCompleted()
0 * handler.describeJob(_)
resultNullJobId == null

when:
def resultException = handler.getNumSpotInterruptions('job-789')
then:
1 * handler.isCompleted() >> true
1 * handler.describeJob('job-789') >> { throw new RuntimeException("Error") }
resultException == null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask {
*/

protected Integer getNumSpotInterruptions(String jobId) {
if (!jobId || !taskId) {
if (!jobId || !taskId || !isCompleted()) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
when:
def trace = handler.getTraceRecord()
then:
1 * handler.isCompleted() >> true
2 * handler.isCompleted() >> true
1 * client.getTaskStatus('xyz-123', '0') >> taskStatus
and:
trace.native_id == 'xyz-123/0/789'
Expand Down Expand Up @@ -869,6 +869,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
def result = handler.getNumSpotInterruptions('job-123')

then:
handler.isCompleted() >> true
result == 0
}

Expand Down Expand Up @@ -900,6 +901,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
def result = handler.getNumSpotInterruptions('job-123')

then:
handler.isCompleted() >> true
result == 2
}

Expand All @@ -913,6 +915,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
def resultIncompleteTask = handler.getNumSpotInterruptions('job-123')

then:
handler.isCompleted() >> false
resultNullJobId == null
resultIncompleteTask == null
}
Expand All @@ -929,6 +932,7 @@ class GoogleBatchTaskHandlerTest extends Specification {
def result = handler.getNumSpotInterruptions('job-123')

then:
handler.isCompleted() >> true
result == null
}

Expand Down
Loading