Skip to content

Commit a604ea5

Browse files
committed
refactor: switch block prod test to mixed UTxO backends
Update the block production test to use mixed UTxO backends ("mem" and "disk") instead of mixed P2P/legacy topologies. The test now records the backend type in the database and test output, and the helper script sets the MIXED_UTXO_BACKENDS environment variable accordingly.
1 parent 8cb5b08 commit a604ea5

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

cardano_node_tests/tests/test_blocks.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def payment_addrs(
264264
return addrs
265265

266266
@allure.link(helpers.get_vcs_link())
267-
def test_block_production( # noqa: C901
267+
def test_block_production(
268268
self,
269269
cluster_manager: cluster_management.ClusterManager,
270270
cluster: clusterlib.ClusterLib,
@@ -282,12 +282,7 @@ def test_block_production( # noqa: C901
282282
temp_template = common.get_test_id(cluster)
283283
rand = clusterlib.get_rand_str(5)
284284
num_epochs = int(os.environ.get("BLOCK_PRODUCTION_EPOCHS") or 50)
285-
286-
topology = "p2p"
287-
if configuration.MIXED_P2P:
288-
topology = "mixed"
289-
elif configuration.ENABLE_LEGACY:
290-
topology = "legacy"
285+
mixed_backends = configuration.MIXED_UTXO_BACKENDS.split()
291286

292287
pool_mapping = {}
293288
for idx, pn in enumerate(cluster_management.Resources.ALL_POOLS, start=1):
@@ -301,28 +296,29 @@ def test_block_production( # noqa: C901
301296
delegation.delegate_stake_addr(
302297
cluster_obj=cluster,
303298
addrs_data=cluster_manager.cache.addrs_data,
304-
temp_template=temp_template,
299+
temp_template=f"{temp_template}_pool_{idx}",
305300
pool_id=pool_id,
306301
)
307302

308303
# Create sqlite db
309304
conn = sqlite3.connect(configuration.BLOCK_PRODUCTION_DB)
310305
cur = conn.cursor()
311-
cur.execute("CREATE TABLE IF NOT EXISTS runs(run_id, topology)")
306+
cur.execute("CREATE TABLE IF NOT EXISTS runs(run_id, backend)")
312307
cur.execute(
313308
"CREATE TABLE IF NOT EXISTS"
314-
" blocks(run_id, epoch_no, pool_id, pool_idx, topology, num_blocks)"
309+
" blocks(run_id, epoch_no, pool_id, pool_idx, backend, num_blocks)"
310+
)
311+
cur.execute(
312+
"INSERT INTO runs VALUES (?, ?)",
313+
(rand, "mixed" if mixed_backends else configuration.UTXO_BACKEND),
315314
)
316-
cur.execute("INSERT INTO runs VALUES (?, ?)", (rand, topology))
317315
conn.commit()
318316
cur.close()
319317

320-
def _get_pool_topology(pool_idx: int) -> str:
321-
if topology == "legacy":
322-
return "legacy"
323-
if topology == "mixed":
324-
return "p2p" if pool_idx % 2 == 0 else "legacy"
325-
return "p2p"
318+
def _get_pool_utxo_backend(pool_idx: int) -> str:
319+
if mixed_backends:
320+
return mixed_backends[(pool_idx - 1) % len(mixed_backends)]
321+
return configuration.UTXO_BACKEND
326322

327323
def _save_state(curr_epoch: int) -> None:
328324
ledger_state = clusterlib_utils.get_ledger_state(cluster_obj=cluster)
@@ -345,7 +341,7 @@ def _save_state(curr_epoch: int) -> None:
345341
curr_epoch - 1,
346342
pool_rec["pool_id"],
347343
pool_idx,
348-
_get_pool_topology(pool_idx),
344+
_get_pool_utxo_backend(pool_idx),
349345
num_blocks,
350346
),
351347
)

scripts/test_block_production.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
#!/usr/bin/env bash
22
#
3-
# Run the block production test on environment where half of the nodes are using the legacy
4-
# topology and the other half are using the P2P topology.
3+
# Run the block production test on environment where half of the nodes is using the `mem`
4+
# and the other half is using the `disk` UTxO backend.
55

66
set -euo pipefail
77

88
TOP_DIR="$(readlink -m "${0%/*}/..")"
99

1010
# The database file will be created if missing
11-
if [ -z "${BLOCK_PRODUCTION_DB:-""}" ]; then
11+
if [ -z "${BLOCK_PRODUCTION_DB:-}" ]; then
1212
# shellcheck disable=SC2016
1313
echo 'Configure path to the database file by setting `BLOCK_PRODUCTION_DB`' >&2
1414
exit 1
1515
fi
1616
BLOCK_PRODUCTION_DB="$(readlink -m "$BLOCK_PRODUCTION_DB")"
1717
export BLOCK_PRODUCTION_DB
1818

19-
# Node revision to use. If not set, the latest master will be used.
20-
export NODE_REV="${NODE_REV:-""}"
21-
22-
# Start cluster in Byron era
23-
export CI_BYRON_CLUSTER="${CI_BYRON_CLUSTER:-"true"}"
24-
2519
# The number of pools to setup
2620
export NUM_POOLS="${NUM_POOLS:-"10"}"
2721
if [ $((NUM_POOLS % 2)) -ne 0 ]; then
@@ -32,6 +26,6 @@ fi
3226
# The number of epochs to produce blocks for
3327
export BLOCK_PRODUCTION_EPOCHS="${BLOCK_PRODUCTION_EPOCHS:-"100"}"
3428

35-
export MIXED_P2P=1 CLUSTERS_COUNT=1 TEST_THREADS=0 PYTEST_ARGS="-k test_block_production"
29+
export MIXED_UTXO_BACKENDS="mem disk" SESSION_TIMEOUT=10h CLUSTERS_COUNT=1 TEST_THREADS=0 PYTEST_ARGS="-k test_block_production"
3630

3731
"$TOP_DIR/.github/regression.sh"

0 commit comments

Comments
 (0)