Skip to content

Commit ea67e7e

Browse files
subhashkhilericlaudezdrapela
authored
chore: add Local Test Runner support for E2E Tests for RHDH core. (#4023)
* local test runner * fix(pipelines): dynamically select latest nodejs UBI9 image tag Instead of hardcoding nodejs:18-ubi8, query the cluster for available nodejs imagestream tags and select the latest UBI9 version. Falls back to 18-ubi8 if no UBI9 tags are found. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update .ibm/pipelines/utils.sh Co-authored-by: Zbyněk Drápela <61500440+zdrapela@users.noreply.github.com> * feat(e2e-tests): add CLI flags for non-interactive local test runner Add CLI flags (-j, -r, -t, -p, -s) to local-run.sh for automation and quick runs without interactive prompts. Also improve container-init.sh to pre-compute and save config before deployment so URLs are available even if deployment fails. Additional fixes: - Fix secrets parsing in local-test-setup.sh to handle special chars - Minor formatting fix in utils.sh for piped command Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat(e2e-tests): add multi-platform support for AKS, EKS, and GKE Extend local test runner to support non-OpenShift Kubernetes platforms: - Derive CONTAINER_PLATFORM from job name (*aks*, *eks*, *gke*, *osd*) - Add platform-specific cluster login (oc for OCP/OSD, kubectl for others) - Handle service account token creation for non-OpenShift clusters - Update container-init.sh to configure kubectl context for AKS/EKS/GKE - Add interactive menu options for AKS, EKS, GKE job selection - Update help text and examples for multi-platform usage Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Zbyněk Drápela <61500440+zdrapela@users.noreply.github.com>
1 parent 071c52c commit ea67e7e

File tree

7 files changed

+1300
-8
lines changed

7 files changed

+1300
-8
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ dynamic-plugins-root/*
7676
.ibm/pipelines/artifact_dir/*
7777
.ibm/pipelines/env_override.local.sh
7878

79+
# E2E local test runner work directory
80+
e2e-tests/.local-test/
81+
82+
# E2E test artifacts (generated by Playwright)
83+
e2e-tests/playwright-report/
84+
e2e-tests/test-results/
85+
7986
# Python Caches
8087
**/__pycache__/
8188
**/.pytest_cache/

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ source "${DIR}/lib/log.sh"
1515
export OPENSHIFT_CI="${OPENSHIFT_CI:-false}"
1616
if [[ -z "${OPENSHIFT_CI}" || "${OPENSHIFT_CI}" == "false" ]]; then
1717
# NOTE: Use this file to override the environment variables for the local testing.
18-
log::debug "Sourcing env_override.local.sh"
19-
# shellcheck source=.ibm/pipelines/env_override.local.sh
20-
source "${DIR}/env_override.local.sh"
18+
if [[ -f "${DIR}/env_override.local.sh" ]]; then
19+
log::debug "Sourcing env_override.local.sh"
20+
# shellcheck source=.ibm/pipelines/env_override.local.sh
21+
source "${DIR}/env_override.local.sh"
22+
fi
2123
fi
2224

2325
log::debug "Sourcing env_variables.sh"

.ibm/pipelines/utils.sh

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ retrieve_pod_logs() {
99
local pod_name=$1
1010
local container=$2
1111
local namespace=$3
12-
local log_timeout=${4:-30} # Default timeout: 30 seconds
12+
local log_timeout=${4:-5} # Default timeout: 5 seconds (reduced from 30s to speed up failure cases)
1313
log::debug "Retrieving logs for container: $container"
1414
# Save logs for the current and previous container with timeout to prevent hanging
1515
timeout "${log_timeout}" kubectl logs "$pod_name" -c "$container" -n "$namespace" > "pod_logs/${pod_name}_${container}.log" 2> /dev/null || { log::warn "logs for container $container not found or timed out"; }
@@ -680,9 +680,13 @@ deploy_test_backstage_customization_provider() {
680680

681681
# Check if the buildconfig already exists
682682
if ! oc get buildconfig test-backstage-customization-provider -n "${project}" > /dev/null 2>&1; then
683-
log::info "Creating new app for test-backstage-customization-provider"
684-
oc new-app -S openshift/nodejs:18-minimal-ubi8
685-
oc new-app https://github.com/janus-qe/test-backstage-customization-provider --image-stream="openshift/nodejs:18-ubi8" --namespace="${project}"
683+
# Get latest nodejs UBI9 tag from cluster, fallback to 18-ubi8
684+
local nodejs_tag
685+
nodejs_tag=$(oc get imagestream nodejs -n openshift -o jsonpath='{.spec.tags[*].name}' 2> /dev/null \
686+
| tr ' ' '\n' | grep -E '^[0-9]+-ubi9$' | sort -t'-' -k1 -n | tail -1)
687+
nodejs_tag="${nodejs_tag:-18-ubi8}"
688+
log::info "Creating new app for test-backstage-customization-provider using nodejs:${nodejs_tag}"
689+
oc new-app "openshift/nodejs:${nodejs_tag}~https://github.com/janus-qe/test-backstage-customization-provider" --namespace="${project}"
686690
else
687691
log::warn "BuildConfig for test-backstage-customization-provider already exists in ${project}. Skipping new-app creation."
688692
fi
@@ -841,6 +845,33 @@ check_backstage_running() {
841845
else
842846
log::warn "Attempt ${i} of ${max_attempts}: Backstage not yet available (HTTP Status: ${http_status})"
843847
oc get pods -n "${namespace}"
848+
849+
# Early crash detection: fail fast if RHDH pods are in CrashLoopBackOff
850+
# Check both the main deployment and postgresql pods
851+
local crash_pods
852+
crash_pods=$(oc get pods -n "${namespace}" -l "app.kubernetes.io/instance in (${release_name},redhat-developer-hub,developer-hub,${release_name}-postgresql)" \
853+
-o jsonpath='{range .items[*]}{.metadata.name}{" "}{.status.phase}{" "}{range .status.containerStatuses[*]}{.state.waiting.reason}{end}{range .status.initContainerStatuses[*]}{.state.waiting.reason}{end}{"\n"}{end}' 2> /dev/null | grep -E "CrashLoopBackOff" || true)
854+
# Also check by name pattern for postgresql pods that may have different labels
855+
if [ -z "${crash_pods}" ]; then
856+
crash_pods=$(oc get pods -n "${namespace}" --no-headers 2> /dev/null | grep -E "(${release_name}|developer-hub|postgresql)" | grep -E "CrashLoopBackOff|Init:CrashLoopBackOff" || true)
857+
fi
858+
859+
if [ -n "${crash_pods}" ]; then
860+
log::error "Detected pods in CrashLoopBackOff state - failing fast instead of waiting:"
861+
echo "${crash_pods}"
862+
log::error "Deployment status:"
863+
oc get deployment -l "app.kubernetes.io/instance in (${release_name},redhat-developer-hub,developer-hub)" -n "${namespace}" -o wide 2> /dev/null || true
864+
log::error "Recent logs from deployment:"
865+
oc logs deployment/${release_name}-developer-hub -n "${namespace}" --tail=100 --all-containers=true 2> /dev/null \
866+
|| oc logs deployment/${release_name} -n "${namespace}" --tail=100 --all-containers=true 2> /dev/null || true
867+
log::error "Recent events:"
868+
oc get events -n "${namespace}" --sort-by='.lastTimestamp' | tail -20
869+
mkdir -p "${ARTIFACT_DIR}/${namespace}"
870+
cp -a "/tmp/${LOGFILE}" "${ARTIFACT_DIR}/${namespace}/" || true
871+
save_all_pod_logs "${namespace}"
872+
return 1
873+
fi
874+
844875
sleep "${wait_seconds}"
845876
fi
846877
done
@@ -1320,7 +1351,11 @@ check_and_test() {
13201351
if check_backstage_running "${release_name}" "${namespace}" "${url}" "${max_attempts}" "${wait_seconds}"; then
13211352
echo "Display pods for verification..."
13221353
oc get pods -n "${namespace}"
1323-
run_tests "${release_name}" "${namespace}" "${playwright_project}" "${url}"
1354+
if [[ "${SKIP_TESTS:-false}" == "true" ]]; then
1355+
log::info "SKIP_TESTS=true, skipping test execution for namespace: ${namespace}"
1356+
else
1357+
run_tests "${release_name}" "${namespace}" "${playwright_project}" "${url}"
1358+
fi
13241359
else
13251360
echo "Backstage is not running. Marking deployment as failed and continuing..."
13261361
CURRENT_DEPLOYMENT=$((CURRENT_DEPLOYMENT + 1))

0 commit comments

Comments
 (0)