Skip to content

Commit

Permalink
fix: release clean up code (#898)
Browse files Browse the repository at this point in the history
relase clean up code
  • Loading branch information
cuipinghuo authored Dec 14, 2023
1 parent 73423b7 commit 538b749
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 203 deletions.
50 changes: 50 additions & 0 deletions tests/release/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package constants

import (
"github.com/redhat-appstudio/e2e-tests/pkg/utils"
corev1 "k8s.io/api/core/v1"
"time"
)

const (
ApplicationNameDefault string = "appstudio"
ReleaseStrategyPolicyDefault string = "mvp-policy"
ReleaseStrategyPolicy string = "policy"

RedhatAppstudioUserSecret string = "hacbs-release-tests-token"
HacbsReleaseTestsTokenSecret string = "redhat-appstudio-registry-pull-secret"
PublicSecretNameAuth string = "cosign-public-key"
ReleasePipelineServiceAccountDefault string = "release-service-account"

SourceReleasePlanName string = "source-releaseplan"
TargetReleasePlanAdmissionName string = "demo"
ReleasePvcName string = "release-pvc"
ReleaseEnvironment string = "production"

ReleaseCreationTimeout = 5 * time.Minute
ReleasePipelineRunCreationTimeout = 10 * time.Minute
ReleasePipelineRunCompletionTimeout = 20 * time.Minute
DefaultInterval = 100 * time.Millisecond

// Pipelines constants
ComponentName string = "dc-metro-map"
GitSourceComponentUrl string = "https://github.com/scoheb/dc-metro-map"
AdditionalComponentName string = "simple-python"
AdditionalGitSourceComponentUrl string = "https://github.com/devfile-samples/devfile-sample-python-basic"
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/"

// Service constants
ApplicationName string = "application"
)

var ManagednamespaceSecret = []corev1.ObjectReference{
{Name: RedhatAppstudioUserSecret},
}

// Pipelines variables
var (
RelSvcCatalogURL string = utils.GetEnv("RELEASE_SERVICE_CATALOG_URL", "https://github.com/redhat-appstudio/release-service-catalog")
RelSvcCatalogRevision string = utils.GetEnv("RELEASE_SERVICE_CATALOG_REVISION", "main")
)
49 changes: 0 additions & 49 deletions tests/release/pipelines/const.go

This file was deleted.

16 changes: 6 additions & 10 deletions tests/release/pipelines/fbc_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"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"
releaseConst "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"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
Expand Down Expand Up @@ -43,9 +45,6 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[RHTAPREL-373]fbc happy path e2
var managedWorkspace = os.Getenv(constants.RELEASE_MANAGED_WORKSPACE_ENV)
var devNamespace = devWorkspace + "-tenant"
var managedNamespace = managedWorkspace + "-tenant"
var releasePipelineRunCompletionTimeout = 20 * time.Minute
var releaseCreationTimeout = 5 * time.Minute
var defaultInterval = 100 * time.Millisecond

var err error
var devFw *framework.Framework
Expand Down Expand Up @@ -114,16 +113,15 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[RHTAPREL-373]fbc happy path e2
_, err = managedFw.AsKubeAdmin.ReleaseController.CreateReleasePlanAdmission(fbcReleasePlanAdmissionName, managedNamespace, "", devNamespace, fbcEnterpriseContractPolicyName, fbcServiceAccountName, []string{fbcApplicationName}, true, &tektonutils.PipelineRef{
Resolver: "git",
Params: []tektonutils.Param{
{Name: "url", Value: relSvcCatalogURL},
{Name: "revision", Value: relSvcCatalogRevision},
{Name: "url", Value: releaseConst.RelSvcCatalogURL},
{Name: "revision", Value: releaseConst.RelSvcCatalogRevision},
{Name: "pathInRepo", Value: relSvcCatalogPathInRepo},
},
}, &runtime.RawExtension{
Raw: data,
})

Expect(err).NotTo(HaveOccurred())

defaultEcPolicySpec := ecp.EnterpriseContractPolicySpec{
Description: "Red Hat's enterprise requirements",
PublicKey: "k8s://openshift-pipelines/public-key",
Expand All @@ -138,10 +136,8 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[RHTAPREL-373]fbc happy path e2
Include: []string{"@slsa3"},
},
}

_, err = managedFw.AsKubeDeveloper.TektonController.CreateEnterpriseContractPolicy(fbcEnterpriseContractPolicyName, managedNamespace, defaultEcPolicySpec)
Expect(err).NotTo(HaveOccurred())

})

AfterAll(func() {
Expand Down Expand Up @@ -177,7 +173,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[RHTAPREL-373]fbc happy path e2
GinkgoWriter.Println("Release PR: ", releasePr.Name)
Expect(tekton.HasPipelineRunSucceeded(releasePr)).To(BeTrue(), fmt.Sprintf("release pipelinerun %s/%s did not succeed", releasePr.GetNamespace(), releasePr.GetName()))
return nil
}, releasePipelineRunCompletionTimeout, defaultInterval).Should(Succeed(), "timed out when waiting for release pipelinerun to succeed")
}, releaseConst.ReleasePipelineRunCompletionTimeout, releaseConst.DefaultInterval).Should(Succeed(), "timed out when waiting for release pipelinerun to succeed")
})

It("verifies release CR completed and set succeeded.", func() {
Expand All @@ -191,7 +187,7 @@ var _ = framework.ReleasePipelinesSuiteDescribe("[RHTAPREL-373]fbc happy path e2
return fmt.Errorf("release %s/%s is not marked as finished yet", releaseCR.GetNamespace(), releaseCR.GetName())
}
return nil
}, releaseCreationTimeout, defaultInterval).Should(Succeed())
}, releaseConst.ReleaseCreationTimeout, releaseConst.DefaultInterval).Should(Succeed())
})

})
Expand Down
Loading

0 comments on commit 538b749

Please sign in to comment.