Skip to content

Commit 2d9a751

Browse files
Merge pull request #517 from ratnam915/feature/SREP-1164
SREP-1164 : Update README file for running E2E Tests for CAD
2 parents 47a8a8e + 31a74e4 commit 2d9a751

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ require (
1111
github.com/aws/aws-sdk-go-v2/service/ec2 v1.239.0
1212
github.com/aws/aws-sdk-go-v2/service/sts v1.35.1
1313
github.com/onsi/gomega v1.38.0
14+
github.com/openshift-online/ocm-common v0.0.30
1415
github.com/openshift-online/ocm-sdk-go v0.1.473
1516
github.com/openshift/api v0.0.0-20250731182533-c7fbd085e10c
1617
github.com/openshift/aws-account-operator/api v0.0.0-20250729145742-005e36e69583

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ github.com/openshift-online/ocm-api-model/model v0.0.426 h1:aZZ0PuknD9V+RUFsP692
440440
github.com/openshift-online/ocm-api-model/model v0.0.426/go.mod h1:PQIoq6P8Vlb7goOdRMLK8nJY+B7HH0RTqYAa4kyidTE=
441441
github.com/openshift-online/ocm-cli v1.0.6 h1:48VzgYR9JxscLfup7w1nUfMHCIGp/a8AAHrw9cxjMcw=
442442
github.com/openshift-online/ocm-cli v1.0.6/go.mod h1:6BPWRw7d5E3FKRqSxO8YaYJ0g8Am9NxVqKAnFdDp7Lk=
443+
github.com/openshift-online/ocm-common v0.0.30 h1:+JO/WyPGcU99PJlHZNX/pkR5wlIoKHQutTihAiUwfQE=
444+
github.com/openshift-online/ocm-common v0.0.30/go.mod h1:VEkuZp9aqbXtetZ5ycND6QpvhykvTuBF3oPsVM1X3vI=
443445
github.com/openshift-online/ocm-sdk-go v0.1.473 h1:m/NWIBCzhC/8PototMQ7x8MQXCeSLjW7q0qR7bPGXKk=
444446
github.com/openshift-online/ocm-sdk-go v0.1.473/go.mod h1:5Gw/YZE+c5FAPaBtO1w/asd9qbs2ljQwg7fpVq51UW4=
445447
github.com/openshift/api v0.0.0-20250731182533-c7fbd085e10c h1:mY2wQ+0z9CzOn4vdQ+IaP2pnaQxgOx4ei5Qd9sVGr6k=

test/e2e/README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,40 @@
22
When updating your operator it's beneficial to add e2e tests for new functionality AND ensure existing functionality is not breaking using e2e tests.
33
To do this, following steps are recommended
44

5-
1. Run "make e2e-binary-build" to make sure e2e tests build
6-
2. Deploy your new version of operator in a test cluster
7-
3. Run "go install github.com/onsi/ginkgo/ginkgo@latest"
5+
1. Run "make e2e-binary-build" to make sure e2e tests build
6+
7+
2. Run "go install github.com/onsi/ginkgo/ginkgo@latest"
8+
9+
3. Create a ROSA Cluster which would be used for E2E testing using the below command:
10+
11+
rosa create cluster --cluster-name=<cluster-name> --profile <default-aws-profile>
12+
813
4. Get kubeadmin credentials from your cluster using
914

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

12-
5. Run test suite using
17+
5. AWS Credentials
18+
These are needed for interacting with the cluster. You can find them in the ~/.aws/credentials file.
19+
Check for the access key and the secret key from the <default-aws-profile> used for creating the cluster.
20+
export AWS_ACCESS_KEY_ID=<your AWS access key ID>
21+
export AWS_SECRET_ACCESS_KEY=<your AWS secret access key>
22+
23+
6. PAGERDUTY ROUTING KEY
24+
25+
This is required for the PagerDuty alerts that are being sent as part of the testing:
26+
27+
https://redhat.pagerduty.com/service-directory/P4BLYHK/integrations
28+
29+
The value can be picked up from the Integration Key in the above link
30+
31+
export CAD_PAGERDUTY_ROUTING_KEY=<url-integration-key-value>
32+
33+
7. OCM_CLUSTER_ID
34+
35+
For running the test cases set up the value of OCM_CLUSTER_ID from the Internal ID of the cluster created in Step #3.
36+
37+
export OCM_CLUSTER_ID=<internal-cluster-id>
38+
39+
7. Run test suite using
1340

1441
DISABLE_JUNIT_REPORT=true KUBECONFIG=/(path-to)/kubeconfig ./(path-to)/bin/ginkgo --tags=osde2e -v test/e2e

test/e2e/configuration_anomaly_detection_tests.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/onsi/ginkgo/v2"
1919
. "github.com/onsi/ginkgo/v2"
2020
. "github.com/onsi/gomega"
21+
ocmConfig "github.com/openshift-online/ocm-common/pkg/ocm/config"
22+
ocmConnBuilder "github.com/openshift-online/ocm-common/pkg/ocm/connection-builder"
2123
v1beta1 "github.com/openshift/api/machine/v1beta1"
2224
awsinternal "github.com/openshift/configuration-anomaly-detection/pkg/aws"
2325
machineutil "github.com/openshift/configuration-anomaly-detection/pkg/investigations/utils/machine"
@@ -47,14 +49,26 @@ var _ = Describe("Configuration Anomaly Detection", Ordered, func() {
4749
logger.SetLogger(ginkgo.GinkgoLogr)
4850
var err error
4951
ocmEnv := ocme2e.Stage
50-
clientID := os.Getenv("OCM_CLIENT_ID")
51-
clientSecret := os.Getenv("OCM_CLIENT_SECRET")
5252
clusterID = os.Getenv("OCM_CLUSTER_ID")
5353

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

56-
ocme2eCli, err = ocme2e.New(ctx, "", clientID, clientSecret, ocmEnv)
57-
Expect(err).ShouldNot(HaveOccurred(), "Unable to setup E2E OCM Client")
56+
cfg, err := ocmConfig.Load()
57+
if err != nil {
58+
// Fall back to environment variables
59+
clientID := os.Getenv("OCM_CLIENT_ID")
60+
clientSecret := os.Getenv("OCM_CLIENT_SECRET")
61+
Expect(clientID).NotTo(BeEmpty(), "OCM_CLIENT_ID must be set")
62+
Expect(clientSecret).NotTo(BeEmpty(), "OCM_CLIENT_SECRET must be set")
63+
64+
ocme2eCli, err = ocme2e.New(ctx, "", clientID, clientSecret, ocmEnv)
65+
Expect(err).ShouldNot(HaveOccurred(), "Unable to setup E2E OCM Client")
66+
} else {
67+
// Build connection based on local config
68+
connection, err := ocmConnBuilder.NewConnection().Config(cfg).AsAgent("cad-local-e2e-tests").Build()
69+
Expect(err).ShouldNot(HaveOccurred(), "Unable to build OCM connection")
70+
ocme2eCli = &ocme2e.Client{Connection: connection}
71+
}
5872

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

0 commit comments

Comments
 (0)