Skip to content

Commit 3b7eeb7

Browse files
Run the "from_files" recovery tests in separate runners (#7014)
Co-authored-by: Amaury Chamayou <[email protected]>
1 parent da429c5 commit 3b7eeb7

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

tests/recovery.py

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import subprocess
1414
import json
1515
from infra.runner import ConcurrentRunner
16-
from distutils.dir_util import remove_tree, copy_tree
1716
from infra.consortium import slurp_file
1817
import infra.health_watcher
1918
import time
@@ -536,10 +535,23 @@ def test_recover_service_from_files(
536535
os.path.dirname(os.path.realpath(__file__)), "testdata", directory
537536
)
538537

539-
new_common = infra.network.get_common_folder_name(args.workspace, args.label)
540-
remove_tree(new_common)
541538
old_common = os.path.join(service_dir, "common")
542-
copy_tree(old_common, new_common)
539+
LOG.info(f"Copying common folder: {old_common}")
540+
new_common = infra.network.get_common_folder_name(args.workspace, args.label)
541+
542+
cmd = ["rm", "-rf", new_common]
543+
assert (
544+
infra.proc.ccall(*cmd).returncode == 0
545+
), f"Could not remove existing {new_common} directory"
546+
cmd = ["mkdir", "-p", new_common]
547+
assert (
548+
infra.proc.ccall(*cmd).returncode == 0
549+
), f"Could not create fresh {new_common} directory"
550+
for file in os.listdir(old_common):
551+
cmd = ["cp", os.path.join(old_common, file), new_common]
552+
assert (
553+
infra.proc.ccall(*cmd).returncode == 0
554+
), f"Could not copy {file} to {new_common}"
543555

544556
network = infra.network.Network(args.nodes, args.binary_dir)
545557

@@ -1078,27 +1090,13 @@ def run(args):
10781090
chunk_start_seqno == seqno
10791091
), f"{service_status} service at seqno {seqno} did not start a new ledger chunk (started at {chunk_start_seqno})"
10801092

1081-
test_recover_service_from_files(
1082-
args, directory="expired_service", expected_recovery_count=2, test_receipt=True
1083-
)
1084-
# sgx_service is historical ledger, from 1.x -> 2.x -> 3.x -> 5.x -> main.
1085-
# This is used to test recovery from SGX to SNP.
1086-
test_recover_service_from_files(
1087-
args, directory="sgx_service", expected_recovery_count=4, test_receipt=False
1088-
)
10891093

1094+
def run_recovery_from_files(args):
10901095
test_recover_service_from_files(
10911096
args,
1092-
directory="double_sealed_service",
1093-
expected_recovery_count=2,
1094-
test_receipt=False,
1095-
)
1096-
1097-
test_recover_service_from_files(
1098-
args,
1099-
directory="cose_flipflop_service",
1100-
expected_recovery_count=0,
1101-
test_receipt=False,
1097+
directory=args.directory,
1098+
expected_recovery_count=args.expected_recovery_count,
1099+
test_receipt=args.test_receipt,
11021100
)
11031101

11041102

@@ -1357,6 +1355,28 @@ def add(parser):
13571355
snapshot_tx_interval=30,
13581356
)
13591357

1358+
for directory, expected_recovery_count, test_receipt in (
1359+
("expired_service", 2, True),
1360+
# sgx_service is historical ledger, from 1.x -> 2.x -> 3.x -> 5.x -> main.
1361+
# This is used to test recovery from SGX to SNP.
1362+
("sgx_service", 4, False),
1363+
# double_sealed_service is a regression test for the issue described in #6906
1364+
("double_sealed_service", 2, False),
1365+
# cose_flipflop_service is a regression test for the issue described in #7002
1366+
("cose_flipflop_service", 0, False),
1367+
):
1368+
cr.add(
1369+
f"recovery_from_{directory}",
1370+
run_recovery_from_files,
1371+
package="samples/apps/logging/liblogging",
1372+
nodes=infra.e2e_args.min_nodes(cr.args, f=1),
1373+
ledger_chunk_bytes="50KB",
1374+
snapshot_tx_interval=30,
1375+
directory=directory,
1376+
expected_recovery_count=expected_recovery_count,
1377+
test_receipt=test_receipt,
1378+
)
1379+
13601380
# Note: `run_corrupted_ledger` runs with very a specific node configuration
13611381
# so that the contents of recovered (and tampered) ledger chunks
13621382
# can be dictated by the test. In particular, the signature interval is large

0 commit comments

Comments
 (0)