Skip to content

Commit 844f528

Browse files
more e2e test logs (#706)
* Get rid of evals in e2e Signed-off-by: Kevin M Granger <kgranger@redhat.com> * Ignore any .venv*. Useful for mounting within a container, perhaps of a different architecture Signed-off-by: Kevin M Granger <kgranger@redhat.com> * Fix typo in e2e script help * Make helm work without thanos Signed-off-by: Kevin M Granger <kgranger@redhat.com> * try each exporter even if one fails Signed-off-by: Kevin M Granger <kgranger@redhat.com> * Log all pods, not just crashing ones Signed-off-by: Kevin M Granger <kgranger@redhat.com> * Use banners for log sections instead of ASCII separators Signed-off-by: Kevin M Granger <kgranger@redhat.com> * Fix thanos helm flag when set Signed-off-by: Kevin M Granger <kgranger@redhat.com> Signed-off-by: Kevin M Granger <kgranger@redhat.com>
1 parent d1a2046 commit 844f528

2 files changed

Lines changed: 36 additions & 15 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ target/
8181
#Pipfile.lock
8282

8383
# Python virtualenv
84-
.venv
84+
/.venv*
8585

8686
# celery beat schedule file
8787
celerybeat-schedule

scripts/run-pelorus-e2e-tests

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function download_file_from_url() {
5454
# Function to safely remove temporary files and temporary download dir
5555
# Argument is optional exit value to propagate it after cleanup
5656
function cleanup_and_exit() {
57+
echo "===== Cleaning up and exiting ====="
5758
local exit_val=$1
5859
if [ -z "${DWN_DIR}" ]; then
5960
echo "cleanup_and_exit(): Temp download dir not provided !" >&2
@@ -63,16 +64,15 @@ function cleanup_and_exit() {
6364
PELORUS_TMP_DIR=$(basename "${DWN_DIR}")
6465
if [[ "${PELORUS_TMP_DIR}" =~ "${TMP_DIR_PREFIX}"* ]]; then
6566
echo "Cleaning up temporary files"
66-
eval rm -f "${DWN_DIR}/*"
67-
rmdir "${DWN_DIR}"
67+
rm -rf "${DWN_DIR}"
6868
fi
6969
fi
7070
fi
71-
# Show logs from pods which are in CrashLoopBackOff state
72-
for failing_pod in $(oc get pods -n "${PELORUS_NAMESPACE}" | grep -i crash | cut -d ' ' -f1);
73-
do
74-
echo "Logs from crashed pod: ${failing_pod}"
75-
oc logs -n "${PELORUS_NAMESPACE}" "${failing_pod}"
71+
# Show logs from all pods.
72+
echo "===== Pod Logs ====="
73+
for pod in $(oc get pods -n "${PELORUS_NAMESPACE}" -o name); do
74+
echo "----- Logs from ${pod} -----"
75+
oc logs -n "${PELORUS_NAMESPACE}" --all-containers "${pod}"
7676
done
7777

7878
# Cleanup binary builds
@@ -96,7 +96,7 @@ function retry() {
9696
}
9797

9898
function print_help() {
99-
printf "\nUsage: %s [OPTION]... -d [DIR]\n\n" % "$0"
99+
printf "\nUsage: %s [OPTION]... -d [DIR]\n\n" "$0"
100100
printf "\tStartup:\n"
101101
printf "\t -h\tprint this help\n"
102102
printf "\n\tOptions:\n"
@@ -191,6 +191,9 @@ fi
191191

192192

193193
### MAIN
194+
195+
echo "===== 1. Set up deployment ====="
196+
194197
# Create download directory
195198
DWN_DIR=$(TMPDIR="${VENV}" mktemp -d -t "${TMP_DIR_PREFIX}XXXXX") || exit 2
196199

@@ -479,6 +482,8 @@ if [ "${ENABLE_JIRA_CUSTOM_FAIL_EXP}" == true ]; then
479482
fi
480483
fi
481484

485+
echo "===== 2. Set up OpenShift resources ====="
486+
482487
# We do check for the exit status, as we are not really interested in the
483488
# current state, e.g. Active of that namespace before deleting resources.
484489
if oc get namespace mongo-persistent 2>/dev/null; then
@@ -527,16 +532,16 @@ retry 5m 5s ogns prometheus-pelorus
527532
cat "${DWN_DIR}/ci_values.yaml"
528533

529534
# Thanos and s3 support
530-
THANOS_HELM_FLAG=""
535+
THANOS_HELM_FLAG=() # an array so expanding it later will be 0 words if empty
531536
if [ "${ENABLE_THANOS}" == true ]; then
532537
echo "Enabling Thanos support"
533538
thanos_config_file=$(create_s3_thanos_config s3_host s3_bucket s3_access_key s3_secret_key)
534-
THANOS_HELM_FLAG=" --values ${thanos_config_file}"
535-
echo "${THANOS_HELM_FLAG}"
539+
THANOS_HELM_FLAG=("--values" "${thanos_config_file}")
536540
fi
537541

538542
# update exporter values and helm upgrade
539-
eval helm upgrade pelorus charts/pelorus --namespace pelorus --values "${DWN_DIR}/ci_values.yaml" "${THANOS_HELM_FLAG}"
543+
echo helm upgrade pelorus charts/pelorus --namespace pelorus --values "${DWN_DIR}/ci_values.yaml" "${THANOS_HELM_FLAG[@]}"
544+
helm upgrade pelorus charts/pelorus --namespace pelorus --values "${DWN_DIR}/ci_values.yaml" "${THANOS_HELM_FLAG[@]}"
540545

541546
retry 10m 5s owpr deploytime
542547
retry 10m 5s owpr committime
@@ -547,15 +552,31 @@ retry 2m 5s oc wait pod --for=condition=Ready -n mongo-persistent -l app=mongo
547552
retry 10m 10s oc wait pod --for=condition=Ready -n mongo-persistent -l app=todolist
548553

549554
# Test all deployed exporters
555+
556+
echo "===== 3. Test Exporters ====="
557+
558+
any_exporter_failed=""
550559
exporters=$(oc get route -n "${PELORUS_NAMESPACE}"|grep "-exporter")
551560
echo "$exporters"
552561
for exporter_route in $(echo "$exporters" | awk '{print $2}');
553562
do
554563
echo "$exporter_route"
555-
curl "$exporter_route"
556-
curl "$exporter_route" 2>&1 | grep todolist || exit 2
564+
route_output="$(curl "$exporter_route")"
565+
curl_result=$?
566+
echo "$route_output"
567+
if [[ $curl_result -ne 0 ]]; then
568+
echo "Error curling $exporter_route" 1>&2
569+
any_exporter_failed=true
570+
elif ! { echo "$route_output" | grep todolist; }; then
571+
echo "todolist not found in $exporter_route" 1>&2
572+
any_exporter_failed=true
573+
fi
557574
done
558575

576+
if [[ "$any_exporter_failed" = "true" ]]; then
577+
exit 2
578+
fi
579+
559580
if oc get pods -n pelorus | grep -q Crash ; then
560581
echo "Some pods are not functioning properly"
561582
oc get pods -n pelorus

0 commit comments

Comments
 (0)