Skip to content

Commit 810cad6

Browse files
local test runner
1 parent 67d1b7b commit 810cad6

File tree

7 files changed

+1028
-7
lines changed

7 files changed

+1028
-7
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: 34 additions & 4 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"; }
@@ -666,8 +666,7 @@ deploy_test_backstage_customization_provider() {
666666
# Check if the buildconfig already exists
667667
if ! oc get buildconfig test-backstage-customization-provider -n "${project}" > /dev/null 2>&1; then
668668
log::info "Creating new app for test-backstage-customization-provider"
669-
oc new-app -S openshift/nodejs:18-minimal-ubi8
670-
oc new-app https://github.com/janus-qe/test-backstage-customization-provider --image-stream="openshift/nodejs:18-ubi8" --namespace="${project}"
669+
oc new-app openshift/nodejs:18-ubi8~https://github.com/janus-qe/test-backstage-customization-provider --namespace="${project}"
671670
else
672671
log::warn "BuildConfig for test-backstage-customization-provider already exists in ${project}. Skipping new-app creation."
673672
fi
@@ -826,6 +825,33 @@ check_backstage_running() {
826825
else
827826
log::warn "Attempt ${i} of ${max_attempts}: Backstage not yet available (HTTP Status: ${http_status})"
828827
oc get pods -n "${namespace}"
828+
829+
# Early crash detection: fail fast if RHDH pods are in CrashLoopBackOff
830+
# Check both the main deployment and postgresql pods
831+
local crash_pods
832+
crash_pods=$(oc get pods -n "${namespace}" -l "app.kubernetes.io/instance in (${release_name},redhat-developer-hub,developer-hub,${release_name}-postgresql)" \
833+
-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)
834+
# Also check by name pattern for postgresql pods that may have different labels
835+
if [ -z "${crash_pods}" ]; then
836+
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)
837+
fi
838+
839+
if [ -n "${crash_pods}" ]; then
840+
log::error "❌ Detected pods in CrashLoopBackOff state - failing fast instead of waiting:"
841+
echo "${crash_pods}"
842+
log::error "Deployment status:"
843+
oc get deployment -l "app.kubernetes.io/instance in (${release_name},redhat-developer-hub,developer-hub)" -n "${namespace}" -o wide 2> /dev/null || true
844+
log::error "Recent logs from deployment:"
845+
oc logs deployment/${release_name}-developer-hub -n "${namespace}" --tail=100 --all-containers=true 2> /dev/null \
846+
|| oc logs deployment/${release_name} -n "${namespace}" --tail=100 --all-containers=true 2> /dev/null || true
847+
log::error "Recent events:"
848+
oc get events -n "${namespace}" --sort-by='.lastTimestamp' | tail -20
849+
mkdir -p "${ARTIFACT_DIR}/${namespace}"
850+
cp -a "/tmp/${LOGFILE}" "${ARTIFACT_DIR}/${namespace}/" || true
851+
save_all_pod_logs "${namespace}"
852+
return 1
853+
fi
854+
829855
sleep "${wait_seconds}"
830856
fi
831857
done
@@ -1262,7 +1288,11 @@ check_and_test() {
12621288
if check_backstage_running "${release_name}" "${namespace}" "${url}" "${max_attempts}" "${wait_seconds}"; then
12631289
echo "Display pods for verification..."
12641290
oc get pods -n "${namespace}"
1265-
run_tests "${release_name}" "${namespace}" "${playwright_project}" "${url}"
1291+
if [[ "${SKIP_TESTS:-false}" == "true" ]]; then
1292+
log::info "SKIP_TESTS=true, skipping test execution for namespace: ${namespace}"
1293+
else
1294+
run_tests "${release_name}" "${namespace}" "${playwright_project}" "${url}"
1295+
fi
12661296
else
12671297
echo "Backstage is not running. Marking deployment as failed and continuing..."
12681298
CURRENT_DEPLOYMENT=$((CURRENT_DEPLOYMENT + 1))

0 commit comments

Comments
 (0)