Skip to content

Commit 3100d62

Browse files
authored
Merge pull request #2476 from input-output-hk/dlachaume/2471/add-cardano-node-startup-check-step
Test: add Cardano node startup check to `Mithril Client multi-platform test` workflow
2 parents a319874 + b676524 commit 3100d62

File tree

2 files changed

+92
-19
lines changed

2 files changed

+92
-19
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [[ $# -lt 1 ]]; then
6+
echo "Usage: $0 <file containing 'mithril-client' CLI download output> [--include-ancillary]"
7+
echo "The first argument must be the file path containing the raw output (stdout) of the mithril-client CLI download command."
8+
echo "The second optional argument must be '--include-ancillary' if ancillary files are included."
9+
exit 1
10+
fi
11+
12+
if [[ ! -f "$1" ]]; then
13+
echo "Error: File '$1' not found."
14+
exit 1
15+
fi
16+
17+
CLIENT_CMD_OUTPUT=$(cat "$1")
18+
INCLUDE_ANCILLARY="$2"
19+
20+
DOCKER_CMD=$(echo "$CLIENT_CMD_OUTPUT" | grep -E '^\s*docker run')
21+
if [[ -z "$DOCKER_CMD" ]]; then
22+
echo "No Docker command found in mithril-client CLI command output."
23+
exit 1
24+
fi
25+
26+
echo "Extracted Docker command:"
27+
echo "$DOCKER_CMD"
28+
29+
DOCKER_CMD_DETACHED="${DOCKER_CMD/docker run/docker run -d}"
30+
echo "Running Docker command in detached mode:"
31+
echo "$DOCKER_CMD_DETACHED"
32+
33+
CONTAINER_ID=$(eval "$DOCKER_CMD_DETACHED")
34+
35+
wait_for_log() {
36+
local CONTAINER_ID="$1"
37+
local TIMEOUT="$2"
38+
local LOG_MESSAGE="$3"
39+
40+
echo "Waiting up to $TIMEOUT seconds for '$LOG_MESSAGE'..."
41+
for ((i=1; i<=TIMEOUT; i++)); do
42+
if docker logs "$CONTAINER_ID" 2>&1 | grep -q "$LOG_MESSAGE"; then
43+
echo "Found '$LOG_MESSAGE' in logs."
44+
return 0
45+
fi
46+
sleep 1
47+
done
48+
49+
echo "'$LOG_MESSAGE' not found within $TIMEOUT seconds."
50+
docker logs "$CONTAINER_ID"
51+
return 1
52+
}
53+
54+
if wait_for_log "$CONTAINER_ID" 15 "Started opening Immutable DB"; then
55+
echo "✅ The Cardano node started successfully from the Mithril snapshot."
56+
else
57+
echo "❌ Failed to start the Cardano node from the Mithril snapshot."
58+
exit 1
59+
fi
60+
61+
if [[ "$INCLUDE_ANCILLARY" == "--include-ancillary" ]]; then
62+
echo "Parameter '--include-ancillary' is set."
63+
if wait_for_log "$CONTAINER_ID" 30 "Chain extended, new tip"; then
64+
echo "✅ The Cardano node started successfully from the Mithril snapshot with the ancillary files."
65+
exit 0
66+
else
67+
echo "❌ Failed to start the Cardano node from the Mithril snapshot with the ancillary files."
68+
exit 1
69+
fi
70+
else
71+
echo "Parameter '--include-ancillary' is not set."
72+
echo "Skipping additional check for 'Chain extended, new tip' in logs."
73+
exit 0
74+
fi

.github/workflows/test-client.yml

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ on:
4040
required: false
4141
type: string
4242
default: https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/pre-release-preview/ancillary.vkey
43-
include_ancillary:
44-
description: Include ancillary files in the download.
45-
required: true
46-
type: boolean
47-
default: true
4843
enable_debug:
4944
description: Enable debug output ("-vvv") for the mithril-client calls
5045
required: true
@@ -72,9 +67,6 @@ on:
7267
ancillary_verification_key:
7368
type: string
7469
default: https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/testing-preview/ancillary.vkey
75-
include_ancillary:
76-
type: boolean
77-
default: true
7870
enable_debug:
7971
type: boolean
8072
default: false
@@ -85,6 +77,8 @@ jobs:
8577
fail-fast: false
8678
matrix:
8779
os: [ubuntu-24.04, macos-14, windows-latest]
80+
extra_args: ["", "--include-ancillary"]
81+
8882
runs-on: ${{ matrix.os }}
8983
steps:
9084
- name: Checkout sources
@@ -110,9 +104,6 @@ jobs:
110104
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ inputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV
111105
112106
echo "ANCILLARY_VERIFICATION_KEY=$(curl -s ${{ inputs.ancillary_verification_key }})" >> $GITHUB_ENV
113-
if [[ "${{ inputs.include_ancillary }}" == "true" ]]; then
114-
echo "INCLUDE_ANCILLARY=--include-ancillary" >> $GITHUB_OUTPUT
115-
fi
116107
117108
- name: Assessing aggregator capabilities (Unix)
118109
id: aggregator_capability_unix
@@ -169,7 +160,12 @@ jobs:
169160
- name: Cardano Database Snapshot / download & restore latest
170161
shell: bash
171162
working-directory: ./bin
172-
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CDB_SNAPSHOT_DIGEST $INCLUDE_ANCILLARY
163+
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CDB_SNAPSHOT_DIGEST ${{ matrix.extra_args }} > cdb-download-output.txt 2>&1
164+
165+
- name: Cardano Database Snapshot / verify Cardano node starts successfully
166+
if: runner.os == 'Linux'
167+
shell: bash
168+
run: .github/workflows/scripts/verify-cardano-db-restoration.sh ./bin/cdb-download-output.txt "${{ matrix.extra_args }}"
173169

174170
- name: Mithril Stake Distribution / list and get last hash
175171
shell: bash
@@ -243,13 +239,19 @@ jobs:
243239
if: steps.aggregator_capability_unix.outputs.cardano_database_v2_enabled == 'true' || steps.aggregator_capability_windows.outputs.cardano_database_v2_enabled == 'true'
244240
shell: bash
245241
working-directory: ./bin
246-
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} --unstable --origin-tag CI cardano-db-v2 download $CARDANO_DATABASE_V2_SNAPSHOT_HASH $INCLUDE_ANCILLARY
242+
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} --unstable --origin-tag CI cardano-db-v2 download $CARDANO_DATABASE_V2_SNAPSHOT_HASH ${{ matrix.extra_args }} > cdb-v2-download-output.txt 2>&1
243+
244+
- name: Cardano Database V2 Snapshot / verify Cardano node starts successfully
245+
if: runner.os == 'Linux' && steps.aggregator_capability_unix.outputs.cardano_database_v2_enabled == 'true'
246+
shell: bash
247+
run: .github/workflows/scripts/verify-cardano-db-restoration.sh ./bin/cdb-v2-download-output.txt "${{ matrix.extra_args }}"
247248

