Skip to content

Commit

Permalink
refactor: consistently call release-service imports (#1055)
Browse files Browse the repository at this point in the history
The release-service libraries in the e2e-tests repo was called
releasecommon in some places and releaseConst in others. This commit
changes it to be releasecommon everywhere. Also, this commit updates
some lingering ReleasePlanAdmissions that were using hardcoded values
for the release-service-catalog instead of the variables.

Signed-off-by: Johnny Bieren <[email protected]>
  • Loading branch information
johnbieren authored Feb 26, 2024
1 parent 21db9eb commit a844926
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 99 deletions.
5 changes: 3 additions & 2 deletions tests/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
buildservice "github.com/redhat-appstudio/build-service/api/v1alpha1"
"github.com/redhat-appstudio/build-service/controllers"
"github.com/redhat-appstudio/e2e-tests/pkg/framework"
releasecommon "github.com/redhat-appstudio/e2e-tests/tests/release"
imagecontollers "github.com/redhat-appstudio/image-controller/controllers"
v1 "k8s.io/api/core/v1"
)
Expand Down Expand Up @@ -1477,8 +1478,8 @@ var _ = framework.BuildSuiteDescribe("Build service E2E tests", Label("build", "
_, err = f.AsKubeAdmin.ReleaseController.CreateReleasePlanAdmission("demo", managedNamespace, "", f.UserNamespace, "demo", constants.DefaultPipelineServiceAccount, []string{applicationName}, false, &tektonutils.PipelineRef{
Resolver: "git",
Params: []tektonutils.Param{
{Name: "url", Value: "https://github.com/redhat-appstudio/release-service-catalog"},
{Name: "revision", Value: "main"},
{Name: "url", Value: releasecommon.RelSvcCatalogURL},
{Name: "revision", Value: releasecommon.RelSvcCatalogRevision},
{Name: "pathInRepo", Value: "pipelines/e2e/e2e.yaml"},
}}, &runtime.RawExtension{Raw: rawData})
Expect(err).NotTo(HaveOccurred())
Expand Down
8 changes: 4 additions & 4 deletions tests/release/pipelines/push_to_external_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("Push to external registry", Lab
"mapping": map[string]interface{}{
"components": []map[string]interface{}{
{
"name": component.GetName(),
"name": component.GetName(),
"repository": releasecommon.ReleasedImagePushRepo,
},
},
Expand Down Expand Up @@ -168,15 +168,15 @@ var _ = framework.ReleasePipelinesSuiteDescribe("Push to external registry", Lab
})

It("tests if the image was pushed to quay", func() {
//retrieve the component to get the latest data
//retrieve the component to get the latest data
component, err := fw.AsKubeAdmin.HasController.GetComponent(component.GetName(), devNamespace)
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("could not get component %s in the %s namespace", component.GetName(), devNamespace))
containerImageDigest := strings.Split(component.Spec.ContainerImage, "@")[1]

imageDigest, err := releasecommon.GetDigestWithTagInQuay(releasecommon.ReleasedImagePushRepo + ":latest")
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed while getting Digest for quay image %s with error: %+v", releasecommon.ReleasedImagePushRepo + ":latest", err))
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed while getting Digest for quay image %s with error: %+v", releasecommon.ReleasedImagePushRepo+":latest", err))
Expect(imageDigest).To(Equal(containerImageDigest))
})
})

