Skip to content

Commit 079341f

Browse files
committed
ci(test-client): add conversion to legacy case
1 parent 16c4ecf commit 079341f

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

.github/workflows/scripts/verify-cardano-db-restoration.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,34 @@
33
set -e
44

55
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."
6+
echo "Usage: $0 --docker-cmd [docker run command string] [--include-ancillary] [--ledger-backend <in-memory|lmdb|legacy>]"
7+
echo ""
8+
echo "Parameters:"
9+
echo " --docker-cmd <command> (Required) The 'docker run' command output in the result of a mithril-client CLI download or snapshot converter command."
10+
echo " --include-ancillary (Optional) Does the ancillary files were included in the restoration."
11+
echo " --ledger-backend <in-memory|lmdb> (Optional) Specify the ledger backend. Default is 'in-memory'. Note: lmdb backend requires --include-ancillary to be set."
912
exit 1
1013
fi
1114

12-
if [[ ! -f "$1" ]]; then
13-
echo "Error: File '$1' not found."
14-
exit 1
15-
fi
16-
17-
CLIENT_CMD_OUTPUT=$(cat "$1"); shift
15+
DOCKER_CMD=""
1816
INCLUDE_ANCILLARY="false"
1917
LEDGER_BACKEND="in-memory"
2018

2119
while [[ "$#" -gt 0 ]]; do
2220
case $1 in
21+
--docker-cmd) DOCKER_CMD="$2"; shift;;
2322
--include-ancillary) INCLUDE_ANCILLARY="true" ;;
2423
--ledger-backend) LEDGER_BACKEND="$2"; shift ;;
2524
esac
2625
shift
2726
done
2827

29-
DOCKER_CMD=$(echo "$CLIENT_CMD_OUTPUT" | grep -E '^\s*docker run')
3028
if [[ -z "$DOCKER_CMD" ]]; then
31-
echo "No Docker command found in mithril-client CLI command output."
29+
echo "Error: argument '--docker-cmd \"docker run ...\"' is mandatory."
3230
exit 1
3331
fi
3432

35-
echo "Extracted Docker command:"
33+
echo "Docker command:"
3634
echo "$DOCKER_CMD"
3735

3836
# Note: ledger conversion to lmdb can only be executed if ancillary files are included

.github/workflows/test-client.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
117117
if [[ $CARDANO_DATABASE_V2_CAPABILITY == "true" ]]; then
118118
echo 'available_cardano_database_backends=["v1","v2"]' >> $GITHUB_OUTPUT
119-
echo 'bin-cdb-download-matrix-include=[{"backend":"v2","os":"ubuntu-24.04","ledger_backend":"lmdb","extra_args":"--include-ancillary"}]' >> $GITHUB_OUTPUT
119+
echo 'bin-cdb-download-matrix-include=[{"backend":"v2","os":"ubuntu-24.04","ledger_backend":"lmdb","extra_args":"--include-ancillary"},{"backend":"v2","os":"ubuntu-24.04","ledger_backend":"legacy","extra_args":"--include-ancillary"}]' >> $GITHUB_OUTPUT
120120
else
121121
echo 'available_cardano_database_backends=["v1"]' >> $GITHUB_OUTPUT
122122
echo 'bin-cdb-download-matrix-include=[]' >> $GITHUB_OUTPUT
@@ -293,16 +293,28 @@ jobs:
293293
shell: bash
294294
working-directory: ./bin
295295
run: |
296-
./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download ${{ steps.last_snapshot.outputs.hash }} --backend ${{ matrix.backend }} --download-dir "${{ matrix.backend }}" ${{ matrix.extra_args }} 2>&1 | tee cdb-${{ matrix.backend }}-download-output.txt
296+
./mithril-client ${{ needs.prepare.outputs.debug_level }} --origin-tag CI cardano-db download ${{ steps.last_snapshot.outputs.hash }} \
297+
--backend ${{ matrix.backend }} --download-dir "${{ matrix.backend }}" ${{ matrix.extra_args }} --json \
298+
| tee cdb-${{ matrix.backend }}-download-output.json
297299
298-
- name: Ledger state snapshot conversion from InMemory to LMDB
300+
- name: Ledger state snapshot conversion from InMemory to ${{ matrix.ledger_backend }}
299301
# The 'snapshot-converter' binary is not currently supported on Linux ARM64 platforms.
300-
if: matrix.os != 'ubuntu-24.04-arm' && matrix.extra_args == '--include-ancillary' && matrix.ledger_backend == 'lmdb'
302+
if: matrix.os != 'ubuntu-24.04-arm' && matrix.extra_args == '--include-ancillary' && contains(fromJSON('["lmdb", "legacy"]'), matrix.ledger_backend)
301303
env:
302304
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
303305
shell: bash
304306
working-directory: ./bin
305-
run: ./mithril-client ${{ needs.prepare.outputs.debug_level }} tools utxo-hd snapshot-converter --db-directory ${{ matrix.backend }}/db --cardano-node-version latest --utxo-hd-flavor LMDB --commit
307+
run: |
308+
LEDGER_BACKEND="${{ matrix.ledger_backend }}"
309+
if [[ ${LEDGER_BACKEND,,} == "lmdb" ]]; then
310+
UTXO_HD_FLAVOR="LMDB"
311+
elif [[ ${LEDGER_BACKEND,,} == "legacy" ]]; then
312+
UTXO_HD_FLAVOR="Legacy"
313+
fi
314+
315+
./mithril-client ${{ needs.prepare.outputs.debug_level }} tools utxo-hd snapshot-converter --db-directory ${{ matrix.backend }}/db \
316+
--cardano-node-version latest --utxo-hd-flavor $UTXO_HD_FLAVOR --commit --json \
317+
| tee cdb-${{ matrix.backend }}-converter-output.json
306318
307319
- name: Cardano Database V2 Snapshot / verify immutables
308320
if: matrix.backend == 'v2'
@@ -313,7 +325,14 @@ jobs:
313325
- name: Cardano Database Snapshot / verify Cardano node starts successfully
314326
if: matrix.os == 'ubuntu-24.04'
315327
shell: bash
316-
run: .github/workflows/scripts/verify-cardano-db-restoration.sh ./bin/cdb-${{ matrix.backend }}-download-output.txt --ledger-backend ${{ matrix.ledger_backend }} ${{ matrix.extra_args }}
328+
run: |
329+
if [[ -e "./bin/cdb-${{ matrix.backend }}-converter-output.json" ]]; then
330+
DOCKER_CMD=$(jq -r ".run_docker_cmd" ./bin/cdb-${{ matrix.backend }}-converter-output.json)
331+
else
332+
DOCKER_CMD=$(jq -r ".run_docker_cmd" ./bin/cdb-${{ matrix.backend }}-download-output.json)
333+
fi
334+
335+
.github/workflows/scripts/verify-cardano-db-restoration.sh --docker-cmd "$DOCKER_CMD" --ledger-backend ${{ matrix.ledger_backend }} ${{ matrix.extra_args }}
317336
318337
- name: Cardano Database V2 Snapshot / verify tampered and missing immutables from a specific range
319338
if: matrix.backend == 'v2'

0 commit comments

Comments
 (0)