Skip to content

Commit 9d24054

Browse files
Merge remote-tracking branch 'remotes/from/ce/main'
2 parents 3059cb6 + 75e9eaf commit 9d24054

5 files changed

Lines changed: 165 additions & 43 deletions

File tree

.github/workflows/build.yml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,48 @@ jobs:
731731
fi
732732
- id: slackbot-webhook-url
733733
run:
734-
echo "slackbot-webhook-url=${{ needs.setup.outputs.is-ent-repo != 'true' && secrets.FEED_VAULT_CI_OFFICIAL_WEBHOOK_URL || steps.secrets.outputs.slackbot-webhook-url }}" >> "$GITHUB_OUTPUT"
734+
echo "slackbot-webhook-url=${{ needs.setup.outputs.is-ent-repo != 'true' && secrets.FEED_VAULT_CI_OFFICIAL_WEBHOOK_URL || steps.secrets.outputs.slackbot-webhook-url }}" | tee -a "$GITHUB_OUTPUT"
735735
- if: ${{ needs.setup.outputs.is-fork == 'false' }}
736-
name: Download failure summaries
736+
name: Download test results tarballs
737737
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
738738
with:
739-
pattern: failure-summary-*.md
740-
path: failure-summaries
739+
pattern: test-results_*.tar.gz
740+
path: test-results-tarballs
741741
merge-multiple: true
742+
- if: ${{ needs.setup.outputs.is-fork == 'false' }}
743+
name: Extract test results and failure summaries
744+
run: |
745+
mkdir -p failure-summaries
746+
extraction_errors=0
747+
748+
if [ -d "test-results-tarballs" ]; then
749+
for tarball in test-results-tarballs/*.tar.gz; do
750+
if [ -f "$tarball" ]; then
751+
temp_extract_dir=$(mktemp -d)
752+
753+
# Extract tarball with error checking
754+
if ! tar -xzf "$tarball" -C "$temp_extract_dir"; then
755+
echo "::error file=$(basename "$tarball")::Failed to extract tarball"
756+
extraction_errors=$((extraction_errors + 1))
757+
rm -rf "$temp_extract_dir"
758+
continue
759+
fi
760+
761+
# Copy failure summaries if they exist
762+
if [ -d "$temp_extract_dir/failure_summary" ]; then
763+
if ls "$temp_extract_dir/failure_summary"/*.md &>/dev/null; then
764+
cp "$temp_extract_dir/failure_summary"/*.md failure-summaries/
765+
fi
766+
fi
767+
768+
rm -rf "$temp_extract_dir"
769+
fi
770+
done
771+
772+
if [ $extraction_errors -gt 0 ]; then
773+
echo "::error::Failed to extract $extraction_errors tarball(s)"
774+
fi
775+
fi
742776
- if: ${{ needs.setup.outputs.is-fork == 'false' }}
743777
id: prepare-failure-summary
744778
name: Prepare failure summary

.github/workflows/test-run-enos-scenario-matrix.yml

Lines changed: 63 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -342,43 +342,17 @@ jobs:
342342
if-no-files-found: ignore
343343
continue-on-error: true
344344

345-
- name: Upload Test Results
345+
- name: Prepare Test Results and Failure Summaries
346346
if: always()
347-
id: upload_test_results
348-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
349-
with:
350-
name: ${{ steps.prepare_scenario.outputs.test_results_artifact_name }}
351-
path: /tmp/vault_test_results_*.json
352-
retention-days: 7
353-
if-no-files-found: ignore
354-
continue-on-error: true
355-
356-
- name: Upload JUnit Test Results
357-
if: always()
358-
id: upload_junit_results
359-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
360-
with:
361-
name: ${{ steps.prepare_scenario.outputs.junit_results_artifact_name }}
362-
path: /tmp/vault_test_results_*.xml
363-
retention-days: 7
364-
if-no-files-found: ignore
365-
continue-on-error: true
366-
367-
- name: Check for test results
368-
if: always()
369-
id: check_test_results
347+
id: prepare_test_summary
370348
continue-on-error: true
371349
run: |
372-
if find /tmp -maxdepth 1 -name 'vault_test_results_*.json' -type f -print -quit 2>/dev/null | grep -q .; then
373-
echo "has_results=true" >> "$GITHUB_OUTPUT"
374-
else
375-
echo "has_results=false" >> "$GITHUB_OUTPUT"
350+
if ! find /tmp -maxdepth 1 -name 'vault_test_results_*.json' -type f -print -quit 2>/dev/null | grep -q .; then
351+
echo "failure_summary_created=false" | tee -a "$GITHUB_OUTPUT"
352+
echo "::warning::No test results found in /tmp/vault_test_results_*.json"
353+
exit 0
376354
fi
377355
378-
- name: Prepare Test Results Summary
379-
if: always() && steps.check_test_results.outputs.has_results == 'true'
380-
continue-on-error: true
381-
run: |
382356
# Find the most recent JSON test results file
383357
json_file=$(find /tmp -maxdepth 1 -name 'vault_test_results_*.json' -type f -printf '%T@ %p\n' 2>/dev/null | sort -rn | head -n1 | cut -d' ' -f2-)
384358
@@ -396,6 +370,9 @@ jobs:
396370
passed_tests=$(jq -r 'select(.Action == "pass") | select(.Test != null)' "$json_file" | jq -s 'length')
397371
failed_tests=$(jq -r 'select(.Action == "fail") | select(.Test != null)' "$json_file" | jq -s 'length')
398372
373+
# Output for use in tarball creation
374+
echo "failure_summary_created=true" | tee -a "$GITHUB_OUTPUT"
375+
399376
# Create step summary for this specific scenario
400377
{
401378
echo "## Test Results for ${{ matrix.scenario.id.filter }}"
@@ -414,19 +391,66 @@ jobs:
414391
cat "${failure_summary_file}"
415392
echo ""
416393
fi
394+
} | tee -a "$GITHUB_STEP_SUMMARY"
395+
else
396+
echo "failure_summary_created=false" | tee -a "$GITHUB_OUTPUT"
397+
fi
398+
399+
- name: Create test results tarball
400+
if: always()
401+
id: create_test_results_tarball
402+
continue-on-error: true
403+
run: |
404+
mkdir -p /tmp/test-artifacts/test_results
405+
mkdir -p /tmp/test-artifacts/junit_results
406+
mkdir -p /tmp/test-artifacts/failure_summary
417407
418-
echo "📊 Full test results available in artifacts: \`${{ steps.prepare_scenario.outputs.test_results_artifact_name }}\`"
419-
} >> "$GITHUB_STEP_SUMMARY"
408+
if ls /tmp/vault_test_results_*.json 1> /dev/null 2>&1; then
409+
cp /tmp/vault_test_results_*.json /tmp/test-artifacts/test_results/
410+
fi
411+
412+
if ls /tmp/vault_test_results_*.xml 1> /dev/null 2>&1; then
413+
cp /tmp/vault_test_results_*.xml /tmp/test-artifacts/junit_results/
414+
fi
415+
416+
failure_summary_file="${{ steps.prepare_scenario.outputs.failure_summary_artifact_name }}"
417+
if [ "${{ steps.prepare_test_summary.outputs.failure_summary_created }}" == "true" ] && [ -f "$failure_summary_file" ]; then
418+
cp "$failure_summary_file" /tmp/test-artifacts/failure_summary/
419+
fi
420+
421+
if [ -n "$(ls -A /tmp/test-artifacts/test_results 2>/dev/null)" ] || \
422+
[ -n "$(ls -A /tmp/test-artifacts/junit_results 2>/dev/null)" ] || \
423+
[ -n "$(ls -A /tmp/test-artifacts/failure_summary 2>/dev/null)" ]; then
424+
scenario_safe_name=$(echo "${{ matrix.scenario.id.filter }}" | sed -e 's/ /_/g' | sed -e 's/:/=/g')
425+
# Truncate to 215 chars to leave room for .tar.gz suffix and buffer
426+
tarball_name="test-results_${scenario_safe_name:0:215}.tar.gz"
427+
428+
if tar -czf "/tmp/${tarball_name}" -C /tmp/test-artifacts .; then
429+
{
430+
echo "tarball_created=true"
431+
echo "tarball_name=${tarball_name}"
432+
echo "tarball_path=/tmp/${tarball_name}"
433+
} | tee -a "$GITHUB_OUTPUT"
434+
435+
# Add artifact reference to step summary
436+
echo "" | tee -a "$GITHUB_STEP_SUMMARY"
437+
echo "Full test results available in artifact: \`${tarball_name}\`" | tee -a "$GITHUB_STEP_SUMMARY"
438+
else
439+
echo "::error::Failed to create tarball"
440+
echo "tarball_created=false" | tee -a "$GITHUB_OUTPUT"
441+
fi
420442
else
421-
echo "⚠️ No test results found in /tmp/vault_test_results_*.json" >> "$GITHUB_STEP_SUMMARY"
443+
echo "tarball_created=false" | tee -a "$GITHUB_OUTPUT"
422444
fi
423445
424-
- name: Upload Failure Summary
425-
if: always() && steps.check_test_results.outputs.has_results == 'true'
446+
- name: Upload test results tarball
447+
if: always() && steps.create_test_results_tarball.outputs.tarball_created == 'true'
448+
id: upload_test_results_tarball
426449
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
427450
with:
428-
name: ${{ steps.prepare_scenario.outputs.failure_summary_artifact_name }}
429-
path: ${{ steps.prepare_scenario.outputs.failure_summary_artifact_name }}
451+
name: ${{ steps.create_test_results_tarball.outputs.tarball_name }}
452+
path: ${{ steps.create_test_results_tarball.outputs.tarball_path }}
453+
retention-days: 7
430454
if-no-files-found: ignore
431455
continue-on-error: true
432456

enos/modules/vault_run_blackbox_test/main.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,10 @@ locals {
135135
tonumber(regex("TEST_EXIT_CODE=(.+)", enos_local_exec.run_blackbox_test.stdout)[0]),
136136
null
137137
)
138+
# The script emits BLACKBOX_TEST_CMD=<base64> so the multi-line command
139+
# can survive regex extraction. base64decode() restores the pretty string.
140+
blackbox_test_cmd = try(
141+
base64decode(regex("BLACKBOX_TEST_CMD=(.+)", enos_local_exec.run_blackbox_test.stdout)[0]),
142+
""
143+
)
138144
}

enos/modules/vault_run_blackbox_test/outputs.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ output "test_results_summary" {
1818
test_package = var.test_package
1919
}
2020
}
21+
22+
output "blackbox_test_cmd" {
23+
description = <<-EOT
24+
The equivalent standalone go test command for this blackbox test run.
25+
Copy and paste this into a terminal to reproduce the test outside of Enos.
26+
Run with: enos scenario output <scenario> <filter> | jq -r '.blackbox_test_cmd.value'
27+
EOT
28+
value = local.blackbox_test_cmd
29+
}

enos/modules/vault_run_blackbox_test/scripts/run-test.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ else
229229
fi
230230

231231
# Also output human-readable results to stdout
232+
echo ""
232233
echo "=== TEST EXECUTION SUMMARY ==="
233234
if [ $test_exit_code -eq 0 ]; then
234235
echo "✅ Tests PASSED"
@@ -237,6 +238,7 @@ else
237238
fi
238239

239240
# Parse JSON results and create a summary
241+
echo ""
240242
echo "=== DETAILED RESULTS ==="
241243
if [ -f "$json_output" ] && [ -s "$json_output" ]; then
242244
if command -v jq &> /dev/null; then
@@ -272,6 +274,53 @@ if [ -f "$json_output" ] && [ -s "$json_output" ]; then
272274
echo "JSON_RESULTS_FILE=$json_output"
273275
fi
274276

277+
# Print the equivalent standalone go test command so it can be copied and run outside of Enos.
278+
# Each env var is printed on its own line with a trailing backslash so the whole block
279+
# can be selected and pasted directly into a terminal.
280+
#
281+
# Env vars included:
282+
# - All VAULT_* except enos-internal plumbing (VAULT_TEST_*, VAULT_ADDR_DEBUG)
283+
# - Integration vars (LDAP_*, PG*, POSTGRES_*, MONGO_*)
284+
# - Verify-test scalars (EXPECTED_STATE, TIMEOUT_SECONDS, RETRY_INTERVAL, DEFAULT_LCQ)
285+
286+
# Collect relevant env vars, one per line, redacting secrets
287+
mapfile -t env_lines < <(env \
288+
| grep -E '^(VAULT_|LDAP_|PG|POSTGRES_|MONGO_|EXPECTED_STATE=|TIMEOUT_SECONDS=|RETRY_INTERVAL=|DEFAULT_LCQ=)' \
289+
| grep -v -E '^(VAULT_TEST_|VAULT_ADDR_DEBUG=)' \
290+
| sed 's/^\(VAULT_TOKEN=\).*/\1***/' \
291+
| sed 's/^\(VAULT_LICENSE=\).*/\1***/' \
292+
| sed 's/^\(VAULT_LICENSE_IBM=\).*/\1***/' \
293+
| sort)
294+
295+
# Reconstruct the -run filter from the matrix if one was used
296+
run_filter=""
297+
if [ -n "${VAULT_TEST_MATRIX:-}" ] && [ -f "${VAULT_TEST_MATRIX}" ]; then
298+
run_filter="-run=\"$(jq -r '[.include[].test] | join("|")' "$VAULT_TEST_MATRIX")\""
299+
fi
300+
301+
# Building Blackbox Test Command. Build the pretty multi-line command string
302+
cmd_lines=()
303+
for line in "${env_lines[@]}"; do
304+
cmd_lines+=(" ${line} \\")
305+
done
306+
cmd_lines+=(" go test -count=1 -timeout=${test_timeout} \\")
307+
[[ -n "${tags}" ]] && cmd_lines+=(" ${tags} \\")
308+
[[ -n "${run_filter}" ]] && cmd_lines+=(" ${run_filter} \\")
309+
# Last line: package with no trailing backslash
310+
cmd_lines+=(" ${VAULT_TEST_PACKAGE}")
311+
312+
# Join into a single display string
313+
pretty_cmd="$(printf '%s\n' "${cmd_lines[@]}")"
314+
315+
echo ""
316+
echo "=== BLACKBOX TEST COMMAND ==="
317+
echo "${pretty_cmd}"
318+
echo "============================="
319+
320+
# Emit a single-line base64-encoded marker so Terraform can capture the command
321+
# via regex() and expose it as an `enos scenario output` value.
322+
echo "BLACKBOX_TEST_CMD=$(echo "${pretty_cmd}" | base64 -w 0)"
323+
275324
popd > /dev/null
276325

277326
# Always output exit code for Terraform to capture, but exit 0 so script doesn't fail

0 commit comments

Comments
 (0)