From 1bb7f527407c8f7850813f5c07a7bc3ac1039fb4 Mon Sep 17 00:00:00 2001 From: Jing Qi Date: Sat, 2 Nov 2024 11:29:57 +0800 Subject: [PATCH] fix: clean RP and RPA in multiarch-advisories Signed-off-by: Jing Qi --- .../release/pipelines/multiarch_advisories.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/release/pipelines/multiarch_advisories.go b/tests/release/pipelines/multiarch_advisories.go index efe814b973..fe40eedff7 100644 --- a/tests/release/pipelines/multiarch_advisories.go +++ b/tests/release/pipelines/multiarch_advisories.go @@ -114,19 +114,23 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for multi arch test f Expect(err).NotTo(HaveOccurred()) _, err = devFw.AsKubeDeveloper.ReleaseController.GetReleasePlan(multiarchReleasePlanName, devNamespace) - if errors.IsNotFound(err) { - createMultiArchReleasePlan(multiarchReleasePlanName, *devFw, devNamespace, multiarchApplicationName, managedNamespace, "true") + if err == nil { + Expect(devFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlan(multiarchReleasePlanName, devNamespace, false)).NotTo(HaveOccurred()) } + createMultiArchReleasePlan(multiarchReleasePlanName, *devFw, devNamespace, multiarchApplicationName, managedNamespace, "true") _, err = managedFw.AsKubeAdmin.ReleaseController.GetReleasePlanAdmission(multiarchReleasePlanAdmissionName, managedNamespace) - if errors.IsNotFound(err) { - createMultiArchReleasePlanAdmission(multiarchReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, multiarchApplicationName, multiarchEnterpriseContractPolicyName, multiarchCatalogPathInRepo) + if err == nil { + Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(multiarchReleasePlanAdmissionName, managedNamespace, false)).NotTo(HaveOccurred()) } + createMultiArchReleasePlanAdmission(multiarchReleasePlanAdmissionName, *managedFw, devNamespace, managedNamespace, multiarchApplicationName, multiarchEnterpriseContractPolicyName, multiarchCatalogPathInRepo) _, err = managedFw.AsKubeDeveloper.TektonController.GetEnterpriseContractPolicy(multiarchEnterpriseContractPolicyName, managedNamespace) - if errors.IsNotFound(err) { - createMultiArchEnterpriseContractPolicy(multiarchEnterpriseContractPolicyName, *managedFw, devNamespace, managedNamespace) + if err == nil { + err = managedFw.AsKubeDeveloper.TektonController.DeleteEnterpriseContractPolicy(multiarchEnterpriseContractPolicyName, managedNamespace, false) + Expect(err).ShouldNot(HaveOccurred()) } + createMultiArchEnterpriseContractPolicy(multiarchEnterpriseContractPolicyName, *managedFw, devNamespace, managedNamespace) snapshotPush, err = releasecommon.CreateSnapshotWithImageSource(*devFw, multiarchComponentName, multiarchApplicationName, devNamespace, sampleImage, multiarchGitSourceURL, multiarchGitSrcSHA, "", "", "", "") Expect(err).ShouldNot(HaveOccurred()) @@ -141,6 +145,9 @@ var _ = framework.ReleasePipelinesSuiteDescribe("e2e tests for multi arch test f if err = devFw.AsKubeDeveloper.ReleaseController.StoreRelease(releaseCR); err != nil { GinkgoWriter.Printf("failed to store Release %s:%s: %s\n", releaseCR.GetNamespace(), releaseCR.GetName(), err.Error()) } + // clean RP and RPA since they may be changed according to new source code change + Expect(devFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlan(multiarchReleasePlanName, devNamespace, false)).NotTo(HaveOccurred()) + Expect(managedFw.AsKubeDeveloper.ReleaseController.DeleteReleasePlanAdmission(multiarchReleasePlanAdmissionName, managedNamespace, false)).NotTo(HaveOccurred()) }) var _ = Describe("Post-release verification", func() {