Skip to content

Commit c029f80

Browse files
committed
ci: gzip junit results in SHARED_DIR to avoid Secret size limit
Gzip junit XML before writing to SHARED_DIR to stay under the Kubernetes Secret 1 MiB size limit. Raw junit XML can exceed this when coverage <property> tags and many test cases are present. XML compresses ~10-15x with gzip, keeping even large files well under the limit. Also adds a safety check that removes the gzipped file if it still exceeds 800 KB after compression, and validates the source file exists before attempting the copy. The data-router step in openshift/release already handles both .gz and plain .xml formats (openshift/release#81313). Assisted-by: OpenCode
1 parent 5c7ffe3 commit c029f80

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.ci/pipelines/lib/testing.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,18 @@ testing::run_tests() {
107107
# Use artifacts_subdir for artifact directory to keep artifacts organized
108108
common::save_artifact "${artifacts_subdir}" "${e2e_tests_dir}/test-results/" "test-results" || true
109109
common::save_artifact "${artifacts_subdir}" "${e2e_tests_dir}/${JUNIT_RESULTS}" || true
110-
if [[ "${CI}" == "true" ]]; then
111-
rsync "${ARTIFACT_DIR}/${artifacts_subdir}/${JUNIT_RESULTS}" "${SHARED_DIR}/junit-results-${artifacts_subdir}.xml" || true
110+
if [[ "${CI}" == "true" && -f "${ARTIFACT_DIR}/${artifacts_subdir}/${JUNIT_RESULTS}" ]]; then
111+
# Gzip junit before writing to SHARED_DIR to stay under Kubernetes Secret 1 MiB limit
112+
gzip -c "${ARTIFACT_DIR}/${artifacts_subdir}/${JUNIT_RESULTS}" > "${SHARED_DIR}/junit-results-${artifacts_subdir}.xml.gz"
113+
local gz_size
114+
gz_size=$(stat -c%s "${SHARED_DIR}/junit-results-${artifacts_subdir}.xml.gz" 2> /dev/null || stat -f%z "${SHARED_DIR}/junit-results-${artifacts_subdir}.xml.gz")
115+
local max_size=$((800 * 1024))
116+
if ((gz_size > max_size)); then
117+
echo "[WARNING] junit-results-${artifacts_subdir}.xml.gz is $((gz_size / 1024)) KB, exceeds $((max_size / 1024)) KB limit. Removing from SHARED_DIR."
118+
rm -f "${SHARED_DIR}/junit-results-${artifacts_subdir}.xml.gz"
119+
else
120+
echo "[INFO] Copied junit-results-${artifacts_subdir}.xml.gz to SHARED_DIR ($((gz_size / 1024)) KB)"
121+
fi
112122
fi
113123

114124
common::save_artifact "${artifacts_subdir}" "${e2e_tests_dir}/screenshots/" "attachments/screenshots" || true

0 commit comments

Comments
 (0)