From dc33f507e79ea984deb00f757cf7df13157f4ae2 Mon Sep 17 00:00:00 2001 From: xmbhasin Date: Fri, 28 Mar 2025 13:07:26 -0400 Subject: [PATCH] fix(e2e-tests): timeout failures during jenkins job checks * increase retry on job creation to fix failing test `performs backups before pod deletion and restores them even Jenkins status is restarted` * allow retry on error when retrieving finished job to fix failing test `runs kubernetes plugin job successfully` --- test/e2e/restorebackup_test.go | 2 +- test/e2e/seedjobs_test.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/test/e2e/restorebackup_test.go b/test/e2e/restorebackup_test.go index 8477b64b..39d85cc9 100644 --- a/test/e2e/restorebackup_test.go +++ b/test/e2e/restorebackup_test.go @@ -30,7 +30,7 @@ func waitForJobCreation(jenkinsClient client.Jenkins, jobID string) { return false, err } return err == nil, err - }, time.Minute*3, time.Second*2).Should(BeTrue()) + }, time.Duration(110)*retryInterval, retryInterval).Should(BeTrue()) Expect(err).NotTo(HaveOccurred()) } diff --git a/test/e2e/seedjobs_test.go b/test/e2e/seedjobs_test.go index 97d58dbd..1d813ccb 100644 --- a/test/e2e/seedjobs_test.go +++ b/test/e2e/seedjobs_test.go @@ -186,7 +186,7 @@ if (jobRef == null) { } if (!jobRef.getDisplayName().equals("Seed Job from {{ .ID }}")) { - throw new Exception("Display name is not equal") + throw new Exception("Display name is not equal") } if (jobRef.getScm() == null) { @@ -194,7 +194,7 @@ if (jobRef.getScm() == null) { } if (jobRef.getScm().getBranches().find { val -> val.getName() == "{{ .RepositoryBranch }}" } == null) { - throw new Exception("Specified SCM branch not found") + throw new Exception("Specified SCM branch not found") } if(jobRef.getScm().getRepositories().find { it.getURIs().find { uri -> uri.toString().equals("https://github.com/jenkinsci/kubernetes-operator.git") } } == null) { @@ -221,7 +221,7 @@ if (jobRef.getTriggers().find { key, val -> val.getClass().getSimpleName() == "T for (BuildStep step : jobRef.getBuildersList()) { if (!step.getTargets().equals("{{ .Targets }}")) { - throw new Exception("Targets are not equals'") + throw new Exception("Targets are not equals'") } if (!step.getAdditionalClasspath().equals(null)) { @@ -266,9 +266,14 @@ func verifyJobHasBeenRunCorrectly(jenkinsClient jenkinsclient.Jenkins, jobID str Eventually(func() (bool, error) { job, err = jenkinsClient.GetJob(context.TODO(), jobID) - Expect(err).To(BeNil()) + if err != nil { + return false, err + } + build, err = job.GetLastBuild(context.TODO()) - Expect(err).To(BeNil()) + if err != nil { + return false, err + } By("evaluating correctness of the outcome") return build.IsGood(context.TODO()), err