It("verifies that a Release is marked as succeeded.", func() {
Eventually(func() error {
Expand Down
54 changes: 27 additions & 27 deletions tests/release/pipelines/rh_push_to_external_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/redhat-appstudio/e2e-tests/pkg/utils"
"github.com/redhat-appstudio/e2e-tests/pkg/utils/contract"
"github.com/redhat-appstudio/e2e-tests/pkg/utils/tekton"
releaseConst "github.com/redhat-appstudio/e2e-tests/tests/release"
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"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
Expand Down Expand Up @@ -69,11 +69,11 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
Expect(certPyxisStage).ToNot(BeEmpty())

// Create secret for the release registry repo "hacbs-release-tests".
_, err = fw.AsKubeAdmin.CommonController.CreateRegistryAuthSecret(releaseConst.RedhatAppstudioUserSecret, managedNamespace, sourceAuthJson)
_, err = fw.AsKubeAdmin.CommonController.CreateRegistryAuthSecret(releasecommon.RedhatAppstudioUserSecret, managedNamespace, sourceAuthJson)
Expect(err).ToNot(HaveOccurred())

// Linking the build secret to the pipeline service account in dev namespace.
err = fw.AsKubeAdmin.CommonController.LinkSecretToServiceAccount(devNamespace, releaseConst.HacbsReleaseTestsTokenSecret, constants.DefaultPipelineServiceAccount, true)
err = fw.AsKubeAdmin.CommonController.LinkSecretToServiceAccount(devNamespace, releasecommon.HacbsReleaseTestsTokenSecret, constants.DefaultPipelineServiceAccount, true)
Expect(err).ToNot(HaveOccurred())

publicKey, err := fw.AsKubeAdmin.TektonController.GetTektonChainsPublicKey()
Expand Down Expand Up @@ -102,25 +102,25 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
Expect(err).ToNot(HaveOccurred())

Expect(fw.AsKubeAdmin.TektonController.CreateOrUpdateSigningSecret(
publicKey, releaseConst.PublicSecretNameAuth, managedNamespace)).To(Succeed())
publicKey, releasecommon.PublicSecretNameAuth, managedNamespace)).To(Succeed())

defaultECP, err := fw.AsKubeAdmin.TektonController.GetEnterpriseContractPolicy("default", "enterprise-contract-service")
Expect(err).NotTo(HaveOccurred())
policy := contract.PolicySpecWithSourceConfig(defaultECP.Spec, ecp.SourceConfig{Include: []string{"@minimal"}, Exclude: []string{"cve"}})

managedServiceAccount, err := fw.AsKubeAdmin.CommonController.CreateServiceAccount(releaseConst.ReleasePipelineServiceAccountDefault, managedNamespace, releaseConst.ManagednamespaceSecret, nil)
managedServiceAccount, err := fw.AsKubeAdmin.CommonController.CreateServiceAccount(releasecommon.ReleasePipelineServiceAccountDefault, managedNamespace, releasecommon.ManagednamespaceSecret, nil)
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePipelineRoleBindingForServiceAccount(devNamespace, managedServiceAccount)
Expect(err).NotTo(HaveOccurred())
_, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePipelineRoleBindingForServiceAccount(managedNamespace, managedServiceAccount)
Expect(err).NotTo(HaveOccurred())

err = fw.AsKubeAdmin.CommonController.LinkSecretToServiceAccount(managedNamespace, releaseConst.RedhatAppstudioUserSecret, releaseConst.ReleasePipelineServiceAccountDefault, true)
err = fw.AsKubeAdmin.CommonController.LinkSecretToServiceAccount(managedNamespace, releasecommon.RedhatAppstudioUserSecret, releasecommon.ReleasePipelineServiceAccountDefault, true)
Expect(err).ToNot(HaveOccurred())

// using cdq since git ref is not known
cdq, err := fw.AsKubeAdmin.HasController.CreateComponentDetectionQuery(releaseConst.ComponentName, devNamespace, releaseConst.GitSourceComponentUrl, "", "", "", false)
cdq, err := fw.AsKubeAdmin.HasController.CreateComponentDetectionQuery(releasecommon.ComponentName, devNamespace, releasecommon.GitSourceComponentUrl, "", "", "", false)
Expect(err).NotTo(HaveOccurred())
Expect(cdq.Status.ComponentDetected).To(HaveLen(1), "Expected length of the detected Components was not 1")

Expand All @@ -130,8 +130,8 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
}

// using cdq since git ref is not known
additionalCompName = releaseConst.AdditionalComponentName
cdq, err = fw.AsKubeAdmin.HasController.CreateComponentDetectionQuery(additionalCompName, devNamespace, releaseConst.AdditionalGitSourceComponentUrl, "", "", "", false)
additionalCompName = releasecommon.AdditionalComponentName
cdq, err = fw.AsKubeAdmin.HasController.CreateComponentDetectionQuery(additionalCompName, devNamespace, releasecommon.AdditionalGitSourceComponentUrl, "", "", "", false)
Expect(err).NotTo(HaveOccurred())
Expect(cdq.Status.ComponentDetected).To(HaveLen(1), "Expected length of the detected Components was not 1")

Expand All @@ -140,7 +140,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
additionalComponentDetected = compDetected
}

_, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlan(releaseConst.SourceReleasePlanName, devNamespace, releaseConst.ApplicationNameDefault, managedNamespace, "true")
_, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlan(releasecommon.SourceReleasePlanName, devNamespace, releasecommon.ApplicationNameDefault, managedNamespace, "true")
Expect(err).NotTo(HaveOccurred())

data, err := json.Marshal(map[string]interface{}{
Expand All @@ -163,22 +163,22 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
})
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlanAdmission(releaseConst.TargetReleasePlanAdmissionName, managedNamespace, "", devNamespace, releaseConst.ReleaseStrategyPolicyDefault, releaseConst.ReleasePipelineServiceAccountDefault, []string{releaseConst.ApplicationNameDefault}, true, &tektonutils.PipelineRef{
_, err = fw.AsKubeAdmin.ReleaseController.CreateReleasePlanAdmission(releasecommon.TargetReleasePlanAdmissionName, managedNamespace, "", devNamespace, releasecommon.ReleaseStrategyPolicyDefault, releasecommon.ReleasePipelineServiceAccountDefault, []string{releasecommon.ApplicationNameDefault}, true, &tektonutils.PipelineRef{
Resolver: "git",
Params: []tektonutils.Param{
{Name: "url", Value: releaseConst.RelSvcCatalogURL},
{Name: "revision", Value: releaseConst.RelSvcCatalogRevision},
{Name: "url", Value: releasecommon.RelSvcCatalogURL},
{Name: "revision", Value: releasecommon.RelSvcCatalogRevision},
{Name: "pathInRepo", Value: "pipelines/rh-push-to-external-registry/rh-push-to-external-registry.yaml"},
},
}, &runtime.RawExtension{
Raw: data,
})
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.TektonController.CreateEnterpriseContractPolicy(releaseConst.ReleaseStrategyPolicyDefault, managedNamespace, policy)
_, err = fw.AsKubeAdmin.TektonController.CreateEnterpriseContractPolicy(releasecommon.ReleaseStrategyPolicyDefault, managedNamespace, policy)
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.TektonController.CreatePVCInAccessMode(releaseConst.ReleasePvcName, managedNamespace, corev1.ReadWriteOnce)
_, err = fw.AsKubeAdmin.TektonController.CreatePVCInAccessMode(releasecommon.ReleasePvcName, managedNamespace, corev1.ReadWriteOnce)
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.CommonController.CreateRole("role-release-service-account", managedNamespace, map[string][]string{
Expand All @@ -188,10 +188,10 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
})
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.CommonController.CreateRoleBinding("role-release-service-account-binding", managedNamespace, "ServiceAccount", releaseConst.ReleasePipelineServiceAccountDefault, managedNamespace, "Role", "role-release-service-account", "rbac.authorization.k8s.io")
_, err = fw.AsKubeAdmin.CommonController.CreateRoleBinding("role-release-service-account-binding", managedNamespace, "ServiceAccount", releasecommon.ReleasePipelineServiceAccountDefault, managedNamespace, "Role", "role-release-service-account", "rbac.authorization.k8s.io")
Expect(err).NotTo(HaveOccurred())

_, err = fw.AsKubeAdmin.HasController.CreateApplication(releaseConst.ApplicationNameDefault, devNamespace)
_, err = fw.AsKubeAdmin.HasController.CreateApplication(releasecommon.ApplicationNameDefault, devNamespace)
Expect(err).NotTo(HaveOccurred())
})

Expand All @@ -209,14 +209,14 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
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(componentDetected.ComponentStub, devNamespace, "", "", releaseConst.ApplicationNameDefault, true, map[string]string{})
component1, err = fw.AsKubeAdmin.HasController.CreateComponent(componentDetected.ComponentStub, devNamespace, "", "", releasecommon.ApplicationNameDefault, true, map[string]string{})
Expect(err).NotTo(HaveOccurred())
Expect(fw.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(component1, "",
fw.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 2, Always: true})).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(additionalComponentDetected.ComponentStub, devNamespace, "", "", releaseConst.ApplicationNameDefault, true, map[string]string{})
component2, err = fw.AsKubeAdmin.HasController.CreateComponent(additionalComponentDetected.ComponentStub, devNamespace, "", "", releasecommon.ApplicationNameDefault, true, map[string]string{})
Expect(err).NotTo(HaveOccurred())
Expect(fw.AsKubeAdmin.HasController.WaitForComponentPipelineToBeFinished(component2, "",
fw.AsKubeAdmin.TektonController, &has.RetryOptions{Retries: 2, Always: true})).To(Succeed())
Expand All @@ -235,7 +235,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
return err
}
return nil
}, 5*time.Minute, releaseConst.DefaultInterval).Should(Succeed(), "timed out waiting for Snapshots to be created in %s namespace", devNamespace)
}, 5*time.Minute, releasecommon.DefaultInterval).Should(Succeed(), "timed out waiting for Snapshots to be created in %s namespace", devNamespace)
})

