Skip to content

Commit

Permalink
fix: access token expired during pipelineRun (konflux-ci#1182)
Browse files Browse the repository at this point in the history
fix: access token expired and build pipelineRun

Signed-off-by: Jing Qi <[email protected]>

Add managedFw in the ticker to avoid access token expired
Updated to use WaitForComponentPipelineToBeFinished function and removed the other loop
  • Loading branch information
jinqi7 authored May 22, 2024
1 parent 64a88a9 commit 46e966d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 57 deletions.
10 changes: 5 additions & 5 deletions tests/release/pipelines/fbc_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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.")
Expand Down
20 changes: 4 additions & 16 deletions tests/release/pipelines/release_to_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
26 changes: 8 additions & 18 deletions tests/release/pipelines/rh_advisories.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -119,35 +118,26 @@ 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.")
})
// Run a goroutine to handle the ticker ticks
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)
Expand Down
26 changes: 8 additions & 18 deletions tests/release/pipelines/rh_push_to_redhat_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -123,35 +122,26 @@ 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.")
})
// Run a goroutine to handle the ticker ticks
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)
Expand Down

0 comments on commit 46e966d

Please sign in to comment.