Skip to content

Commit c21a892

Browse files
gustavoliraclaude
andcommitted
feat(rhdh): add rerun-failed-tests CI job configuration
Add CI configuration for the new `/test rerun-failed-tests` command that re-executes only tests that failed in the previous e2e-ocp-helm run. New step registry: - ci-operator/step-registry/redhat-developer/rhdh/ocp/rerun-failed-tests/ New test configuration in redhat-developer-rhdh-main.yaml: - as: rerun-failed-tests - optional: true (manually triggered via /test rerun-failed-tests) - Uses cluster_claim with OCP 4.18 on AWS This PR depends on: redhat-developer/rhdh#4037 Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 90375d2 commit c21a892

File tree

4 files changed

+243
-0
lines changed

4 files changed

+243
-0
lines changed

ci-operator/config/redhat-developer/rhdh/redhat-developer-rhdh-main.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ tests:
3838
test:
3939
- ref: redhat-developer-rhdh-ocp-helm
4040
workflow: generic-claim
41+
- always_run: false
42+
as: rerun-failed-tests
43+
cluster_claim:
44+
architecture: amd64
45+
cloud: aws
46+
labels:
47+
region: us-east-2
48+
owner: rhdh
49+
product: ocp
50+
timeout: 1h0m0s
51+
version: "4.18"
52+
optional: true
53+
steps:
54+
post:
55+
- ref: redhat-developer-rhdh-send-data-router
56+
- chain: gather
57+
test:
58+
- ref: redhat-developer-rhdh-ocp-rerun-failed-tests
59+
workflow: generic-claim
4160
- always_run: false
4261
as: e2e-ocp-helm-nightly
4362
cluster_claim:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# DO NOT EDIT; this file is auto-generated using https://github.com/openshift/ci-tools.
2+
# Fetched from https://github.com/redhat-developer/rhdh root OWNERS
3+
# If the repo had OWNERS_ALIASES then the aliases were expanded
4+
# Logins who are not members of 'openshift' organization were filtered out
5+
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md
6+
7+
approvers:
8+
- josephca
9+
- subhashkhileri
10+
- gustavolira
11+
- zdrapela
12+
options: {}
13+
reviewers:
14+
- albarbaro
15+
- josephca
16+
- subhashkhileri
17+
- gustavolira
18+
- zdrapela
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/bin/bash
2+
3+
echo "========== Repository, Branch, and PR Variables =========="
4+
GITHUB_ORG_NAME="redhat-developer"
5+
echo "GITHUB_ORG_NAME: $GITHUB_ORG_NAME"
6+
GITHUB_REPOSITORY_NAME="rhdh"
7+
echo "GITHUB_REPOSITORY_NAME: $GITHUB_REPOSITORY_NAME"
8+
RELEASE_BRANCH_NAME=$(echo "${JOB_SPEC}" | jq -r '.extra_refs[].base_ref' 2>/dev/null || echo "${JOB_SPEC}" | jq -r '.refs.base_ref')
9+
echo "RELEASE_BRANCH_NAME: $RELEASE_BRANCH_NAME"
10+
GIT_PR_NUMBER=$(echo "${JOB_SPEC}" | jq -r '.refs.pulls[0].number')
11+
echo "GIT_PR_NUMBER: $GIT_PR_NUMBER"
12+
TAG_NAME=""
13+
export GITHUB_ORG_NAME GITHUB_REPOSITORY_NAME RELEASE_BRANCH_NAME GIT_PR_NUMBER TAG_NAME
14+
15+
# Export PR number for the rerun-failed-tests script
16+
export PULL_NUMBER="${GIT_PR_NUMBER}"
17+
export REPO_OWNER="${GITHUB_ORG_NAME}"
18+
export REPO_NAME="${GITHUB_REPOSITORY_NAME}"
19+
20+
echo "========== Workdir Setup =========="
21+
export HOME WORKSPACE
22+
HOME=/tmp
23+
WORKSPACE=$(pwd)
24+
cd /tmp || exit
25+
26+
echo "========== Cluster Authentication =========="
27+
export OPENSHIFT_PASSWORD
28+
export OPENSHIFT_API
29+
export OPENSHIFT_USERNAME
30+
31+
OPENSHIFT_API="$(yq e '.clusters[0].cluster.server' "$KUBECONFIG")"
32+
OPENSHIFT_USERNAME="kubeadmin"
33+
34+
yq -i 'del(.clusters[].cluster.certificate-authority-data) | .clusters[].cluster.insecure-skip-tls-verify=true' "$KUBECONFIG"
35+
if [[ -s "$KUBEADMIN_PASSWORD_FILE" ]]; then
36+
OPENSHIFT_PASSWORD="$(cat "$KUBEADMIN_PASSWORD_FILE")"
37+
elif [[ -s "${SHARED_DIR}/kubeadmin-password" ]]; then
38+
# Recommendation from hypershift qe team in slack channel..
39+
OPENSHIFT_PASSWORD="$(cat "${SHARED_DIR}/kubeadmin-password")"
40+
else
41+
echo "Kubeadmin password file is empty... Aborting job"
42+
exit 1
43+
fi
44+
45+
timeout --foreground 5m bash <<-"EOF"
46+
while ! oc login "$OPENSHIFT_API" -u "$OPENSHIFT_USERNAME" -p "$OPENSHIFT_PASSWORD" --insecure-skip-tls-verify=true; do
47+
sleep 20
48+
done
49+
EOF
50+
if [ $? -ne 0 ]; then
51+
echo "Timed out waiting for login"
52+
exit 1
53+
fi
54+
55+
echo "========== Cluster Service Account and Token Management =========="
56+
export K8S_CLUSTER_URL K8S_CLUSTER_TOKEN
57+
K8S_CLUSTER_URL=$(oc whoami --show-server)
58+
echo "K8S_CLUSTER_URL: $K8S_CLUSTER_URL"
59+
60+
echo "Note: This cluster will be automatically deleted 4 hours after being claimed."
61+
echo "To debug issues or log in to the cluster manually, use the script: .ibm/pipelines/ocp-cluster-claim-login.sh"
62+
63+
oc create serviceaccount tester-sa-2 -n default
64+
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:default:tester-sa-2
65+
K8S_CLUSTER_TOKEN=$(oc create token tester-sa-2 -n default --duration=4h)
66+
67+
echo "========== Platform Environment Variables =========="
68+
echo "Setting platform environment variables:"
69+
export IS_OPENSHIFT="true"
70+
echo "IS_OPENSHIFT=${IS_OPENSHIFT}"
71+
export CONTAINER_PLATFORM="ocp"
72+
echo "CONTAINER_PLATFORM=${CONTAINER_PLATFORM}"
73+
echo "Getting container platform version"
74+
CONTAINER_PLATFORM_VERSION=$(oc version --output json 2> /dev/null | jq -r '.openshiftVersion' | cut -d'.' -f1,2 || echo "unknown")
75+
export CONTAINER_PLATFORM_VERSION
76+
echo "CONTAINER_PLATFORM_VERSION=${CONTAINER_PLATFORM_VERSION}"
77+
78+
echo "========== Cluster kubeadmin logout =========="
79+
oc logout
80+
81+
echo "========== Git Repository Setup & Checkout =========="
82+
QUAY_REPO="rhdh-community/rhdh"
83+
export QUAY_REPO
84+
85+
# Clone and checkout the specific PR
86+
git clone "https://github.com/${GITHUB_ORG_NAME}/${GITHUB_REPOSITORY_NAME}.git"
87+
cd "${GITHUB_REPOSITORY_NAME}" || exit
88+
git checkout "$RELEASE_BRANCH_NAME" || exit
89+
90+
git config --global user.name "rhdh-qe"
91+
git config --global user.email "[email protected]"
92+
93+
echo "========== PR Branch Handling =========="
94+
if [ "$JOB_TYPE" == "presubmit" ] && [[ "$JOB_NAME" != rehearse-* ]]; then
95+
# If executed as PR check of the repository, switch to PR branch.
96+
git fetch origin pull/"${GIT_PR_NUMBER}"/head:PR"${GIT_PR_NUMBER}"
97+
git checkout PR"${GIT_PR_NUMBER}"
98+
git merge origin/$RELEASE_BRANCH_NAME --no-edit
99+
GIT_PR_RESPONSE=$(curl -s "https://api.github.com/repos/${GITHUB_ORG_NAME}/${GITHUB_REPOSITORY_NAME}/pulls/${GIT_PR_NUMBER}")
100+
LONG_SHA=$(echo "$GIT_PR_RESPONSE" | jq -r '.head.sha')
101+
SHORT_SHA=$(git rev-parse --short=8 ${LONG_SHA})
102+
TAG_NAME="pr-${GIT_PR_NUMBER}-${SHORT_SHA}"
103+
echo "TAG_NAME: $TAG_NAME"
104+
IMAGE_NAME="${QUAY_REPO}:${TAG_NAME}"
105+
echo "IMAGE_NAME: $IMAGE_NAME"
106+
fi
107+
108+
echo "========== Changeset Analysis =========="
109+
PR_CHANGESET=$(git diff --name-only $RELEASE_BRANCH_NAME)
110+
echo "Changeset: $PR_CHANGESET"
111+
112+
# Check if changes are exclusively within the specified directories
113+
DIRECTORIES_TO_CHECK=".ibm|e2e-tests|docs|.claude|.cursor|.rulesync|.vscode"
114+
ONLY_IN_DIRS=true
115+
116+
for change in $PR_CHANGESET; do
117+
# Check if the change is not within the specified directories
118+
if ! echo "$change" | grep -qE "^($DIRECTORIES_TO_CHECK)/"; then
119+
ONLY_IN_DIRS=false
120+
break
121+
fi
122+
done
123+
124+
echo "ONLY_IN_DIRS: $ONLY_IN_DIRS"
125+
126+
echo "========== Image Tag Resolution =========="
127+
if [[ "$JOB_NAME" == rehearse-* || "$JOB_TYPE" == "periodic" ]]; then
128+
QUAY_REPO="rhdh/rhdh-hub-rhel9"
129+
if [ "${RELEASE_BRANCH_NAME}" != "main" ]; then
130+
# Get branch a specific tag name (e.g., 'release-1.5' becomes '1.5')
131+
TAG_NAME="$(echo $RELEASE_BRANCH_NAME | cut -d'-' -f2)"
132+
else
133+
TAG_NAME="next"
134+
fi
135+
echo "TAG_NAME: $TAG_NAME"
136+
elif [[ "$ONLY_IN_DIRS" == "true" && "$JOB_TYPE" == "presubmit" ]];then
137+
if [ "${RELEASE_BRANCH_NAME}" != "main" ]; then
138+
QUAY_REPO="rhdh/rhdh-hub-rhel9"
139+
# Get branch a specific tag name (e.g., 'release-1.5' becomes '1.5')
140+
TAG_NAME="$(echo $RELEASE_BRANCH_NAME | cut -d'-' -f2)"
141+
else
142+
QUAY_REPO="rhdh-community/rhdh"
143+
TAG_NAME="next"
144+
fi
145+
echo "INFO: Bypassing PR image build wait, using tag: ${TAG_NAME}"
146+
echo "INFO: Container image will be tagged as: ${QUAY_REPO}:${TAG_NAME}"
147+
else
148+
echo "Waiting for Docker image availability..."
149+
# Timeout configuration for waiting for Docker image availability
150+
MAX_WAIT_TIME_SECONDS=$((80*60)) # Maximum wait time: 1 hour 20 minutes
151+
POLL_INTERVAL_SECONDS=60 # Check every 60 seconds
152+
153+
ELAPSED_TIME=0
154+
155+
while true; do
156+
# Check image availability
157+
response=$(curl -s "https://quay.io/api/v1/repository/${QUAY_REPO}/tag/?specificTag=$TAG_NAME")
158+
159+
# Use jq to parse the JSON and see if the tag exists
160+
tag_count=$(echo $response | jq '.tags | length')
161+
162+
if [ "$tag_count" -gt "0" ]; then
163+
echo "Docker image $IMAGE_NAME is now available. Time elapsed: $(($ELAPSED_TIME / 60)) minute(s)."
164+
break
165+
fi
166+
167+
# Wait for the interval duration
168+
sleep $POLL_INTERVAL_SECONDS
169+
170+
# Increment the elapsed time
171+
ELAPSED_TIME=$(($ELAPSED_TIME + $POLL_INTERVAL_SECONDS))
172+
173+
# If the elapsed time exceeds the timeout, exit with an error
174+
if [ $ELAPSED_TIME -ge $MAX_WAIT_TIME_SECONDS ]; then
175+
echo "Timed out waiting for Docker image $IMAGE_NAME. Time elapsed: $(($ELAPSED_TIME / 60)) minute(s)."
176+
exit 1
177+
fi
178+
done
179+
fi
180+
181+
echo "========== Current branch =========="
182+
echo "Current branch: $(git branch --show-current)"
183+
echo "Using Image: ${QUAY_REPO}:${TAG_NAME}"
184+
185+
echo "========== Test Execution =========="
186+
echo "Executing openshift-ci-tests.sh for rerun-failed-tests"
187+
bash ./.ibm/pipelines/openshift-ci-tests.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ref:
2+
as: redhat-developer-rhdh-ocp-rerun-failed-tests
3+
cli: latest
4+
commands: "redhat-developer-rhdh-ocp-rerun-failed-tests-commands.sh"
5+
credentials:
6+
- mount_path: /tmp/secrets
7+
name: rhdh
8+
namespace: test-credentials
9+
from_image:
10+
name: rhdh-e2e-runner
11+
namespace: ci
12+
tag: main
13+
resources:
14+
limits:
15+
memory: 6Gi
16+
cpu: "2"
17+
requests:
18+
cpu: "2"
19+
memory: 6Gi

0 commit comments

Comments
 (0)