From ab48b1641714ed3c8ee80a62cdea6190aee50bc8 Mon Sep 17 00:00:00 2001 From: Sushanta Das Date: Wed, 24 Jul 2024 11:21:20 +0530 Subject: [PATCH] Release related tests --- tests/release/const.go | 16 +++++-- tests/release/pipelines/fbc_release.go | 48 ++++++++++++++++--- .../pipelines/multiarch_rh_advisories.go | 18 +++---- .../pipelines/push_to_external_registry.go | 16 ++++++- tests/release/pipelines/release_to_github.go | 21 ++++++-- tests/release/pipelines/rh_advisories.go | 14 +++++- .../pipelines/rh_push_to_external_registry.go | 43 +++++++++++++++-- .../release/pipelines/rh_push_to_redhat_io.go | 15 +++++- tests/release/pipelines/rhtap_service_push.go | 42 +++++++++++----- tests/release/pipelines/tenant_pipelines.go | 31 ++++++++---- tests/release/releaseLib.go | 31 ++++++++++-- tests/release/service/happy_path.go | 15 +++++- 12 files changed, 255 insertions(+), 55 deletions(-) diff --git a/tests/release/const.go b/tests/release/const.go index ef49274cf7..374894fb97 100644 --- a/tests/release/const.go +++ b/tests/release/const.go @@ -1,8 +1,10 @@ package common import ( + "fmt" "time" + "github.com/konflux-ci/e2e-tests/pkg/constants" "github.com/konflux-ci/e2e-tests/pkg/utils" corev1 "k8s.io/api/core/v1" ) @@ -34,9 +36,11 @@ const ( // Pipelines constants ComponentName string = "dc-metro-map" - GitSourceComponentUrl string = "https://github.com/scoheb/dc-metro-map" + DcMetroMapGitRepoName string = "dc-metro-map" + DcMetroMapGitRevision string = "d49914874789147eb2de9bb6a12cd5d150bfff92" AdditionalComponentName string = "simple-python" - AdditionalGitSourceComponentUrl string = "https://github.com/devfile-samples/devfile-sample-python-basic" + AdditionalGitSourceComponentUrl string = "https://github.com/redhat-appstudio-qe/devfile-sample-python-basic-release" + AdditionalGitRevision string = "47fc22092005aabebce233a9b6eab994a8152bbd" ReleasedImagePushRepo string = "quay.io/redhat-appstudio-qe/dcmetromap" AdditionalReleasedImagePushRepo string = "quay.io/redhat-appstudio-qe/simplepython" PyxisStageImagesApiEndpoint string = "https://pyxis.preprod.api.redhat.com/v1/images/id/" @@ -50,6 +54,8 @@ const ( // Service constants ApplicationName string = "application" + + githubUrlFormat = "https://github.com/%s/%s" ) var ManagednamespaceSecret = []corev1.ObjectReference{ @@ -58,6 +64,8 @@ var ManagednamespaceSecret = []corev1.ObjectReference{ // Pipelines variables var ( - RelSvcCatalogURL string = utils.GetEnv("RELEASE_SERVICE_CATALOG_URL", "https://github.com/konflux-ci/release-service-catalog") - RelSvcCatalogRevision string = utils.GetEnv("RELEASE_SERVICE_CATALOG_REVISION", "staging") + githubOrg = utils.GetEnv(constants.GITHUB_E2E_ORGANIZATION_ENV, "redhat-appstudio-qe") + DcMetroMapGitSourceURL = fmt.Sprintf(githubUrlFormat, githubOrg, DcMetroMapGitRepoName) + RelSvcCatalogURL string = utils.GetEnv("RELEASE_SERVICE_CATALOG_URL", "https://github.com/konflux-ci/release-service-catalog") + RelSvcCatalogRevision string = utils.GetEnv("RELEASE_SERVICE_CATALOG_REVISION", "staging") ) diff --git a/tests/release/pipelines/fbc_release.go b/tests/release/pipelines/fbc_release.go index 84bc15cee6..59a71f4b80 100644 --- a/tests/release/pipelines/fbc_release.go +++ b/tests/release/pipelines/fbc_release.go @@ -24,7 +24,8 @@ import ( const ( fbcServiceAccountName = "release-service-account" - fbcSourceGitURL = "https://github.com/redhat-appstudio-qe/fbc-sample-repo" + fbcSourceGitURL = "https://github.com/redhat-appstudio-qe/fbc-sample-repo-release" + fbcGitRevision = "8e374e107fecf03f3c64c528bb53798039661414" fbcDockerFilePath = "catalog.Dockerfile" targetPort = 50051 relSvcCatalogPathInRepo = "pipelines/fbc-release/fbc-release.yaml" @@ -33,7 +34,6 @@ const ( var snapshot *appservice.Snapshot var releaseCR *releaseapi.Release var buildPR *tektonv1.PipelineRun -var err error var devWorkspace = utils.GetEnv(constants.RELEASE_DEV_WORKSPACE_ENV, constants.DevReleaseTeam) var managedWorkspace = utils.GetEnv(constants.RELEASE_MANAGED_WORKSPACE_ENV, constants.ManagedReleaseTeam) var devFw *framework.Framework @@ -45,7 +45,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- var devNamespace = devWorkspace + "-tenant" var managedNamespace = managedWorkspace + "-tenant" - + var err error var issueId = "bz12345" var productName = "preGA-product" var productVersion = "v2" @@ -69,6 +69,8 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- Describe("with FBC happy path", Label("fbcHappyPath"), func() { var component *appservice.Component + var baseBranchName, pacBranchName string + BeforeAll(func() { devFw = releasecommon.NewFramework(devWorkspace) managedFw = releasecommon.NewFramework(managedWorkspace) @@ -88,7 +90,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- createFBCReleasePlanAdmission(fbcReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, fbcApplicationName, fbcEnterpriseContractPolicyName, relSvcCatalogPathInRepo, "false", "", "", "", "") - component = releasecommon.CreateComponent(*devFw, devNamespace, fbcApplicationName, fbcComponentName, fbcSourceGitURL, "", "4.13", fbcDockerFilePath, constants.DefaultFbcBuilderPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*devFw, devNamespace, fbcApplicationName, fbcComponentName, fbcSourceGitURL, fbcGitRevision, "4.13", fbcDockerFilePath, constants.DefaultFbcBuilderPipelineBundle) createFBCEnterpriseContractPolicy(fbcEnterpriseContractPolicyName, *managedFw, devNamespace, managedNamespace) @@ -100,6 +102,15 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- Expect(devFw.AsKubeDeveloper.HasController.DeleteApplication(fbcApplicationName, devNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(fbcEnterpriseContractPolicyName, managedNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(fbcReleasePlanAdmissionName, managedNamespace, false)).NotTo(HaveOccurred()) + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(fbcSourceGitURL), pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(fbcSourceGitURL), baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } }) var _ = Describe("Post-release verification", func() { @@ -119,6 +130,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- Describe("with FBC hotfix process", Label("fbcHotfix"), func() { var component *appservice.Component + var baseBranchName, pacBranchName string BeforeAll(func() { devFw = releasecommon.NewFramework(devWorkspace) @@ -133,7 +145,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- createFBCReleasePlanAdmission(fbcHotfixRPAName, *managedFw, devNamespace, managedNamespace, fbcHotfixAppName, fbcHotfixECPolicyName, relSvcCatalogPathInRepo, "true", issueId, "false", "", "") - component = releasecommon.CreateComponent(*devFw, devNamespace, fbcHotfixAppName, fbcHotfixCompName, fbcSourceGitURL, "", "4.13", fbcDockerFilePath, constants.DefaultFbcBuilderPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*devFw, devNamespace, fbcHotfixAppName, fbcHotfixCompName, fbcSourceGitURL, fbcGitRevision, "4.13", fbcDockerFilePath, constants.DefaultFbcBuilderPipelineBundle) createFBCEnterpriseContractPolicy(fbcHotfixECPolicyName, *managedFw, devNamespace, managedNamespace) }) @@ -144,6 +156,15 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- Expect(devFw.AsKubeDeveloper.HasController.DeleteApplication(fbcHotfixAppName, devNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(fbcHotfixECPolicyName, managedNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(fbcHotfixRPAName, managedNamespace, false)).NotTo(HaveOccurred()) + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(fbcSourceGitURL), pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(fbcSourceGitURL), baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } }) var _ = Describe("FBC hotfix post-release verification", func() { @@ -163,6 +184,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- Describe("with FBC pre-GA process", Label("fbcPreGA"), func() { var component *appservice.Component + var baseBranchName, pacBranchName string BeforeAll(func() { devFw = releasecommon.NewFramework(devWorkspace) @@ -177,7 +199,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- createFBCReleasePlanAdmission(fbcPreGARPAName, *managedFw, devNamespace, managedNamespace, fbcPreGAAppName, fbcPreGAECPolicyName, relSvcCatalogPathInRepo, "false", issueId, "true", productName, productVersion) - component = releasecommon.CreateComponent(*devFw, devNamespace, fbcPreGAAppName, fbcPreGACompName, fbcSourceGitURL, "", "4.13", fbcDockerFilePath, constants.DefaultFbcBuilderPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*devFw, devNamespace, fbcPreGAAppName, fbcPreGACompName, fbcSourceGitURL, fbcGitRevision, "4.13", fbcDockerFilePath, constants.DefaultFbcBuilderPipelineBundle) createFBCEnterpriseContractPolicy(fbcPreGAECPolicyName, *managedFw, devNamespace, managedNamespace) }) @@ -190,6 +212,17 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- Expect(managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(fbcPreGAECPolicyName, managedNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(fbcPreGARPAName, managedNamespace, false)).NotTo(HaveOccurred()) } + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(fbcSourceGitURL), pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(fbcSourceGitURL), baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(devFw, utils.GetRepoName(fbcSourceGitURL)) }) var _ = Describe("FBC pre-GA post-release verification", func() { @@ -209,6 +242,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("FBC e2e-tests", Label("release- }) func assertBuildPipelineRunSucceeded(devFw framework.Framework, devNamespace, managedNamespace, fbcAppName string, component *appservice.Component) { + var err error dFw := releasecommon.NewFramework(devWorkspace) devFw = *dFw // Create a ticker that ticks every 3 minutes @@ -247,6 +281,7 @@ func assertBuildPipelineRunSucceeded(devFw framework.Framework, devNamespace, ma } func assertReleasePipelineRunSucceeded(devFw, managedFw framework.Framework, devNamespace, managedNamespace, fbcAppName string, component *appservice.Component) { + var err error snapshot, err = devFw.AsKubeDeveloper.IntegrationController.WaitForSnapshotToGetCreated("", "", component.Name, devNamespace) Expect(err).ToNot(HaveOccurred()) GinkgoWriter.Println("snapshot: ", snapshot.Name) @@ -278,6 +313,7 @@ func assertReleasePipelineRunSucceeded(devFw, managedFw framework.Framework, dev } func assertReleaseCRSucceeded(devFw framework.Framework, devNamespace, managedNamespace, fbcAppName string, component *appservice.Component) { + var err error dFw := releasecommon.NewFramework(devWorkspace) Eventually(func() error { releaseCR, err = dFw.AsKubeDeveloper.ReleaseController.GetRelease("", snapshot.Name, devNamespace) diff --git a/tests/release/pipelines/multiarch_rh_advisories.go b/tests/release/pipelines/multiarch_rh_advisories.go index d6d3a20f6e..e29d88dcd6 100644 --- a/tests/release/pipelines/multiarch_rh_advisories.go +++ b/tests/release/pipelines/multiarch_rh_advisories.go @@ -269,7 +269,6 @@ func createMultiArchReleasePlan(multiarchReleasePlanName string, devFw framework Expect(err).NotTo(HaveOccurred()) } - func createMultiArchReleasePlanAdmission(multiarchRPAName string, managedFw framework.Framework, devNamespace, managedNamespace, multiarchAppName, multiarchECPName, pathInRepoValue string) { var err error @@ -277,9 +276,9 @@ func createMultiArchReleasePlanAdmission(multiarchRPAName string, managedFw fram "mapping": map[string]interface{}{ "components": []map[string]interface{}{ { - "name": multiarchComponentName, + "name": multiarchComponentName, "repository": "quay.io/redhat-pending/rhtap----konflux-release-e2e", - "tags": []string{"latest"}, + "tags": []string{"latest"}, "source": map[string]interface{}{ "git": map[string]interface{}{ "url": multiarchGitSourceURL, @@ -319,8 +318,9 @@ func createMultiArchReleasePlanAdmission(multiarchRPAName string, managedFw fram Expect(err).NotTo(HaveOccurred()) } -// preparePR function is to prepare a merged PR for triggerng a push event -func preparePR(devFw *framework.Framework, testBaseBranchName, testPRBranchName string) (int) { +// preparePR function is to prepare a merged PR for triggerng a push event +func preparePR(devFw *framework.Framework, testBaseBranchName, testPRBranchName string) int { + var err error //Create the ref, update the file, create the PR and merge the PR err = devFw.AsKubeAdmin.CommonController.Github.CreateRef(multiarchGitSourceRepoName, multiarchGitSrcDefaultBranch, multiarchGitSrcDefaultSHA, testBaseBranchName) Expect(err).ShouldNot(HaveOccurred()) @@ -328,16 +328,16 @@ func preparePR(devFw *framework.Framework, testBaseBranchName, testPRBranchName err = devFw.AsKubeAdmin.CommonController.Github.CreateRef(multiarchGitSourceRepoName, multiarchGitSrcDefaultBranch, multiarchGitSrcDefaultSHA, testPRBranchName) Expect(err).ShouldNot(HaveOccurred()) - // Update the pac configuration for "push" event + // Update the pac configuration for "push" event fileName := "multi-platform-test-prod-push.yaml" - fileResponse, err := devFw.AsKubeAdmin.CommonController.Github.GetFile(multiarchGitSourceRepoName, ".tekton/" + fileName, testPRBranchName) + fileResponse, err := devFw.AsKubeAdmin.CommonController.Github.GetFile(multiarchGitSourceRepoName, ".tekton/"+fileName, testPRBranchName) Expect(err).ShouldNot(HaveOccurred()) fileContent, err := fileResponse.GetContent() Expect(err).ShouldNot(HaveOccurred()) - fileContent = strings.ReplaceAll(fileContent, "[main]", "[" + testBaseBranchName + "]") - repoContentResponse, err := devFw.AsKubeAdmin.CommonController.Github.UpdateFile(multiarchGitSourceRepoName, ".tekton/" + fileName, fileContent, testPRBranchName, *fileResponse.SHA) + fileContent = strings.ReplaceAll(fileContent, "[main]", "["+testBaseBranchName+"]") + repoContentResponse, err := devFw.AsKubeAdmin.CommonController.Github.UpdateFile(multiarchGitSourceRepoName, ".tekton/"+fileName, fileContent, testPRBranchName, *fileResponse.SHA) Expect(err).ShouldNot(HaveOccurred()) pr, err := devFw.AsKubeAdmin.CommonController.Github.CreatePullRequest(multiarchGitSourceRepoName, "update pac configuration title", "update pac configuration body", testPRBranchName, testBaseBranchName) diff --git a/tests/release/pipelines/push_to_external_registry.go b/tests/release/pipelines/push_to_external_registry.go index 9e9fa82aec..79a3b4939c 100644 --- a/tests/release/pipelines/push_to_external_registry.go +++ b/tests/release/pipelines/push_to_external_registry.go @@ -28,7 +28,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("Push to external registry", Lab var fw *framework.Framework AfterEach(framework.ReportFailure(&fw)) var err error - var devNamespace, managedNamespace string + var devNamespace, managedNamespace, baseBranchName, pacBranchName string var component *appservice.Component var releaseCR *releaseApi.Release @@ -72,7 +72,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("Push to external registry", Lab _, err = fw.AsKubeAdmin.HasController.CreateApplication(releasecommon.ApplicationNameDefault, devNamespace) Expect(err).NotTo(HaveOccurred()) - component = releasecommon.CreateComponent(*fw, devNamespace, releasecommon.ApplicationNameDefault, releasecommon.ComponentName, releasecommon.GitSourceComponentUrl, "", ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*fw, devNamespace, releasecommon.ApplicationNameDefault, releasecommon.ComponentName, releasecommon.DcMetroMapGitSourceURL, releasecommon.DcMetroMapGitRevision, ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) _, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlan(releasecommon.SourceReleasePlanName, devNamespace, releasecommon.ApplicationNameDefault, managedNamespace, "", nil, nil) Expect(err).NotTo(HaveOccurred()) @@ -128,6 +128,18 @@ var _ = framework.ReleasePipelinesSuiteDescribe("Push to external registry", Lab Expect(fw.AsKubeAdmin.CommonController.DeleteNamespace(managedNamespace)).NotTo(HaveOccurred()) Expect(fw.SandboxController.DeleteUserSignup(fw.UserName)).To(BeTrue()) } + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(fw, releasecommon.DcMetroMapGitRepoName) }) var _ = Describe("Post-release verification", func() { diff --git a/tests/release/pipelines/release_to_github.go b/tests/release/pipelines/release_to_github.go index 2915ea7ba7..1cb9e74955 100644 --- a/tests/release/pipelines/release_to_github.go +++ b/tests/release/pipelines/release_to_github.go @@ -29,9 +29,10 @@ import ( const ( sampServiceAccountName = "release-service-account" - sampSourceGitURL = "https://github.com/redhat-appstudio-qe/devfile-sample-go-basic" + sampSourceGitURL = "https://github.com/redhat-appstudio-qe/devfile-sample-go-basic-release" + sampGitRevision = "508445a786e84c01e84c8c46d9d2407642d02762" sampRepoOwner = "redhat-appstudio-qe" - sampRepo = "devfile-sample-go-basic" + sampRepo = "devfile-sample-go-basic-release" sampCatalogPathInRepo = "pipelines/release-to-github/release-to-github.yaml" ) @@ -58,6 +59,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for release-to-github var releasePR, buildPR *tektonv1.PipelineRun var gh *github.Github var sampReleaseURL string + var baseBranchName, pacBranchName string AfterEach(framework.ReportFailure(&devFw)) @@ -106,7 +108,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for release-to-github createGHReleasePlanAdmission(sampReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, sampApplicationName, sampEnterpriseContractPolicyName, sampCatalogPathInRepo, "false", "", "", "", "") - component = releasecommon.CreateComponent(*devFw, devNamespace, sampApplicationName, sampComponentName, sampSourceGitURL, "", ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*devFw, devNamespace, sampApplicationName, sampComponentName, sampSourceGitURL, sampGitRevision, ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) createGHEnterpriseContractPolicy(sampEnterpriseContractPolicyName, *managedFw, devNamespace, managedNamespace) }) @@ -121,6 +123,19 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for release-to-github if gh.CheckIfReleaseExist(sampRepoOwner, sampRepo, sampReleaseURL) { gh.DeleteRelease(sampRepoOwner, sampRepo, sampReleaseURL) } + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(sampRepo, pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(sampRepo, baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(devFw, sampRepo) + }) var _ = Describe("Post-release verification", func() { diff --git a/tests/release/pipelines/rh_advisories.go b/tests/release/pipelines/rh_advisories.go index a123868094..8f15fabe86 100644 --- a/tests/release/pipelines/rh_advisories.go +++ b/tests/release/pipelines/rh_advisories.go @@ -56,6 +56,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-advisories pip var snapshot *appservice.Snapshot var releaseCR *releaseapi.Release var releasePR, buildPR *tektonv1.PipelineRun + var baseBranchName, pacBranchName string AfterEach(framework.ReportFailure(&devFw)) @@ -103,7 +104,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-advisories pip createADVSReleasePlan(advsReleasePlanName, *devFw, devNamespace, advsApplicationName, managedNamespace, "true") - component = releasecommon.CreateComponent(*devFw, devNamespace, advsApplicationName, advsComponentName, releasecommon.AdditionalGitSourceComponentUrl, "", ".", constants.DockerFilePath, constants.DefaultDockerBuildPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*devFw, devNamespace, advsApplicationName, advsComponentName, releasecommon.AdditionalGitSourceComponentUrl, releasecommon.AdditionalGitRevision, ".", constants.DockerFilePath, constants.DefaultDockerBuildPipelineBundle) createADVSReleasePlanAdmission(advsReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, advsApplicationName, advsEnterpriseContractPolicyName, advsCatalogPathInRepo) @@ -116,6 +117,17 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-advisories pip Expect(devFw.AsKubeDeveloper.HasController.DeleteApplication(advsApplicationName, devNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(advsEnterpriseContractPolicyName, managedNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(advsReleasePlanAdmissionName, managedNamespace, false)).NotTo(HaveOccurred()) + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(devFw, utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl)) }) var _ = Describe("Post-release verification", func() { diff --git a/tests/release/pipelines/rh_push_to_external_registry.go b/tests/release/pipelines/rh_push_to_external_registry.go index 3722d60913..1061b500e3 100644 --- a/tests/release/pipelines/rh_push_to_external_registry.go +++ b/tests/release/pipelines/rh_push_to_external_registry.go @@ -47,6 +47,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu var releaseCR1, releaseCR2 *releaseApi.Release var componentObj1, componentObj2 appservice.ComponentSpec + var baseBranchNameComp1, pacBranchNameComp1, baseBranchNameComp2, pacBranchNameComp2 string BeforeAll(func() { fw, err = framework.NewFramework(utils.GetGeneratedNamespace("push-pyxis")) @@ -118,13 +119,26 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu compName = releasecommon.ComponentName additionalCompName = releasecommon.AdditionalComponentName + pacBranchNameComp1 = constants.PaCPullRequestBranchPrefix + compName + pacBranchNameComp2 = constants.PaCPullRequestBranchPrefix + additionalCompName + + baseBranchNameComp1 = fmt.Sprintf("base-%s", util.GenerateRandomString(6)) + baseBranchNameComp2 = fmt.Sprintf("base-%s", util.GenerateRandomString(6)) + + err = devFw.AsKubeAdmin.CommonController.Github.CreateRef(releasecommon.DcMetroMapGitRepoName, "main", releasecommon.DcMetroMapGitRevision, baseBranchNameComp1) + Expect(err).ShouldNot(HaveOccurred()) + + err = devFw.AsKubeAdmin.CommonController.Github.CreateRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), "main", releasecommon.AdditionalGitRevision, baseBranchNameComp2) + Expect(err).ShouldNot(HaveOccurred()) + componentObj1 = appservice.ComponentSpec{ ComponentName: releasecommon.ComponentName, Application: releasecommon.ApplicationNameDefault, Source: appservice.ComponentSource{ ComponentSourceUnion: appservice.ComponentSourceUnion{ GitSource: &appservice.GitSource{ - URL: releasecommon.GitSourceComponentUrl, + URL: releasecommon.DcMetroMapGitSourceURL, + Revision: baseBranchNameComp1, }, }, }, @@ -136,6 +150,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu ComponentSourceUnion: appservice.ComponentSourceUnion{ GitSource: &appservice.GitSource{ URL: releasecommon.AdditionalGitSourceComponentUrl, + Revision: baseBranchNameComp2, DockerfileURL: constants.DockerFilePath, }, }, @@ -210,19 +225,41 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu Expect(fw.AsKubeAdmin.CommonController.DeleteNamespace(managedNamespace)).NotTo(HaveOccurred()) Expect(fw.SandboxController.DeleteUserSignup(fw.UserName)).To(BeTrue()) } + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, pacBranchNameComp1) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, baseBranchNameComp1) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), pacBranchNameComp2) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), baseBranchNameComp2) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(fw, releasecommon.DcMetroMapGitRepoName) + releasecommon.CleanupWebhooks(fw, utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl)) + }) var _ = Describe("Post-release verification", func() { It("verifies that Component 1 can be created and build PipelineRun is created for it in dev namespace and succeeds", func() { - component1, err = fw.AsKubeAdmin.HasController.CreateComponent(componentObj1, devNamespace, "", "", releasecommon.ApplicationNameDefault, true, constants.DefaultDockerBuildPipelineBundle) + component1, err = fw.AsKubeAdmin.HasController.CreateComponent(componentObj1, devNamespace, "", "", releasecommon.ApplicationNameDefault, true, utils.MergeMaps(constants.ComponentPaCRequestAnnotation, constants.DefaultDockerBuildPipelineBundle)) Expect(err).NotTo(HaveOccurred()) Expect(fw.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(component1, "", fw.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 2, Always: true}, nil)).To(Succeed()) }) It("verifies that Component 2 can be created and build PipelineRun is created for it in dev namespace and succeeds", func() { - component2, err = fw.AsKubeAdmin.HasController.CreateComponent(componentObj2, devNamespace, "", "", releasecommon.ApplicationNameDefault, true, constants.DefaultDockerBuildPipelineBundle) + component2, err = fw.AsKubeAdmin.HasController.CreateComponent(componentObj2, devNamespace, "", "", releasecommon.ApplicationNameDefault, true, utils.MergeMaps(constants.ComponentPaCRequestAnnotation, constants.DefaultDockerBuildPipelineBundle)) Expect(err).NotTo(HaveOccurred()) Expect(fw.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(component2, "", fw.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 2, Always: true}, nil)).To(Succeed()) diff --git a/tests/release/pipelines/rh_push_to_redhat_io.go b/tests/release/pipelines/rh_push_to_redhat_io.go index c5c6b38e11..c2ce098f0f 100644 --- a/tests/release/pipelines/rh_push_to_redhat_io.go +++ b/tests/release/pipelines/rh_push_to_redhat_io.go @@ -57,6 +57,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-push-to-redhat var snapshot *appservice.Snapshot var releaseCR *releaseapi.Release var releasePR, buildPR *tektonv1.PipelineRun + var baseBranchName, pacBranchName string AfterEach(framework.ReportFailure(&devFw)) @@ -106,7 +107,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-push-to-redhat _, err = devFw.AsKubeDeveloper.ReleaseController.CreateReleasePlan(rhioReleasePlanName, devNamespace, rhioApplicationName, managedNamespace, "true", nil, nil) Expect(err).NotTo(HaveOccurred()) - testComponent = releasecommon.CreateComponent(*devFw, devNamespace, rhioApplicationName, rhioComponentName, releasecommon.AdditionalGitSourceComponentUrl, "", ".", constants.DockerFilePath, constants.DefaultDockerBuildPipelineBundle) + testComponent, baseBranchName, pacBranchName = releasecommon.CreateComponent(*devFw, devNamespace, rhioApplicationName, rhioComponentName, releasecommon.AdditionalGitSourceComponentUrl, releasecommon.AdditionalGitRevision, ".", constants.DockerFilePath, constants.DefaultDockerBuildPipelineBundle) createRHIOReleasePlanAdmission(rhioReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, rhioApplicationName, rhioEnterpriseContractPolicyName, rhioCatalogPathInRepo) @@ -119,6 +120,18 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rh-push-to-redhat Expect(devFw.AsKubeDeveloper.HasController.DeleteApplication(rhioApplicationName, devNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(rhioEnterpriseContractPolicyName, managedNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(rhioReleasePlanAdmissionName, managedNamespace, false)).NotTo(HaveOccurred()) + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl), baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(devFw, utils.GetRepoName(releasecommon.AdditionalGitSourceComponentUrl)) }) var _ = Describe("Post-release verification", func() { diff --git a/tests/release/pipelines/rhtap_service_push.go b/tests/release/pipelines/rhtap_service_push.go index 074dfb0000..53da58a668 100644 --- a/tests/release/pipelines/rhtap_service_push.go +++ b/tests/release/pipelines/rhtap_service_push.go @@ -5,16 +5,16 @@ import ( "encoding/json" "fmt" "os" - "time" "strings" + "time" "github.com/devfile/library/v2/pkg/util" ecp "github.com/enterprise-contract/enterprise-contract-controller/api/v1alpha1" appservice "github.com/konflux-ci/application-api/api/v1alpha1" appstudioApi "github.com/konflux-ci/application-api/api/v1alpha1" + "github.com/konflux-ci/e2e-tests/pkg/clients/github" "github.com/konflux-ci/e2e-tests/pkg/constants" "github.com/konflux-ci/e2e-tests/pkg/framework" - "github.com/konflux-ci/e2e-tests/pkg/clients/github" "github.com/konflux-ci/e2e-tests/pkg/utils" "github.com/konflux-ci/e2e-tests/pkg/utils/tekton" releasecommon "github.com/konflux-ci/e2e-tests/tests/release" @@ -70,6 +70,8 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rhtap-service-pus var releaseCR *releaseapi.Release var buildPR *tektonv1.PipelineRun + var baseBranchName, pacBranchName string + AfterEach(framework.ReportFailure(&devFw)) Describe("Rhtap-service-push happy path", Label("RhtapServicePush"), func() { @@ -124,22 +126,28 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rhtap-service-pus _, err = devFw.AsKubeDeveloper.ReleaseController.CreateReleasePlan(rhtapReleasePlanName, devNamespace, rhtapApplicationName, managedNamespace, "true", nil, nil) Expect(err).NotTo(HaveOccurred()) + pacBranchName = constants.PaCPullRequestBranchPrefix + rhtapComponentName + baseBranchName = fmt.Sprintf("base-%s", util.GenerateRandomString(6)) + + err = devFw.AsKubeAdmin.CommonController.Github.CreateRef(rhtapGitSourceRepoName, rhtapGitSrcDefaultBranch, rhtapGitSrcDefaultSHA, baseBranchName) + Expect(err).ShouldNot(HaveOccurred()) + componentObj := appstudioApi.ComponentSpec{ ComponentName: rhtapComponentName, Application: rhtapApplicationName, Source: appstudioApi.ComponentSource{ ComponentSourceUnion: appstudioApi.ComponentSourceUnion{ GitSource: &appstudioApi.GitSource{ - URL: rhtapGitSourceURL, - Revision: testBaseBranchName, - Context: ".", + URL: rhtapGitSourceURL, + Revision: baseBranchName, + Context: ".", DockerfileURL: constants.DockerFilePath, }, }, }, } // Create a component with Git Source URL, a specified git branch - rhtapComponent, err = devFw.AsKubeAdmin.HasController.CreateComponent(componentObj, devNamespace, "", "", rhtapApplicationName, false, constants.DefaultDockerBuildPipelineBundle) + rhtapComponent, err = devFw.AsKubeAdmin.HasController.CreateComponent(componentObj, devNamespace, "", "", rhtapApplicationName, false, utils.MergeMaps(constants.ComponentPaCRequestAnnotation, constants.DefaultDockerBuildPipelineBundle)) Expect(err).ShouldNot(HaveOccurred()) createRHTAPReleasePlanAdmission(rhtapReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, rhtapApplicationName, rhtapEnterpriseContractPolicyName, rhtapCatalogPathInRepo) @@ -153,6 +161,18 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rhtap-service-pus Expect(devFw.AsKubeDeveloper.HasController.DeleteApplication(rhtapApplicationName, devNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(rhtapEnterpriseContractPolicyName, managedNamespace, false)).NotTo(HaveOccurred()) Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(rhtapReleasePlanAdmissionName, managedNamespace, false)).NotTo(HaveOccurred()) + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(rhtapGitSourceRepoName, pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(rhtapGitSourceRepoName, baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(devFw, rhtapGitSourceRepoName) }) var _ = Describe("Post-release verification", func() { @@ -237,7 +257,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for rhtap-service-pus body := pr.Body GinkgoWriter.Printf("Body of PR #%d: %s \n", pr.GetNumber(), *body) - prLink := fmt.Sprintf(rhtapGitSourceURL + "/pull/%d", sourcePrNum) + prLink := fmt.Sprintf(rhtapGitSourceURL+"/pull/%d", sourcePrNum) GinkgoWriter.Printf("The source PR link: %s", prLink) if strings.Contains(*body, prLink) { GinkgoWriter.Printf("The source PR#%d is added to the PR of infra-deployments", sourcePrNum) @@ -295,9 +315,9 @@ func createRHTAPReleasePlanAdmission(rhtapRPAName string, managedFw framework.Fr "server": "stage", "secret": "pyxis", }, - "targetGHRepo": "hacbs-release/infra-deployments", - "githubAppID": "932323", - "githubAppInstallationID": "52284535", + "targetGHRepo": "hacbs-release/infra-deployments", + "githubAppID": "932323", + "githubAppInstallationID": "52284535", "infra-deployment-update-script": "sed -i -e 's|\\(https://github.com/hacbs-release/release-service/config/default?ref=\\)\\(.*\\)|\\1{{ revision }}|' -e 's/\\(newTag: \\).*/\\1{{ revision }}/' components/release/development/kustomization.yaml", "sign": map[string]interface{}{ "configMapName": "hacbs-signing-pipeline-config-redhatbeta2", @@ -321,6 +341,7 @@ func createRHTAPReleasePlanAdmission(rhtapRPAName string, managedFw framework.Fr // prepareMergedPR function is to prepare a merged PR in source repo for testing update-infra-deployments task func prepareMergedPR(devFw *framework.Framework, testBaseBranchName, testPRBranchName string) (int, string) { //Create the ref, add the file, create the PR and merge the PR + var err error err = devFw.AsKubeAdmin.CommonController.Github.CreateRef(rhtapGitSourceRepoName, rhtapGitSrcDefaultBranch, rhtapGitSrcDefaultSHA, testBaseBranchName) Expect(err).ShouldNot(HaveOccurred()) @@ -348,4 +369,3 @@ func prepareMergedPR(devFw *framework.Framework, testBaseBranchName, testPRBranc return pr.GetNumber(), mergeResultSha } - diff --git a/tests/release/pipelines/tenant_pipelines.go b/tests/release/pipelines/tenant_pipelines.go index 47dbc836ac..e4778719c7 100644 --- a/tests/release/pipelines/tenant_pipelines.go +++ b/tests/release/pipelines/tenant_pipelines.go @@ -8,18 +8,18 @@ import ( tektonutils "github.com/konflux-ci/release-service/tekton/utils" "k8s.io/apimachinery/pkg/runtime" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" appservice "github.com/konflux-ci/application-api/api/v1alpha1" "github.com/konflux-ci/e2e-tests/pkg/clients/has" "github.com/konflux-ci/e2e-tests/pkg/constants" "github.com/konflux-ci/e2e-tests/pkg/framework" "github.com/konflux-ci/e2e-tests/pkg/utils" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" releasecommon "github.com/konflux-ci/e2e-tests/tests/release" releaseApi "github.com/konflux-ci/release-service/api/v1alpha1" - corev1 "k8s.io/api/core/v1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var _ = framework.ReleaseServiceSuiteDescribe("Release service tenant pipeline", Label("release-pipelines", "tenant"), func() { @@ -34,6 +34,7 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service tenant pipeline", var component *appservice.Component var releaseCR *releaseApi.Release + var baseBranchName, pacBranchName string BeforeAll(func() { // Initialize the tests controllers @@ -51,7 +52,7 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service tenant pipeline", _, err = fw.AsKubeAdmin.HasController.CreateApplication(releasecommon.ApplicationNameDefault, devNamespace) Expect(err).NotTo(HaveOccurred()) - component = releasecommon.CreateComponent(*fw, devNamespace, releasecommon.ApplicationNameDefault, releasecommon.ComponentName, releasecommon.GitSourceComponentUrl, "", ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*fw, devNamespace, releasecommon.ApplicationNameDefault, releasecommon.ComponentName, releasecommon.DcMetroMapGitSourceURL, releasecommon.DcMetroMapGitRevision, ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) data, err := json.Marshal(map[string]interface{}{ "mapping": map[string]interface{}{ @@ -68,8 +69,8 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service tenant pipeline", tenantPipeline := &tektonutils.ParameterizedPipeline{} tenantPipeline.ServiceAccountName = constants.DefaultPipelineServiceAccount tenantPipeline.Timeouts = tektonv1.TimeoutFields{ - Pipeline: &metav1.Duration{Duration: 1 * time.Hour}, - } + Pipeline: &metav1.Duration{Duration: 1 * time.Hour}, + } tenantPipeline.PipelineRef = tektonutils.PipelineRef{ Resolver: "git", @@ -81,8 +82,8 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service tenant pipeline", } _, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlan(releasecommon.SourceReleasePlanName, devNamespace, releasecommon.ApplicationNameDefault, "", "", &runtime.RawExtension{ - Raw: data, - }, tenantPipeline) + Raw: data, + }, tenantPipeline) Expect(err).NotTo(HaveOccurred()) _, err = fw.AsKubeAdmin.TektonController.CreatePVCInAccessMode(releasecommon.ReleasePvcName, devNamespace, corev1.ReadWriteOnce) @@ -93,6 +94,18 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service tenant pipeline", if !CurrentSpecReport().Failed() { Expect(fw.SandboxController.DeleteUserSignup(fw.UserName)).To(BeTrue()) } + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = devFw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(devFw, releasecommon.DcMetroMapGitRepoName) }) var _ = Describe("Post-release verification", func() { diff --git a/tests/release/releaseLib.go b/tests/release/releaseLib.go index b5eb0833e3..293c6d8a1f 100644 --- a/tests/release/releaseLib.go +++ b/tests/release/releaseLib.go @@ -1,13 +1,17 @@ package common import ( + "fmt" "os" + "strings" "time" + "github.com/devfile/library/v2/pkg/util" appservice "github.com/konflux-ci/application-api/api/v1alpha1" "github.com/konflux-ci/e2e-tests/pkg/constants" "github.com/konflux-ci/e2e-tests/pkg/framework" "github.com/konflux-ci/e2e-tests/pkg/utils" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -26,7 +30,13 @@ func NewFramework(workspace string) *framework.Framework { return fw } -func CreateComponent(devFw framework.Framework, devNamespace, appName, compName, gitURL, gitRevision, contextDir, dockerFilePath string, buildPipelineBundle map[string]string) *appservice.Component { +func CreateComponent(devFw framework.Framework, devNamespace, appName, compName, gitURL, gitRevision, contextDir, dockerFilePath string, buildPipelineBundle map[string]string) (component *appservice.Component, baseBranchName, pacBranchName string) { + pacBranchName = constants.PaCPullRequestBranchPrefix + compName + baseBranchName = fmt.Sprintf("base-%s", util.GenerateRandomString(6)) + + err := devFw.AsKubeAdmin.CommonController.Github.CreateRef(utils.GetRepoName(gitURL), "main", gitRevision, baseBranchName) + Expect(err).ShouldNot(HaveOccurred()) + componentObj := appservice.ComponentSpec{ ComponentName: compName, Application: appName, @@ -34,14 +44,27 @@ func CreateComponent(devFw framework.Framework, devNamespace, appName, compName, ComponentSourceUnion: appservice.ComponentSourceUnion{ GitSource: &appservice.GitSource{ URL: gitURL, - Revision: gitRevision, + Revision: baseBranchName, Context: contextDir, DockerfileURL: dockerFilePath, }, }, }, } - component, err := devFw.AsKubeAdmin.HasController.CreateComponent(componentObj, devNamespace, "", "", appName, false, buildPipelineBundle) + component, err = devFw.AsKubeAdmin.HasController.CreateComponent(componentObj, devNamespace, "", "", appName, false, utils.MergeMaps(constants.ComponentPaCRequestAnnotation, buildPipelineBundle)) + Expect(err).NotTo(HaveOccurred()) + return +} + +func CleanupWebhooks(f *framework.Framework, repoName string) { + hooks, err := f.AsKubeAdmin.CommonController.Github.ListRepoWebhooks(repoName) Expect(err).NotTo(HaveOccurred()) - return component + for _, h := range hooks { + hookUrl := h.Config["url"].(string) + if strings.Contains(hookUrl, f.ClusterAppDomain) { + GinkgoWriter.Printf("removing webhook URL: %s\n", hookUrl) + Expect(f.AsKubeAdmin.CommonController.Github.DeleteWebhook(repoName, h.GetID())).To(Succeed()) + break + } + } } diff --git a/tests/release/service/happy_path.go b/tests/release/service/happy_path.go index 44efbe42ac..011e82525e 100644 --- a/tests/release/service/happy_path.go +++ b/tests/release/service/happy_path.go @@ -29,7 +29,7 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service happy path", Labe AfterEach(framework.ReportFailure(&fw)) var err error var compName string - var devNamespace, managedNamespace string + var devNamespace, managedNamespace, baseBranchName, pacBranchName string var verifyEnterpriseContractTaskName = "verify-enterprise-contract" var releasedImagePushRepo = "quay.io/redhat-appstudio-qe/dcmetromap" @@ -75,7 +75,7 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service happy path", Labe _, err = fw.AsKubeAdmin.HasController.CreateApplication(releasecommon.ApplicationNameDefault, devNamespace) Expect(err).NotTo(HaveOccurred()) - component = releasecommon.CreateComponent(*fw, devNamespace, releasecommon.ApplicationNameDefault, releasecommon.ComponentName, releasecommon.GitSourceComponentUrl, "", ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) + component, baseBranchName, pacBranchName = releasecommon.CreateComponent(*fw, devNamespace, releasecommon.ApplicationNameDefault, releasecommon.ComponentName, releasecommon.DcMetroMapGitSourceURL, releasecommon.DcMetroMapGitRevision, ".", "Dockerfile", constants.DefaultDockerBuildPipelineBundle) _, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlan(releasecommon.SourceReleasePlanName, devNamespace, releasecommon.ApplicationNameDefault, managedNamespace, "", nil, nil) Expect(err).NotTo(HaveOccurred()) @@ -126,6 +126,17 @@ var _ = framework.ReleaseServiceSuiteDescribe("Release service happy path", Labe Expect(fw.AsKubeAdmin.CommonController.DeleteNamespace(managedNamespace)).NotTo(HaveOccurred()) Expect(fw.SandboxController.DeleteUserSignup(fw.UserName)).To(BeTrue()) } + // Delete new branches created by PaC and a testing branch used as a component's base branch + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, pacBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + err = fw.AsKubeAdmin.CommonController.Github.DeleteRef(releasecommon.DcMetroMapGitRepoName, baseBranchName) + if err != nil { + Expect(err.Error()).To(ContainSubstring("Reference does not exist")) + } + // Delete created webhook from GitHub + releasecommon.CleanupWebhooks(fw, releasecommon.DcMetroMapGitRepoName) }) var _ = Describe("Post-release verification", func() {