Skip to content

SREP-1164 : Update README file for running E2E Tests for CAD #517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/ec2 v1.239.0
github.com/aws/aws-sdk-go-v2/service/sts v1.35.1
github.com/onsi/gomega v1.38.0
github.com/openshift-online/ocm-common v0.0.30
github.com/openshift-online/ocm-sdk-go v0.1.473
github.com/openshift/api v0.0.0-20250731182533-c7fbd085e10c
github.com/openshift/aws-account-operator/api v0.0.0-20250729145742-005e36e69583
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ github.com/openshift-online/ocm-api-model/model v0.0.426 h1:aZZ0PuknD9V+RUFsP692
github.com/openshift-online/ocm-api-model/model v0.0.426/go.mod h1:PQIoq6P8Vlb7goOdRMLK8nJY+B7HH0RTqYAa4kyidTE=
github.com/openshift-online/ocm-cli v1.0.6 h1:48VzgYR9JxscLfup7w1nUfMHCIGp/a8AAHrw9cxjMcw=
github.com/openshift-online/ocm-cli v1.0.6/go.mod h1:6BPWRw7d5E3FKRqSxO8YaYJ0g8Am9NxVqKAnFdDp7Lk=
github.com/openshift-online/ocm-common v0.0.30 h1:+JO/WyPGcU99PJlHZNX/pkR5wlIoKHQutTihAiUwfQE=
github.com/openshift-online/ocm-common v0.0.30/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI=
github.com/openshift-online/ocm-sdk-go v0.1.473 h1:m/NWIBCzhC/8PototMQ7x8MQXCeSLjW7q0qR7bPGXKk=
github.com/openshift-online/ocm-sdk-go v0.1.473/go.mod h1:5Gw/YZE+c5FAPaBtO1w/asd9qbs2ljQwg7fpVq51UW4=
github.com/openshift/api v0.0.0-20250731182533-c7fbd085e10c h1:mY2wQ+0z9CzOn4vdQ+IaP2pnaQxgOx4ei5Qd9sVGr6k=
Expand Down
29 changes: 25 additions & 4 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@
When updating your operator it's beneficial to add e2e tests for new functionality AND ensure existing functionality is not breaking using e2e tests.
To do this, following steps are recommended

1. Run "make e2e-binary-build" to make sure e2e tests build
2. Deploy your new version of operator in a test cluster
3. Run "go install github.com/onsi/ginkgo/ginkgo@latest"
1. Run "make e2e-binary-build" to make sure e2e tests build

2. Run "go install github.com/onsi/ginkgo/ginkgo@latest"

3. Create a ROSA Cluster which would be used for E2E testing using the below command:

rosa create cluster --cluster-name=<cluster-name> --profile <default-aws-profile>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish: we need to export the cluster id as OCM_CLUSTER_ID here


4. Get kubeadmin credentials from your cluster using

ocm get /api/clusters_mgmt/v1/clusters/(cluster-id)/credentials | jq -r .kubeconfig > /(path-to)/kubeconfig
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of this PR, but the sentence above:

. Deploy your new version of operator in a test cluster

That doesn't seem to apply here.


5. Run test suite using
5. AWS Credentials
These are needed for interacting with the cluster. You can find them in the ~/.aws/credentials file.
Check for the access key and the secret key from the <default-aws-profile> used for creating the cluster.
export AWS_ACCESS_KEY_ID=<your AWS access key ID>
export AWS_SECRET_ACCESS_KEY=<your AWS secret access key>

6. PAGERDUTY ROUTING KEY

This is required for the PagerDuty alerts that are being sent as part of the testing:

https://redhat.pagerduty.com/service-directory/P4BLYHK/integrations

The value can be picked up from the Integration Key in the above link

export CAD_PAGERDUTY_ROUTING_KEY=<url-integration-key-value>

7. Run test suite using

DISABLE_JUNIT_REPORT=true KUBECONFIG=/(path-to)/kubeconfig ./(path-to)/bin/ginkgo --tags=osde2e -v test/e2e
22 changes: 18 additions & 4 deletions test/e2e/configuration_anomaly_detection_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"github.com/onsi/ginkgo/v2"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
ocmConfig "github.com/openshift-online/ocm-common/pkg/ocm/config"
ocmConnBuilder "github.com/openshift-online/ocm-common/pkg/ocm/connection-builder"
v1beta1 "github.com/openshift/api/machine/v1beta1"
awsinternal "github.com/openshift/configuration-anomaly-detection/pkg/aws"
machineutil "github.com/openshift/configuration-anomaly-detection/pkg/investigations/utils/machine"
Expand Down Expand Up @@ -47,14 +49,26 @@ var _ = Describe("Configuration Anomaly Detection", Ordered, func() {
logger.SetLogger(ginkgo.GinkgoLogr)
var err error
ocmEnv := ocme2e.Stage
clientID := os.Getenv("OCM_CLIENT_ID")
clientSecret := os.Getenv("OCM_CLIENT_SECRET")
clusterID = os.Getenv("OCM_CLUSTER_ID")

Expect(clusterID).NotTo(BeEmpty(), "CLUSTER_ID must be set")

ocme2eCli, err = ocme2e.New(ctx, "", clientID, clientSecret, ocmEnv)
Expect(err).ShouldNot(HaveOccurred(), "Unable to setup E2E OCM Client")
cfg, err := ocmConfig.Load()
if err != nil {
// Fall back to environment variables
clientID := os.Getenv("OCM_CLIENT_ID")
clientSecret := os.Getenv("OCM_CLIENT_SECRET")
Expect(clientID).NotTo(BeEmpty(), "OCM_CLIENT_ID must be set")
Expect(clientSecret).NotTo(BeEmpty(), "OCM_CLIENT_SECRET must be set")

ocme2eCli, err = ocme2e.New(ctx, "", clientID, clientSecret, ocmEnv)
Expect(err).ShouldNot(HaveOccurred(), "Unable to setup E2E OCM Client")
} else {
// Build connection based on local config
connection, err := ocmConnBuilder.NewConnection().Config(cfg).AsAgent("cad-local-e2e-tests").Build()
Expect(err).ShouldNot(HaveOccurred(), "Unable to build OCM connection")
ocme2eCli = &ocme2e.Client{Connection: connection}
}

k8s, err = openshift.New(ginkgo.GinkgoLogr)
Expect(err).ShouldNot(HaveOccurred(), "Unable to setup k8s client")
Expand Down