Skip to content

Commit

Permalink
test: Add fbc e2e-test happy path to pipelines suite (#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasemAlem authored Oct 10, 2023
1 parent 10f9279 commit 03caa65
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 28 deletions.
1 change: 1 addition & 0 deletions cmd/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
_ "github.com/redhat-appstudio/e2e-tests/tests/enterprise-contract"
_ "github.com/redhat-appstudio/e2e-tests/tests/integration-service"
_ "github.com/redhat-appstudio/e2e-tests/tests/release"
_ "github.com/redhat-appstudio/e2e-tests/tests/release/pipelines"
_ "github.com/redhat-appstudio/e2e-tests/tests/remotesecret"
_ "github.com/redhat-appstudio/e2e-tests/tests/rhtap-demo"
_ "github.com/redhat-appstudio/e2e-tests/tests/spi"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ require (
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-redis/cache/v9 v9.0.0 // indirect
github.com/go-resty/resty/v2 v2.9.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
Expand Down
13 changes: 0 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,6 @@ github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTM
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
github.com/go-redis/cache/v9 v9.0.0 h1:0thdtFo0xJi0/WXbRVu8B066z8OvVymXTJGaXrVWnN0=
github.com/go-redis/cache/v9 v9.0.0/go.mod h1:cMwi1N8ASBOufbIvk7cdXe2PbPjK/WMRL95FFHWsSgI=
github.com/go-resty/resty/v2 v2.9.1 h1:PIgGx4VrHvag0juCJ4dDv3MiFRlDmP0vicBucwf+gLM=
github.com/go-resty/resty/v2 v2.9.1/go.mod h1:4/GYJVjh9nhkhGR6AUNW3XhpDYNUr+Uvy9gV/VGZIy4=
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
Expand Down Expand Up @@ -1629,8 +1627,6 @@ golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2Uz
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -1762,8 +1758,6 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -1937,8 +1931,6 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
Expand All @@ -1952,8 +1944,6 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c=
golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o=
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1972,8 +1962,6 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand All @@ -1982,7 +1970,6 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20220609170525-579cf78fd858/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
Expand Down
20 changes: 20 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ const (
// Cert auth for accessing Pyxis stage external registry
PYXIS_STAGE_CERT_ENV string = "PYXIS_STAGE_CERT"

// Offline/refresh token used for getting Keycloak token in order to authenticate against stage/prod cluster
// More details: https://access.redhat.com/articles/3626371
OFFLINE_TOKEN_ENV = "OFFLINE_TOKEN"

// Keycloak URL used for authentication against stage/prod cluster
KEYLOAK_URL_ENV = "KEYLOAK_URL"

// Toolchain API URL used for authentication against stage/prod cluster
TOOLCHAIN_API_URL_ENV = "TOOLCHAIN_API_URL"

// Dev workspace for release pipelines tests
RELEASE_DEV_WORKSPACE_ENV = "RELEASE_DEV_WORKSPACE"

// Managed workspace for release pipelines tests
RELEASE_MANAGED_WORKSPACE_ENV = "RELEASE_MANAGED_WORKSPACE"

// Bundle ref for overriding the default Java build bundle specified in BuildPipelineSelectorYamlURL
CUSTOM_JAVA_PIPELINE_BUILD_BUNDLE_ENV string = "CUSTOM_JAVA_PIPELINE_BUILD_BUNDLE"

Expand Down Expand Up @@ -106,6 +122,10 @@ const (

ReleasePipelineImageRef = "quay.io/hacbs-release/pipeline-release:0.20"

FromIndex = "quay.io/scoheb/fbc-index-testing:latest"
TargetIndex = "quay.io/scoheb/fbc-target-index-testing:latest"
BinaryImage = "registry.redhat.io/openshift4/ose-operator-registry:v4.12"

StrategyConfigsRepo = "strategy-configs"
StrategyConfigsDefaultBranch = "main"
StrategyConfigsRevision = "caeaaae63a816ab42dad6c7be1e4b352ea8aabf4"
Expand Down
4 changes: 4 additions & 0 deletions pkg/framework/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ func EnterpriseContractSuiteDescribe(text string, args ...interface{}) bool {
func UpgradeSuiteDescribe(text string, args ...interface{}) bool {
return Describe("[upgrade-suite "+text+"]", args, Ordered)
}

func ReleasePipelinesSuiteDescribe(text string, args ...interface{}) bool {
return Describe("[release-pipelines-suite "+text+"]", args, Ordered)
}
25 changes: 13 additions & 12 deletions pkg/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import (
)

type ControllerHub struct {
HasController *has.HasController
CommonController *common.SuiteController
TektonController *tekton.TektonController
GitOpsController *gitops.GitopsController
SPIController *spi.SPIController
RemoteSecretController *remotesecret.RemoteSecretController
ReleaseController *release.ReleaseController
IntegrationController *integration.IntegrationController
JvmbuildserviceController *jvmbuildservice.JvmbuildserviceController
HasController *has.HasController
CommonController *common.SuiteController
TektonController *tekton.TektonController
GitOpsController *gitops.GitopsController
SPIController *spi.SPIController
RemoteSecretController *remotesecret.RemoteSecretController
ReleaseController *release.ReleaseController
IntegrationController *integration.IntegrationController
JvmbuildserviceController *jvmbuildservice.JvmbuildserviceController
}

type Framework struct {
Expand Down Expand Up @@ -104,10 +104,11 @@ func NewFrameworkWithTimeout(userName string, timeout time.Duration, options ...
asAdmin = asUser
}

if err = utils.WaitUntil(asAdmin.CommonController.ServiceaccountPresent(constants.DefaultPipelineServiceAccount, k.UserNamespace), timeout); err != nil {
return nil, fmt.Errorf("'%s' service account wasn't created in %s namespace: %+v", constants.DefaultPipelineServiceAccount, k.UserNamespace, err)
if !isStage {
if err = utils.WaitUntil(asAdmin.CommonController.ServiceaccountPresent(constants.DefaultPipelineServiceAccount, k.UserNamespace), timeout); err != nil {
return nil, fmt.Errorf("'%s' service account wasn't created in %s namespace: %+v", constants.DefaultPipelineServiceAccount, k.UserNamespace, err)
}
}

return &Framework{
AsKubeAdmin: asAdmin,
AsKubeDeveloper: asUser,
Expand Down
17 changes: 17 additions & 0 deletions pkg/utils/release/strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package release

import (
"context"

"github.com/redhat-appstudio/release-service/tekton/utils"

releaseApi "github.com/redhat-appstudio/release-service/api/v1alpha1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -50,3 +52,18 @@ func (r *ReleaseController) GenerateReleaseStrategyConfig(components []Component
Mapping{Components: components},
}
}

// DeleteReleaseStrategy deletes ReleaseStrategy.
func (r *ReleaseController) DeleteReleaseStrategy(name, namespace string, failOnNotFound bool) error {
releasePlan := &releaseApi.ReleaseStrategy{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
}
err := r.KubeRest().Delete(context.TODO(), releasePlan)
if err != nil && !failOnNotFound && k8sErrors.IsNotFound(err) {
err = nil
}
return err
}
15 changes: 15 additions & 0 deletions pkg/utils/tekton/enterprise_contract_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,18 @@ func (t *TektonController) GetEnterpriseContractPolicy(name, namespace string) (

return &defaultEcPolicy, err
}

// DeleteEnterpriseContractPolicy deletes enterprise contract policy.
func (t *TektonController) DeleteEnterpriseContractPolicy(name string, namespace string, failOnNotFound bool) error {
ecPolicy := ecp.EnterpriseContractPolicy{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
}
err := t.KubeRest().Delete(context.TODO(), &ecPolicy)
if err != nil && !failOnNotFound && errors.IsNotFound(err) {
err = nil
}
return err
}
42 changes: 40 additions & 2 deletions tests/release/pipelines/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
# Release Bundles Tests
# Release Pipelines Tests

This suite contains e2e-tests for testing release pipelines from repository [release-service-catalog](https://github.com/redhat-appstudio/release-service-catalog/tree/main), those tests run against RHTAP RH-Stage.

### All tests must have the label `release-pipelines` to avoid running them against the dev environment by OpenShift CI
## prerequisites:
- Export the following environment variables:
```
- TOOLCHAIN_API_URL_ENV: Offline token used for getting Keycloak token in order to authenticate against stage/prod cluster
- KEYLOAK_URL_ENV: Keycloak URL used for authentication against stage/prod cluster
- OFFLINE_TOKEN_ENV : Toolchain API URL used for authentication against stage/prod cluster
```
- The tests will run on two dedicated namespaces, so a user not part of them need to request access to the following namespaces:
```
- dev-release-team-tenant
- managed-release-team-tenant
```

## How to Run tests:

### 1. To run all e2e-tests in suite ensure your changes of the suite tests are saved.
- navigate to `e2e-tests` directoy
```bash
make build
./bin/e2e-appstudio --ginkgo.junit-report=report.xml --ginkgo.focus="pipelines"
```

### 2. To run specific test we should define the test with specific label.
[Ginkgo](https://onsi.github.io/ginkgo/#why-ginkgo) uses labels filtering, adding a label for a test will enable to run specific tests with this label.

For example:
If a test has the label `label-test` to a test in suite `pipelines` then the test should run using the following arguments:

- navigate to `e2e-tests` directoy
```bash
make build
./bin/e2e-appstudio --ginkgo.junit-report=report.xml --ginkgo.focus="pipelines" --ginkgo.label-filter="label-test"
```



This suite contains e2e-tests for testing release pipelines from repository [release-service-catalog](https://github.com/redhat-appstudio/release-service-catalog/tree/main), those tests run against RHTAP RH-Stage.
Loading

0 comments on commit 03caa65

Please sign in to comment.