248249
test-docker:
249250
strategy:
250251
fail-fast: false
251252
matrix:
252253
os: [ubuntu-24.04]
254+
extra_args: ["", "--include-ancillary"]
253255
runs-on: ${{ matrix.os }}
254256
steps:
255257
- name: Prepare environment variables
@@ -267,9 +269,6 @@ jobs:
267269
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ inputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV
268270
269271
echo "ANCILLARY_VERIFICATION_KEY=$(curl -s ${{ inputs.ancillary_verification_key }})" >> $GITHUB_ENV
270-
if [[ "${{ inputs.include_ancillary }}" == "true" ]]; then
271-
echo "INCLUDE_ANCILLARY=--include-ancillary" >> $GITHUB_OUTPUT
272-
fi
273272
274273
- name: Assessing aggregator capabilities
275274
id: aggregator_capability
@@ -286,7 +285,7 @@ jobs:
286285
id: command
287286
shell: bash
288287
run: |
289-
echo "mithril_client=docker run --rm -e NETWORK=$NETWORK -e GENESIS_VERIFICATION_KEY=$GENESIS_VERIFICATION_KEY -e AGGREGATOR_ENDPOINT=$AGGREGATOR_ENDPOINT --name='mithril-client' ghcr.io/input-output-hk/mithril-client:$MITHRIL_IMAGE_ID" >> $GITHUB_OUTPUT
288+
echo "mithril_client=docker run --rm -e NETWORK=$NETWORK -e GENESIS_VERIFICATION_KEY=$GENESIS_VERIFICATION_KEY -e ANCILLARY_VERIFICATION_KEY=$ANCILLARY_VERIFICATION_KEY -e AGGREGATOR_ENDPOINT=$AGGREGATOR_ENDPOINT --name='mithril-client' ghcr.io/input-output-hk/mithril-client:$MITHRIL_IMAGE_ID" >> $GITHUB_OUTPUT
290289
291290
- name: Show client version
292291
shell: bash
@@ -300,7 +299,7 @@ jobs:
300299
301300
- name: Cardano Database Snapshot / download & restore latest
302301
shell: bash
303-
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CDB_SNAPSHOT_DIGEST --download-dir /app $INCLUDE_ANCILLARY
302+
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} --origin-tag CI cardano-db download $CDB_SNAPSHOT_DIGEST --download-dir /app ${{ matrix.extra_args }}
304303

305304
- name: Mithril Stake Distribution / list and get last hash
306305
shell: bash
@@ -363,7 +362,7 @@ jobs:
363362
- name: Cardano Database V2 Snapshot / download & restore latest (Full restoration)
364363
if: steps.aggregator_capability.outputs.cardano_database_v2_enabled == 'true'
365364
shell: bash
366-
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} --origin-tag CI --unstable cardano-db-v2 download $CARDANO_DATABASE_V2_SNAPSHOT_HASH --download-dir /app $INCLUDE_ANCILLARY
365+
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} --origin-tag CI --unstable cardano-db-v2 download $CARDANO_DATABASE_V2_SNAPSHOT_HASH --download-dir /app ${{ matrix.extra_args }}
367366

368367
test-mithril-client-wasm:
369368
strategy:

0 commit comments

Comments
 (0)