Skip to content

Commit a2114e9

Browse files
committed
update tests with latests changes
Signed-off-by: jorgee <jorge.ejarque@seqera.io>
1 parent 51597f1 commit a2114e9

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

plugins/nf-google/src/test/nextflow/cloud/google/batch/GoogleBatchTaskHandlerTest.groovy

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,44 @@ class GoogleBatchTaskHandlerTest extends Specification {
731731
handler.task.error?.message == TASK_ERROR
732732
result == RESULT
733733

734+
where:
735+
TASK_STATE | DESC | EXIT_CODE | ARRAY_CHILD | TASK_STATUS | EXIT_STATUS | RESULT | TASK_ERROR
736+
TaskStatus.State.FAILED | "Error" | null | true | nextflow.processor.TaskStatus.COMPLETED | 0 | true | null
737+
null | "Error" | null | true | nextflow.processor.TaskStatus.COMPLETED | 1 | true | null
738+
TaskStatus.State.FAILED | "Error" | null | false | nextflow.processor.TaskStatus.COMPLETED | 0 | true | null
739+
null | "Error" | null | false | nextflow.processor.TaskStatus.COMPLETED | 1 | true | null
740+
}
741+
742+
def 'should check if completed when 500xx errors' () {
743+
given:
744+
def jobId = '1'
745+
def taskId = '1'
746+
def client = Mock(BatchClient){
747+
getTaskInArrayStatus(jobId, taskId) >> { TASK_STATE ? makeTaskStatus(TASK_STATE, DESC, EXIT_CODE): null }
748+
getTaskStatus(jobId, taskId) >> { TASK_STATE ? makeTaskStatus(TASK_STATE, DESC, EXIT_CODE): null }
749+
getJobStatus(jobId ) >> makeJobStatus(JobStatus.State.FAILED,DESC)
750+
}
751+
def logging = Mock(BatchLogging)
752+
def executor = Mock(GoogleBatchExecutor){
753+
getLogging() >> logging
754+
}
755+
def task = new TaskRun()
756+
task.name = 'hello'
757+
def handler = Spy(new GoogleBatchTaskHandler(jobId: jobId, taskId: taskId, client: client, task: task, isArrayChild: ARRAY_CHILD, status: nextflow.processor.TaskStatus.RUNNING, executor: executor))
758+
when:
759+
def result = handler.checkIfCompleted()
760+
then:
761+
0 * handler.readExitFile() >> EXIT_STATUS
762+
handler.status == TASK_STATUS
763+
handler.task.exitStatus == EXIT_STATUS
764+
handler.task.error?.message == TASK_ERROR
765+
result == RESULT
766+
734767
where:
735768
TASK_STATE | DESC | EXIT_CODE | ARRAY_CHILD | TASK_STATUS | EXIT_STATUS | RESULT | TASK_ERROR
736-
TaskStatus.State.FAILED | "Error" | null | true | nextflow.processor.TaskStatus.COMPLETED | 0 | true | null
737-
null | "Error" | null | true | nextflow.processor.TaskStatus.COMPLETED | 1 | true | null
738-
TaskStatus.State.FAILED | 'Task failed due to Spot VM preemption with exit code 50001.' | 50001 | true | nextflow.processor.TaskStatus.COMPLETED | Integer.MAX_VALUE | true | 'Task failed due to Spot VM preemption with exit code 50001.'
739-
TaskStatus.State.FAILED | "Error" | null | false | nextflow.processor.TaskStatus.COMPLETED | 0 | true | null
740-
null | "Error" | null | false | nextflow.processor.TaskStatus.COMPLETED | 1 | true | null
741-
TaskStatus.State.FAILED | 'Task failed due to Spot VM preemption with exit code 50001.' | 50001 | false | nextflow.processor.TaskStatus.COMPLETED | Integer.MAX_VALUE | true | 'Task failed due to Spot VM preemption with exit code 50001.'
769+
TaskStatus.State.FAILED | 'Task failed due to Spot VM preemption with exit code 50001.' | 50001 | true | nextflow.processor.TaskStatus.COMPLETED | 50001 | true | 'Task failed due to Spot VM preemption with exit code 50001.'
770+
TaskStatus.State.FAILED | 'Task failed due to Spot VM preemption with exit code 50001.' | 50001 | false | nextflow.processor.TaskStatus.COMPLETED | 50001 | true | 'Task failed due to Spot VM preemption with exit code 50001.'
742771
}
743772

773+
744774
}

0 commit comments

Comments
 (0)