From 11fcc686b19ee2e041f67066e38e084f7af1f9c3 Mon Sep 17 00:00:00 2001 From: Or Shoval Date: Wed, 19 Jul 2023 17:17:06 +0300 Subject: [PATCH] tests: Fix lint problems on job.go Signed-off-by: Or Shoval --- tests/libnet/job/job.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/libnet/job/job.go b/tests/libnet/job/job.go index 4c9d39d0b67c..6964a37808d5 100644 --- a/tests/libnet/job/job.go +++ b/tests/libnet/job/job.go @@ -84,7 +84,8 @@ fi`, // which tries to contact the host on the provided port. // It expects to receive "Hello World!" to succeed. func NewHelloWorldJobTCP(host string, port string) *batchv1.Job { - check := fmt.Sprintf(`set -x; x="$(head -n 1 < <(nc %s %s -i 3 -w 3 --no-shutdown))"; echo "$x" ; if [ "$x" = "Hello World!" ]; then echo "succeeded"; exit 0; else echo "failed"; exit 1; fi`, host, port) + check := fmt.Sprintf(`set -x; x="$(head -n 1 < <(nc %s %s -i 3 -w 3 --no-shutdown))"; echo "$x" ; \ + if [ "$x" = "Hello World!" ]; then echo "succeeded"; exit 0; else echo "failed"; exit 1; fi`, host, port) return NewHelloWorldJob(check) } @@ -92,7 +93,8 @@ func NewHelloWorldJobTCP(host string, port string) *batchv1.Job { // This pod tries to contact the host on the provided port, over HTTP. // On success - it expects to receive "Hello World!". func NewHelloWorldJobHTTP(host string, port string) *batchv1.Job { - check := fmt.Sprintf(`set -x; x="$(head -n 1 < <(curl --silent %s:%s))"; echo "$x" ; if [ "$x" = "Hello World!" ]; then echo "succeeded"; exit 0; else echo "failed"; exit 1; fi`, libnet.FormatIPForURL(host), port) + check := fmt.Sprintf(`set -x; x="$(head -n 1 < <(curl --silent %s:%s))"; echo "$x" ; \ + if [ "$x" = "Hello World!" ]; then echo "succeeded"; exit 0; else echo "failed"; exit 1; fi`, libnet.FormatIPForURL(host), port) return NewHelloWorldJob(check) } @@ -105,7 +107,7 @@ func WaitForJob(job *batchv1.Job, toSucceed bool, timeout time.Duration) error { jobFailedError := func(job *batchv1.Job) error { if toSucceed { - return fmt.Errorf("Job %s finished with failure, status: %+v", job.Name, job.Status) + return fmt.Errorf("job %s finished with failure, status: %+v", job.Name, job.Status) } return nil } @@ -113,7 +115,7 @@ func WaitForJob(job *batchv1.Job, toSucceed bool, timeout time.Duration) error { if toSucceed { return nil } - return fmt.Errorf("Job %s finished with success, status: %+v", job.Name, job.Status) + return fmt.Errorf("job %s finished with success, status: %+v", job.Name, job.Status) } const finish = true @@ -133,13 +135,17 @@ func WaitForJob(job *batchv1.Job, toSucceed bool, timeout time.Duration) error { if c.Status == k8sv1.ConditionTrue { return finish, jobFailedError(job) } + case batchv1.JobSuspended: + break + case batchv1.JobFailureTarget: + break } } return !finish, nil }) if err != nil { - return fmt.Errorf("Job %s timeout reached, status: %+v, err: %v", job.Name, job.Status, err) + return fmt.Errorf("job %s timeout reached, status: %+v, err: %v", job.Name, job.Status, err) } return nil }