Skip to content

Commit

Permalink
Release related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tisutisu committed Jul 24, 2024
1 parent c430a05 commit ab48b16
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 55 deletions.
16 changes: 12 additions & 4 deletions tests/release/const.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand Down Expand Up @@ -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/"
Expand All @@ -50,6 +54,8 @@ const (

// Service constants
ApplicationName string = "application"

githubUrlFormat = "https://github.com/%s/%s"
)

var ManagednamespaceSecret = []corev1.ObjectReference{
Expand All @@ -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")
)
48 changes: 42 additions & 6 deletions tests/release/pipelines/fbc_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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)
Expand All @@ -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)

Expand All @@ -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() {
Expand All @@ -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)
Expand All @@ -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)
})
Expand All @@ -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() {
Expand All @@ -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)
Expand All @@ -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)
})
Expand All @@ -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() {
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions tests/release/pipelines/multiarch_rh_advisories.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,16 @@ 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

data, err := json.Marshal(map[string]interface{}{
"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,
Expand Down Expand Up @@ -319,25 +318,26 @@ 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())

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)
Expand Down
16 changes: 14 additions & 2 deletions tests/release/pipelines/push_to_external_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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() {
Expand Down
21 changes: 18 additions & 3 deletions tests/release/pipelines/release_to_github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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))

Expand Down Expand Up @@ -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)
})
Expand All @@ -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() {
Expand Down
Loading

0 comments on commit ab48b16

Please sign in to comment.