Skip to content

Commit 9d075e8

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

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,26 @@ if [[ $# -lt 1 ]]; then
99
exit 1
1010
fi
1111

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
12+
DOCKER_CMD=""
1813
INCLUDE_ANCILLARY="false"
1914
LEDGER_BACKEND="in-memory"
2015

2116
while [[ "$#" -gt 0 ]]; do
2217
case $1 in
18+
--docker-cmd) DOCKER_CMD="$2"; shift;;
2319
--include-ancillary) INCLUDE_ANCILLARY="true" ;;
2420
--ledger-backend) LEDGER_BACKEND="$2"; shift ;;
2521
esac
2622
shift
2723
done
2824

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

35-
echo "Extracted Docker command:"
31+
echo "Docker command:"
3632
echo "$DOCKER_CMD"
3733

3834
# 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+
2>&1 | 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)