From 46e966dcb6c02b91dccc7dc5b334df01d0022024 Mon Sep 17 00:00:00 2001 From: Jing Qi Date: Wed, 22 May 2024 05:24:14 -0600 Subject: [PATCH] fix: access token expired during pipelineRun (#1182) fix: access token expired and build pipelineRun Signed-off-by: Jing Qi Add managedFw in the ticker to avoid access token expired Updated to use WaitForComponentPipelineToBeFinished function and removed the other loop --- tests/release/pipelines/fbc_release.go | 10 +++---- tests/release/pipelines/release_to_github.go | 20 +++----------- tests/release/pipelines/rh_advisories.go | 26 ++++++------------- .../release/pipelines/rh_push_to_redhat_io.go | 26 ++++++------------- 4 files changed, 25 insertions(+), 57 deletions(-) diff --git a/tests/release/pipelines/fbc_release.go b/tests/release/pipelines/fbc_release.go index 6d0a9e02c..66be8329f 100644 --- a/tests/release/pipelines/fbc_release.go +++ b/tests/release/pipelines/fbc_release.go @@ -100,7 +100,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- var _ = Describe("Post-release verification", func() { It("verifies that a build PipelineRun is created in dev namespace and succeeds", func() { - assertBuildPipelineRunCreated(*devFw, devNamespace, managedNamespace, fbcApplicationName, component) + assertBuildPipelineRunSucceeded(*devFw, devNamespace, managedNamespace, fbcApplicationName, component) }) It("verifies the fbc release pipelinerun is running and succeeds", func() { @@ -142,7 +142,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- var _ = Describe("FBC hotfix post-release verification", func() { It("verifies that a build PipelineRun is created in dev namespace and succeeds", func() { - assertBuildPipelineRunCreated(*devFw, devNamespace, managedNamespace, fbcHotfixAppName, component) + assertBuildPipelineRunSucceeded(*devFw, devNamespace, managedNamespace, fbcHotfixAppName, component) }) It("verifies the fbc release pipelinerun is running and succeeds", func() { @@ -186,7 +186,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- var _ = Describe("FBC pre-GA post-release verification", func() { It("verifies that a build PipelineRun is created in dev namespace and succeeds", func() { - assertBuildPipelineRunCreated(*devFw, devNamespace, managedNamespace, fbcPreGAAppName, component) + assertBuildPipelineRunSucceeded(*devFw, devNamespace, managedNamespace, fbcPreGAAppName, component) }) It("verifies the fbc release pipelinerun is running and succeeds", func() { @@ -200,12 +200,12 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- }) }) -func assertBuildPipelineRunCreated(devFw framework.Framework, devNamespace, managedNamespace, fbcAppName string, component *appservice.Component) { +func assertBuildPipelineRunSucceeded(devFw framework.Framework, devNamespace, managedNamespace, fbcAppName string, component *appservice.Component) { dFw := releasecommon.NewFramework(devWorkspace) devFw = *dFw // Create a ticker that ticks every 3 minutes ticker := time.NewTicker(3 * time.Minute) - // Schedule the stop of the ticker after 10 minutes + // Schedule the stop of the ticker after 5 minutes time.AfterFunc(5*time.Minute, func() { ticker.Stop() fmt.Println("Stopped executing every 3 minutes.") diff --git a/tests/release/pipelines/release_to_github.go b/tests/release/pipelines/release_to_github.go index 45592d4d0..043337898 100644 --- a/tests/release/pipelines/release_to_github.go +++ b/tests/release/pipelines/release_to_github.go @@ -16,7 +16,6 @@ import ( "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/framework" "github.com/redhat-appstudio/e2e-tests/pkg/utils" - "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" releasecommon "github.com/redhat-appstudio/e2e-tests/tests/release" releaseapi "github.com/redhat-appstudio/release-service/api/v1alpha1" tektonutils "github.com/redhat-appstudio/release-service/tekton/utils" @@ -140,22 +139,11 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for release-to-github managedFw = releasecommon.NewFramework(managedWorkspace) } }() - Eventually(func() error { - buildPR, err = devFw.AsKubeDeveloper.HasController.GetComponentPipelineRun(component.Name, sampApplicationName, devNamespace, "") - if err != nil { - return err - } - if !buildPR.IsDone() { - return fmt.Errorf("build pipelinerun %s in namespace %s did not finish yet", buildPR.Name, buildPR.Namespace) - } - Expect(tekton.HasPipelineRunSucceeded(buildPR)).To(BeTrue(), fmt.Sprintf("build pipelinerun %s/%s did not succeed", buildPR.GetNamespace(), buildPR.GetName())) - snapshot, err = devFw.AsKubeDeveloper.IntegrationController.GetSnapshot("", buildPR.Name, "", devNamespace) - if err != nil { - return err - } - return nil - }, releasecommon.BuildPipelineRunCompletionTimeout, releasecommon.DefaultInterval).Should(Succeed(), "timed out when waiting for build pipelinerun to be created") + buildPR, err = devFw.AsKubeDeveloper.HasController.GetComponentPipelineRun(component.Name, sampApplicationName, devNamespace, "") + Expect(err).ShouldNot(HaveOccurred()) Expect(devFw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(component, "", devFw.AsKubeDeveloper.TektonController, &has.RetryOptions{Retries: 3, Always: true}, nil)).To(Succeed()) + snapshot, err = devFw.AsKubeDeveloper.IntegrationController.GetSnapshot("", buildPR.Name, "", devNamespace) + Expect(err).ShouldNot(HaveOccurred()) }) It("verifies release pipelinerun is running and succeeds", func() { devFw = releasecommon.NewFramework(devWorkspace) diff --git a/tests/release/pipelines/rh_advisories.go b/tests/release/pipelines/rh_advisories.go index 5ef1e355f..d6a243ae9 100644 --- a/tests/release/pipelines/rh_advisories.go +++ b/tests/release/pipelines/rh_advisories.go @@ -17,7 +17,6 @@ import ( "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/framework" "github.com/redhat-appstudio/e2e-tests/pkg/utils" - "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" releasecommon "github.com/redhat-appstudio/e2e-tests/tests/release" releaseapi "github.com/redhat-appstudio/release-service/api/v1alpha1" tektonutils "github.com/redhat-appstudio/release-service/tekton/utils" @@ -119,10 +118,11 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-advisories pip var _ = Describe("Post-release verification", func() { It("verifies that a build PipelineRun is created in dev namespace and succeeds", func() { devFw = releasecommon.NewFramework(devWorkspace) + managedFw = releasecommon.NewFramework(managedWorkspace) // Create a ticker that ticks every 3 minutes ticker := time.NewTicker(3 * time.Minute) - // Schedule the stop of the ticker after 10 minutes - time.AfterFunc(10*time.Minute, func() { + // Schedule the stop of the ticker after 15 minutes + time.AfterFunc(15*time.Minute, func() { ticker.Stop() fmt.Println("Stopped executing every 3 minutes.") }) @@ -130,24 +130,14 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-advisories pip go func() { for range ticker.C { devFw = releasecommon.NewFramework(devWorkspace) + managedFw = releasecommon.NewFramework(managedWorkspace) } }() - Eventually(func() error { - buildPR, err = devFw.AsKubeDeveloper.HasController.GetComponentPipelineRun(component.Name, advsApplicationName, devNamespace, "") - if err != nil { - return err - } - if !buildPR.IsDone() { - return fmt.Errorf("build pipelinerun %s in namespace %s did not finish yet", buildPR.Name, buildPR.Namespace) - } - Expect(tekton.HasPipelineRunSucceeded(buildPR)).To(BeTrue(), fmt.Sprintf("build pipelinerun %s/%s did not succeed", buildPR.GetNamespace(), buildPR.GetName())) - snapshot, err = devFw.AsKubeDeveloper.IntegrationController.GetSnapshot("", buildPR.Name, "", devNamespace) - if err != nil { - return err - } - return nil - }, releasecommon.BuildPipelineRunCompletionTimeout, releasecommon.DefaultInterval).Should(Succeed(), "timed out when waiting for build pipelinerun to be created") + buildPR, err = devFw.AsKubeDeveloper.HasController.GetComponentPipelineRun(component.Name, advsApplicationName, devNamespace, "") + Expect(err).ShouldNot(HaveOccurred()) Expect(devFw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(component, "", devFw.AsKubeDeveloper.TektonController, &has.RetryOptions{Retries: 3, Always: true}, nil)).To(Succeed()) + snapshot, err = devFw.AsKubeDeveloper.IntegrationController.GetSnapshot("", buildPR.Name, "", devNamespace) + Expect(err).ShouldNot(HaveOccurred()) }) It("verifies the advs release pipelinerun is running and succeeds", func() { devFw = releasecommon.NewFramework(devWorkspace) diff --git a/tests/release/pipelines/rh_push_to_redhat_io.go b/tests/release/pipelines/rh_push_to_redhat_io.go index d5bcb0f1b..92aeafe90 100644 --- a/tests/release/pipelines/rh_push_to_redhat_io.go +++ b/tests/release/pipelines/rh_push_to_redhat_io.go @@ -17,7 +17,6 @@ import ( "github.com/redhat-appstudio/e2e-tests/pkg/constants" "github.com/redhat-appstudio/e2e-tests/pkg/framework" "github.com/redhat-appstudio/e2e-tests/pkg/utils" - "github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton" tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" releaseapi "github.com/redhat-appstudio/release-service/api/v1alpha1" releasecommon "github.com/redhat-appstudio/e2e-tests/tests/release" @@ -123,10 +122,11 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-push-to-redhat var _ = Describe("Post-release verification", func() { It("verifies that a build PipelineRun is created in dev namespace and succeeds", func() { devFw = releasecommon.NewFramework(devWorkspace) + managedFw = releasecommon.NewFramework(managedWorkspace) // Create a ticker that ticks every 3 minutes ticker := time.NewTicker(3 * time.Minute) // Schedule the stop of the ticker after 15 minutes - time.AfterFunc(10*time.Minute, func() { + time.AfterFunc(15*time.Minute, func() { ticker.Stop() fmt.Println("Stopped executing every 3 minutes.") }) @@ -134,24 +134,14 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-push-to-redhat go func() { for range ticker.C { devFw = releasecommon.NewFramework(devWorkspace) + managedFw = releasecommon.NewFramework(managedWorkspace) } }() - Eventually(func() error { - buildPR, err = devFw.AsKubeDeveloper.HasController.GetComponentPipelineRun(testComponent.Name, rhioApplicationName, devNamespace, "") - if err != nil { - return err - } - if !buildPR.IsDone() { - return fmt.Errorf("build pipelinerun %s in namespace %s did not finish yet", buildPR.Name, buildPR.Namespace) - } - Expect(tekton.HasPipelineRunSucceeded(buildPR)).To(BeTrue(), fmt.Sprintf("build pipelinerun %s/%s did not succeed", buildPR.GetNamespace(), buildPR.GetName())) - snapshot, err = devFw.AsKubeDeveloper.IntegrationController.GetSnapshot("", buildPR.Name, "", devNamespace) - if err != nil { - return err - } - return nil - }, releasecommon.BuildPipelineRunCompletionTimeout, releasecommon.DefaultInterval).Should(Succeed(), "timed out when waiting for build pipelinerun to be created") - Expect(devFw.AsKubeDeveloper.HasController.WaitForComponentPipelineToBeFinished(testComponent, "", devFw.AsKubeDeveloper.TektonController, &has.RetryOptions{Retries: 3, Always: true}, nil)).To(Succeed()) + buildPR, err = devFw.AsKubeDeveloper.HasController.GetComponentPipelineRun(testComponent.Name, rhioApplicationName, devNamespace, "") + Expect(err).ShouldNot(HaveOccurred()) + Expect(devFw.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(testComponent, "", devFw.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 3, Always: true}, buildPR)).To(Succeed()) + snapshot, err = devFw.AsKubeDeveloper.IntegrationController.GetSnapshot("", buildPR.Name, "", devNamespace) + Expect(err).ShouldNot(HaveOccurred()) }) It("verifies the rhio release pipelinerun is running and succeeds", func() { devFw = releasecommon.NewFramework(devWorkspace)