It("tests that associated Release CR is created for each Component's Snapshot", func() {
Expand All @@ -251,7 +251,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
return err
}
return nil
}, releaseConst.ReleaseCreationTimeout, releaseConst.DefaultInterval).Should(Succeed(), "timed out waiting for Release CRs to be created in %s namespace", devNamespace)
}, releasecommon.ReleaseCreationTimeout, releasecommon.DefaultInterval).Should(Succeed(), "timed out waiting for Release CRs to be created in %s namespace", devNamespace)
})

It("verifies that Release PipelineRun is triggered for each Release CR", func() {
Expand All @@ -277,7 +277,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
return fmt.Errorf(errMsg)
}
return nil
}, releaseConst.ReleasePipelineRunCreationTimeout, constants.PipelineRunPollingInterval).Should(Succeed(), fmt.Sprintf("timed out waiting for a PipelineRun to start for each Release CR in %s namespace", managedNamespace))
}, releasecommon.ReleasePipelineRunCreationTimeout, constants.PipelineRunPollingInterval).Should(Succeed(), fmt.Sprintf("timed out waiting for a PipelineRun to start for each Release CR in %s namespace", managedNamespace))
})

It("verifies a release PipelineRun for each component succeeded in managed namespace", func() {
Expand All @@ -299,7 +299,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
return fmt.Errorf(errMsg)
}
return nil
}, releaseConst.ReleasePipelineRunCompletionTimeout, constants.PipelineRunPollingInterval).Should(Succeed())
}, releasecommon.ReleasePipelineRunCompletionTimeout, constants.PipelineRunPollingInterval).Should(Succeed())
})

It("validate the result of task create-pyxis-image contains image ids", func() {
Expand Down Expand Up @@ -332,7 +332,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
}

return imageIDs
}, avgControllerQueryTimeout, releaseConst.DefaultInterval).Should(HaveLen(2))
}, avgControllerQueryTimeout, releasecommon.DefaultInterval).Should(HaveLen(2))
})

It("tests that associated Release CR has completed for each Component's Snapshot", func() {
Expand All @@ -349,13 +349,13 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
return fmt.Errorf(errMsg)
}
return nil
}, releaseConst.ReleaseCreationTimeout, releaseConst.DefaultInterval).Should(Succeed(), "timed out waiting for Release CRs to be created in %s namespace", devNamespace)
}, releasecommon.ReleaseCreationTimeout, releasecommon.DefaultInterval).Should(Succeed(), "timed out waiting for Release CRs to be created in %s namespace", devNamespace)
})

It("validates that imageIds from task create-pyxis-image exist in Pyxis.", func() {
for _, imageID := range imageIDs {
Eventually(func() error {
body, err := fw.AsKubeAdmin.ReleaseController.GetPyxisImageByImageID(releaseConst.PyxisStageImagesApiEndpoint, imageID,
body, err := fw.AsKubeAdmin.ReleaseController.GetPyxisImageByImageID(releasecommon.PyxisStageImagesApiEndpoint, imageID,
[]byte(pyxisCertDecoded), []byte(pyxisKeyDecoded))
Expect(err).NotTo(HaveOccurred(), "failed to get response body")

Expand All @@ -367,7 +367,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[HACBS-1571]test-release-e2e-pu
}

return nil
}, releaseConst.ReleaseCreationTimeout, releaseConst.DefaultInterval).Should(Succeed())
}, releasecommon.ReleaseCreationTimeout, releasecommon.DefaultInterval).Should(Succeed())
}
})
})
Expand Down
Loading

0 comments on commit a844926

Please sign in to comment.