Skip to content

Commit 9c9f409

Browse files
authored
Tilt flow: e2e test run using gotestsum outside Tilt (#4477)
Follows #4474, With these changes, Tilt environment on CI is fully functional. We also move to use e2e invocation directly with `gotestsum`. Additionally, internal test results ingestion is moved to an action and shared between traditional flow.yml based and Tilt based CI. Finally, this workflow is set-up so it can be invoked from other workflows as follow: ```yaml jobs: pg-ch-e2e: uses: ./.github/workflows/tilt-flow.yml with: test_matcher: TestGenericCH_PG ancillary_services: postgres clickhouse secrets: inherit ```
1 parent c47b4b1 commit 9c9f409

4 files changed

Lines changed: 222 additions & 124 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 'Ingest test results'
2+
description: >-
3+
Normalize JUnit test results and ingest them into the CI observability store
4+
for analysis. No-op when the o11y target secrets are not configured. Must run
5+
from the workspace root (uses .github/scripts/test-results.sh) and requires the
6+
`retry` CLI on PATH.
7+
8+
inputs:
9+
combination-id:
10+
description: >-
11+
Identifier for the combination/compatibility this run covers (stored as
12+
compatibility_matrix_id). e.g. "pg17-my8-mo7-ch24" or "tilt-TestApiPg".
13+
required: true
14+
test-results-file:
15+
description: Path to the JUnit XML test results file (relative to the workspace root).
16+
required: false
17+
default: logs/test-results.xml
18+
o11y-api-key-id:
19+
description: API key id for the o11y ingestion endpoint. Ingestion is skipped when empty.
20+
required: false
21+
default: ''
22+
o11y-api-key-secret:
23+
description: API key secret for the o11y ingestion endpoint. Ingestion is skipped when empty.
24+
required: false
25+
default: ''
26+
o11y-query-endpoint:
27+
description: Query endpoint the normalized results are POSTed to. Ingestion is skipped when empty.
28+
required: false
29+
default: ''
30+
31+
runs:
32+
using: composite
33+
steps:
34+
- name: Ingest tests results for analysis
35+
shell: bash
36+
env:
37+
WORKFLOW_RUN_ID: ${{ github.run_id }}
38+
WORKFLOW_RUN_LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
39+
WORKFLOW_HEAD_BRANCH: ${{ github.head_ref || github.ref_name }}
40+
WORKFLOW_RUN_NUMBER: ${{ github.run_attempt }}
41+
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
42+
SUMMARY_HEADER: "x-clickhouse-summary"
43+
COMBINATION_ID: ${{ inputs.combination-id }}
44+
TEST_RESULTS_FILE: ${{ inputs.test-results-file }}
45+
O11Y_API_KEY_ID: ${{ inputs.o11y-api-key-id }}
46+
O11Y_API_KEY_SECRET: ${{ inputs.o11y-api-key-secret }}
47+
O11Y_QUERY_ENDPOINT: ${{ inputs.o11y-query-endpoint }}
48+
run: |
49+
if [ -z "$O11Y_API_KEY_ID" ] \
50+
|| [ -z "$O11Y_API_KEY_SECRET" ] \
51+
|| [ -z "$O11Y_QUERY_ENDPOINT" ]; then
52+
echo "Secrets not configured; Test results ingestion is disabled."
53+
exit 0
54+
fi
55+
.github/scripts/test-results.sh "$TEST_RESULTS_FILE" > logs/normalized-test-results.ndjson
56+
if [ ! -s logs/normalized-test-results.ndjson ]; then
57+
echo "Failed to extract test results"
58+
exit 1
59+
fi
60+
# Retry upload with exponential backoff
61+
retry --times=5 --delay "1,2,4,8,16,32,64,128" -- \
62+
curl --fail-with-body -i -H "Content-Type: application/octet-stream" \
63+
--user "$O11Y_API_KEY_ID:$O11Y_API_KEY_SECRET" \
64+
"$O11Y_QUERY_ENDPOINT" \
65+
--data-binary @logs/normalized-test-results.ndjson \
66+
| tee upload.log
67+
WRITTEN_ROWS=$(cat upload.log | grep $SUMMARY_HEADER | sed "s/$SUMMARY_HEADER: //" | jq '.written_rows' -r)
68+
if [ -z "$WRITTEN_ROWS" ] || [ "$WRITTEN_ROWS" -eq 0 ]; then
69+
echo "No results uploaded. Query client logs:"
70+
cat upload.log
71+
exit 2
72+
fi
73+
echo "Number of ingested test results: $WRITTEN_ROWS"
74+
exit 0

.github/workflows/flow.yml

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -687,38 +687,9 @@ jobs:
687687
token: ${{ secrets.CODECOV_TOKEN }}
688688
- name: Ingest tests results for analysis
689689
if: success() || failure()
690-
env:
691-
WORKFLOW_RUN_ID: ${{ github.run_id }}
692-
WORKFLOW_RUN_LINK: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
693-
WORKFLOW_HEAD_BRANCH: ${{ github.head_ref || github.ref_name }}
694-
WORKFLOW_RUN_NUMBER: ${{ github.run_attempt }}
695-
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
696-
SUMMARY_HEADER: "x-clickhouse-summary"
697-
COMBINATION_ID: "pg${{ matrix.db-version.pg }}-my${{ matrix.db-version.mysql }}-mo${{ matrix.db-version.mongo }}-ch${{ matrix.db-version.ch }}"
698-
run: |
699-
if [ -z "${{ secrets.CI_O11Y_TARGET_API_KEY_ID }}" ] \
700-
|| [ -z "${{ secrets.CI_O11Y_TARGET_API_KEY_SECRET }}" ] \
701-
|| [ -z "${{ secrets.CI_O11Y_TARGET_QUERY_ENDPOINT }}" ]; then
702-
echo "Secrets not configured; Test results ingestion is disabled."
703-
exit 0
704-
fi
705-
.github/scripts/test-results.sh logs/test-results.xml > logs/normalized-test-results.ndjson
706-
if [ ! -s logs/normalized-test-results.ndjson ]; then
707-
echo "Failed to extract test results"
708-
exit 1
709-
fi
710-
# Retry upload with exponential backoff
711-
retry --times=5 --delay "1,2,4,8,16,32,64,128" -- \
712-
curl --fail-with-body -i -H "Content-Type: application/octet-stream" \
713-
--user "${{ secrets.CI_O11Y_TARGET_API_KEY_ID }}:${{ secrets.CI_O11Y_TARGET_API_KEY_SECRET }}" \
714-
"${{ secrets.CI_O11Y_TARGET_QUERY_ENDPOINT }}" \
715-
--data-binary @logs/normalized-test-results.ndjson \
716-
| tee upload.log
717-
WRITTEN_ROWS=$(cat upload.log | grep $SUMMARY_HEADER | sed "s/$SUMMARY_HEADER: //" | jq '.written_rows' -r)
718-
if [ -z "$WRITTEN_ROWS" ] || [ "$WRITTEN_ROWS" -eq 0 ]; then
719-
echo "No results uploaded. Query client logs:"
720-
cat upload.log
721-
exit 2
722-
fi
723-
echo "Number of ingested test results: $WRITTEN_ROWS"
724-
exit 0
690+
uses: ./.github/actions/ingest-test-results
691+
with:
692+
combination-id: "pg${{ matrix.db-version.pg }}-my${{ matrix.db-version.mysql }}-mo${{ matrix.db-version.mongo }}-ch${{ matrix.db-version.ch }}"
693+
o11y-api-key-id: ${{ secrets.CI_O11Y_TARGET_API_KEY_ID }}
694+
o11y-api-key-secret: ${{ secrets.CI_O11Y_TARGET_API_KEY_SECRET }}
695+
o11y-query-endpoint: ${{ secrets.CI_O11Y_TARGET_QUERY_ENDPOINT }}

0 commit comments

Comments
 (0)