Skip to content

Commit 72d2f71

Browse files
nilgaarzdrapelajosephcaschultzp2020nickboldt
authored
docs: adding ci.md documentation 2 (#1959)
* init CI.md * + Nightlies details * update CI * update CI.md anc add comments to test setup script * + adding subhash answers * + diagrams * restyle and format * minor fix on missing enclosure * -Maintenance * cut duplicated info * observations about /ok-to-test adding /test e2e-tests under Triggering Tests Post-Validation + more about openshift-ci-tests.sh - cluter names retest info cut rename branch names considerations about OCP versions * Update e2e-tests/docs/CI.md Co-authored-by: Zbyněk Drápela <[email protected]> * Update e2e-tests/docs/CI.md Co-authored-by: Zbyněk Drápela <[email protected]> * moving High-Level Overview of openshift-ci-tests.sh fix openshift-ci-tests.sh path removing some duplicated Retrying Tests info puntualization at Environment Variables and Secrets fix comment for droute_send + report portal * note RBAC namespaces * info about config files * + test runner * fix github diagram colors * update nithly diagram * update nightly backgrounds * background color * + diagram in mermaid code * moving to /docs * fix background on nightly diagram * Delete nightly_diagram.mermaid * adjustments in docs. * fix build doc warning * minor updates --------- Co-authored-by: Zbyněk Drápela <[email protected]> Co-authored-by: Joseph Kim <[email protected]> Co-authored-by: Paul Schultz <[email protected]> Co-authored-by: Nick Boldt <[email protected]>
1 parent c50f33d commit 72d2f71

File tree

4 files changed

+186
-0
lines changed

4 files changed

+186
-0
lines changed

.ibm/pipelines/openshift-ci-tests.sh

+3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
set -e
44
export PS4='[$(date "+%Y-%m-%d %H:%M:%S")] ' # logs timestamp for every cmd.
55

6+
# Define log file names and directories.
67
LOGFILE="test-log"
78
export DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
89
OVERALL_RESULT=0
910

11+
# Define a cleanup function to be executed upon script exit.
1012
# shellcheck disable=SC2317
1113
cleanup() {
1214
echo "Cleaning up before exiting"
1315
if [[ "$JOB_NAME" == *aks* && "${OPENSHIFT_CI}" == "true" ]]; then
16+
# If the job is for Azure Kubernetes Service (AKS), stop the AKS cluster.
1417
az_aks_stop "${AKS_NIGHTLY_CLUSTER_NAME}" "${AKS_NIGHTLY_CLUSTER_RESOURCEGROUP}"
1518
fi
1619
rm -rf ~/tmpbin

docs/e2e-tests/CI.md

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Continuous Integration Testing Processes
2+
3+
This document provides a comprehensive overview of our Continuous Integration (CI) testing processes. It explains when and how different test jobs are triggered, where to monitor them, and details about the environments hosting these tests, along with guidance on how to access them.
4+
5+
## GitHub Pull Requests
6+
7+
When a new Pull Request (PR) is opened at [backstage-showcase](https://github.com/janus-idp/backstage-showcase), tests are triggered based on the nature of the changes and the contributor's role.
8+
9+
### Automatic Triggering of Tests
10+
11+
- **Code Changes Affecting Tests:** PR tests are triggered automatically if the changes include code modifications that could impact tests. This means that for PRs involving code that affects functionality or test suites, the CI will automatically initiate the testing process.
12+
- **Documentation-Only Changes:** PRs that involve only documentation updates will skip the tests to conserve CI resources, as they do not affect the codebase or functionality.
13+
14+
### Manual Triggering of Tests
15+
16+
For scenarios where tests are not automatically triggered, or when you need to manually initiate tests (e.g., for draft PRs or external contributions), you can use the following commands:
17+
18+
1. **Commenting `/ok-to-test`:**
19+
20+
- **Purpose:** This command is used to validate a PR for testing, especially important for external contributors or when tests are not automatically triggered.
21+
- **Who Can Use It:** Only members of the [janus-idp](https://github.com/janus-idp) GitHub organization can mark the PR with this comment.
22+
- **Use Cases:**
23+
- **External Contributors:** For PRs from contributors outside the organization, a member needs to comment `/ok-to-test` to initiate tests.
24+
- **More Details:** For additional information about `/ok-to-test`, please refer to the [Kubernetes Community Pull Requests Guide](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#more-about-ok-to-test).
25+
26+
2. **Triggering Tests Post-Validation:**
27+
- After a janus-idp member has validated the PR with `/ok-to-test`, anyone can trigger tests using the following commands:
28+
- `/test`, `/test images`, `/test all` or `/test e2e-tests`
29+
30+
These interactions are picked up by the OpenShift-CI service, which sets up a test environment on the **IBM Cloud**, specifically on an OpenShift Container Platform (OCP) cluster. The configurations and steps for setting up this environment are defined in the `openshift-ci-tests.sh` script. For more details, see the [High-Level Overview of `openshift-ci-tests.sh`](#high-level-overview-of-openshift-ci-testssh).
31+
32+
### Retrying Tests
33+
34+
If the initial automatically triggered tests fail, OpenShift-CI will add a comment to the PR with information on how to retrigger the tests.
35+
36+
### CI Job Definitions
37+
38+
#### Pull Request Test Job
39+
40+
- **Purpose:** Validate new PRs for code quality, functionality, and integration.
41+
- **Trigger:**
42+
- **Automatic:** When a PR includes code changes affecting tests (excluding doc-only changes), tests are automatically triggered.
43+
- **Manual:** When `/ok-to-test` is commented by a janus-idp member for external contributors or when `/test`, `/test images`, `/test all` and `/test e2e-tests` is commented after validation.
44+
- **Environment:** Runs on an ephemeral OpenShift cluster on IBM Cloud.
45+
- **Configurations:**
46+
- Tests are executed on both **RBAC** (Role-Based Access Control) and **non-RBAC** namespaces. Different sets of tests are executed for both the **non-RBAC RHDH instance** and the **RBAC RHDH instance**, each deployed in separate namespaces.
47+
- **Access:** In order to access the environment, you can run the bash at `.ibm/pipelines/ocp-cluster-claim-login.sh`. You will be prompted the prow url (the url from the openshift agent, which looks like https://prow.ci.openshift.org/...). Once you test calimed a cluster, this script will forward the cluster web console url along with the credentials.
48+
- **Steps:**
49+
50+
1. **Detection:** OpenShift-CI detects the PR event.
51+
2. **Environment Setup:** The test environment is set up using the `openshift-ci-tests.sh` script (see the [High-Level Overview](#high-level-overview-of-openshift-ci-testssh)).
52+
- **Cluster Configuration:** Sets up the required namespaces and applies necessary configurations and secrets.
53+
- **Application Deployment:** Deploys the RHDH instances using Helm charts, tailored to the specific test scenarios.
54+
3. **Test Execution:**
55+
- **Running Tests:** Executes test suites using `yarn` commands specified in `package.json`.
56+
- **Retry Logic:** Individual tests are retried up to 2 times as specified in the Playwright configuration.
57+
4. **Artifact Collection:**
58+
- Collects test artifacts (logs, screenshots, recordings).
59+
- Stores artifacts in the designated `ARTIFACT_DIR` for a retention period of **6 months**.
60+
- The reports are also sent to _ReportPortal_
61+
5. **Reporting:**
62+
- Reports status back to the PR checks.
63+
- Generates and uploads HTML reports.
64+
65+
- **Artifacts:** Test reports, logs, screenshots, accessible via PR details under **Artifacts**.
66+
- **Notifications:** Status updates posted on the PR.
67+
68+
### GitHub PR Testing Diagram
69+
70+
![GitHub PR Testing Diagram](../images/github_diagram.svg)
71+
72+
## Nightly Tests
73+
74+
Nightly tests are run to ensure the stability and reliability of our codebase over time. These tests are executed on different clusters to cover various environments, including both **RBAC** and **non-RBAC**.
75+
76+
### Nightly Test Environments
77+
78+
- **AKS Nightly Tests:** Nightly tests for Azure Kubernetes Service (AKS) run on a dedicated cluster. We do not have AKS PR checks; the AKS environment is exclusively used for nightly runs.
79+
- **IBM Cloud Tests:** All nightly tests for the `main` and `release-1.n`(depending on the latest release versions) branches run against OpenShift clusters on IBM Cloud.
80+
- **GKE Nightly Tests:** Nightly tests on top of Google Kubernetes Engine. As the AKS, GKE is only used for nightly tests.
81+
82+
### Additional Nightly Jobs for Main Branch
83+
84+
The nightly job for the `main` branch also runs against three OpenShift Container Platform (OCP) versions to ensure compatibility and stability across multiple versions. We maintain testing on the three most recent OCP versions. As new OCP versions are released, we will update our testing pipeline to include the latest versions and drop support for older ones accordingly.
85+
86+
> **Note:** The output of the nightly runs, including test results and any relevant notifications, is posted on the Slack channel **`#rhdh-e2e-test-alerts`**.
87+
88+
### CI Job Definitions
89+
90+
#### Nightly Test Job
91+
92+
- **Purpose:** Ensure ongoing stability and detect regressions in different environments.
93+
- **Trigger:** Scheduled to run every night.
94+
- **Environments:**
95+
- **AKS Nightly Tests:** Runs on the dedicated AKS cluster.
96+
- **IBM Cloud Nightly Tests:** Runs on OpenShift clusters on IBM Cloud, covering the most recent OCP versions.
97+
- **Configurations:**
98+
- Tests are executed on both **RBAC** (Role-Based Access Control) and **non-RBAC** namespaces.
99+
- **Steps:**
100+
1. **Triggering:** Nightly job is triggered on schedule.
101+
2. **Environment Setup:** Uses the `openshift-ci-tests.sh` script for setting up the environment (see the [High-Level Overview](#high-level-overview-of-openshift-ci-testssh) for more information).
102+
- **Cluster Selection:** Chooses the appropriate cluster and OCP version based on the job configuration.
103+
- **Resource Configuration:** Sets up namespaces and configures resources.
104+
- **Deployment:** Deploys the Red Hat Developer Hub (RHDH) instance and necessary services.
105+
3. **Test Execution:**
106+
- Runs full test suites using the `yarn` commands.
107+
- Tests are executed similarly to the PR tests but may include additional suites.
108+
- **Retry Logic:** Individual tests are retried up to 2 times as specified in the Playwright configuration.
109+
4. **Artifact Collection:**
110+
- Collects and aggregates results.
111+
- Stores artifacts for later review for a retention period of **6 months**.
112+
5. **Reporting:**
113+
- Posts outputs to Slack channel `#rhdh-e2e-test-alerts`.
114+
- Generates report.
115+
- **Artifacts:** Comprehensive test reports, logs, screenshots.
116+
- **Notifications:** Results posted on Slack.
117+
118+
### Nightly Testing Diagram
119+
120+
![Nightly Testing Diagram](../images/nightly_diagram.svg)
121+
122+
## Configuration and Installation of Testing Environments
123+
124+
### Automation Processes
125+
126+
- **Script Used:**
127+
128+
- **`openshift-ci-tests.sh`**: Automates the setup of the test environment, deployment of RHDH instances, and execution of tests. For more details, refer to the [High-Level Overview of `openshift-ci-tests.sh`](#high-level-overview-of-openshift-ci-testssh).
129+
130+
### High-Level Overview of `openshift-ci-tests.sh`
131+
132+
The `openshift-ci-tests.sh` script (located at [`.ibm/pipelines/openshift-ci-tests.sh`](../../.ibm/pipelines/openshift-ci-tests.sh)) orchestrates the deployment and testing workflow for both PR and nightly jobs. The configuration for the Red Hat Developer Hub instance is managed using `yaml` config files for the application itself and the plugins in use. Those files are located in `.ibm/pipelines/resources`. These files define essential setup details and configurations specific to each test instance, ultimately determining the precise environment for the RHDH deployment.
133+
134+
Additionally, a **test runner** based on a custom Docker image (defined in [this Dockerfile](https://github.com/janus-idp/backstage-showcase/blob/main/.ibm/images/Dockerfile)) is set up as part of the environment. This runner helps standardize the testing environment and provides the necessary dependencies for test execution.
135+
136+
The OpenShift CI definitions for PR checks and nightly runs, as well as execution of `openshift-ci-tests.sh`, are managed here:
137+
138+
- [PR checks and nightly job definitions](https://github.com/openshift/release/tree/master/ci-operator/jobs/janus-idp/backstage-showcase)
139+
- [Configuration definitions](https://github.com/openshift/release/tree/master/ci-operator/config/janus-idp/backstage-showcase)
140+
- [Step registry for job execution](https://github.com/openshift/release/tree/master/ci-operator/step-registry/janus-idp/backstage-showcase)
141+
142+
- **Environment Preparation:** Sets up clusters and namespaces based on job requirements.
143+
- **Deployment:** Deploys RHDH instances using Helm charts.
144+
- **Testing:** Runs end-to-end tests with Playwright.
145+
- **Cleanup and Reporting:** Cleans up resources and collects artifacts after testing.
146+
147+
Detailed steps on how the tests and reports are managed can be found in the `run_tests()` function within the `openshift-ci-tests.sh` script. Additionally, all the different `yarn` commands that trigger various Playwright projects are described in the `package.json` file.
148+
149+
When the test run is complete, the status will be reported under your PR checks.
150+
151+
> **Important:** The environment in which the PR tests are executed is shared and ephemeral. All PR tests queue for the same environment, which is destroyed and recreated for each PR. Test outputs (screenshots, recordings, walkthroughs, etc.) are stored for a retention period of **6 months** and can be accessed by checking the **Details -> Artifacts** of the test check on the PR.
152+
153+
### Automated Steps
154+
155+
- **Environment Setup:**
156+
- **PR Tests:** Ephemeral environments are automatically created and destroyed per test run.
157+
- **Nightly Tests:** Use long-running clusters with automated updates, including multiple OCP versions (usually the current and the previous two).
158+
- **Deployment:**
159+
- RHDH instances are deployed using automated scripts and Helm charts.
160+
- **Test Execution:**
161+
- Tests are executed using `yarn` scripts defined in `package.json`.
162+
- **Cleanup:**
163+
- The script cleans up all temporary resources after tests.
164+
- **Reporting:**
165+
- Generates reports and stores artifacts for **6 months**.
166+
- Nightly test results are posted to Slack channel `#rhdh-e2e-test-alerts`.
167+
168+
### Configuration Details
169+
170+
- **Environment Variables and Secrets:**
171+
Stored securely in the **OpenShift-CI Vault** and accessed during runtime. Members of the organization can ask its peers for details about where and how to access this information.
172+
- **Cluster Credentials:**
173+
The script sets cluster URLs, tokens, and selects the appropriate OCP version based on job requirements.
174+
- **Namespace and Resource Management:**
175+
Handles creation and deletion of namespaces and applies necessary Kubernetes resources.
176+
- **Dependency Management:**
177+
Installs required tools like `oc`, `kubectl`, and `helm` if not already available.

0 commit comments

Comments
 (0)