From 09c6c83fb7ec9a9dc29074293e5ca79202c39c7e Mon Sep 17 00:00:00 2001 From: Magnus Kulke Date: Wed, 31 Jul 2024 18:16:40 +0200 Subject: [PATCH] e2e-test: assert job condition on job tests We have elaborate condition checks on a job's pods, but we do not test the job status itself, which will produce wrong test results. A test for job that always fails (cmd: /bin/false) will pass. This keeps the current assertions in-place, but makes the test fail on a failed job status Signed-off-by: Magnus Kulke --- src/cloud-api-adaptor/test/e2e/assessment_runner.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cloud-api-adaptor/test/e2e/assessment_runner.go b/src/cloud-api-adaptor/test/e2e/assessment_runner.go index a1d5e3bc4..df6861f44 100644 --- a/src/cloud-api-adaptor/test/e2e/assessment_runner.go +++ b/src/cloud-api-adaptor/test/e2e/assessment_runner.go @@ -314,6 +314,11 @@ func (tc *TestCase) Run() { var podlist v1.PodList if tc.job != nil { + conditions := tc.job.Status.Conditions + if len(conditions) == 1 && conditions[0].Type == batchv1.JobFailed { + t.Errorf("Job failed") + } + if err := client.Resources(tc.job.Namespace).List(ctx, &podlist); err != nil { t.Fatal(err) }