|
13 | 13 | import subprocess
|
14 | 14 | import json
|
15 | 15 | from infra.runner import ConcurrentRunner
|
16 |
| -from distutils.dir_util import remove_tree, copy_tree |
17 | 16 | from infra.consortium import slurp_file
|
18 | 17 | import infra.health_watcher
|
19 | 18 | import time
|
@@ -536,10 +535,23 @@ def test_recover_service_from_files(
|
536 | 535 | os.path.dirname(os.path.realpath(__file__)), "testdata", directory
|
537 | 536 | )
|
538 | 537 |
|
539 |
| - new_common = infra.network.get_common_folder_name(args.workspace, args.label) |
540 |
| - remove_tree(new_common) |
541 | 538 | 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}" |
543 | 555 |
|
544 | 556 | network = infra.network.Network(args.nodes, args.binary_dir)
|
545 | 557 |
|
@@ -1078,27 +1090,13 @@ def run(args):
|
1078 | 1090 | chunk_start_seqno == seqno
|
1079 | 1091 | ), f"{service_status} service at seqno {seqno} did not start a new ledger chunk (started at {chunk_start_seqno})"
|
1080 | 1092 |
|
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 |
| - ) |
1089 | 1093 |
|
| 1094 | +def run_recovery_from_files(args): |
1090 | 1095 | test_recover_service_from_files(
|
1091 | 1096 | 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, |
1102 | 1100 | )
|
1103 | 1101 |
|
1104 | 1102 |
|
@@ -1357,6 +1355,28 @@ def add(parser):
|
1357 | 1355 | snapshot_tx_interval=30,
|
1358 | 1356 | )
|
1359 | 1357 |
|
| 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 | + |
1360 | 1380 | # Note: `run_corrupted_ledger` runs with very a specific node configuration
|
1361 | 1381 | # so that the contents of recovered (and tampered) ledger chunks
|
1362 | 1382 | # can be dictated by the test. In particular, the signature interval is large
|
|
0 commit comments