Skip to content

Commit f1ef840

Browse files
authored
Flaky test fix - test_post_snapshot_chunks_retained (#7810)
1 parent 2a4963a commit f1ef840

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

tests/e2e_operations.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3821,24 +3821,20 @@ def get_latest_committed_snapshot_seqno():
38213821
network.txs.issue(network, number_txs=3)
38223822
copy_new_committed_to_readonly()
38233823

3824-
primary.trigger_snapshot()
3825-
# Issue enough txs to advance commit past the snapshot
3826-
network.txs.issue(network, number_txs=3)
3827-
network.consortium.force_ledger_chunk(primary)
3828-
network.txs.issue(network, number_txs=3)
3824+
snapshot_tx_id = primary.trigger_snapshot()
38293825

38303826
# Wait for the snapshot to appear
38313827
timeout = 10
38323828
end_time = time.time() + timeout
38333829
snapshot_seqno = None
38343830
while time.time() < end_time:
38353831
snapshot_seqno = get_latest_committed_snapshot_seqno()
3836-
if snapshot_seqno is not None:
3832+
if snapshot_seqno is not None and snapshot_seqno >= snapshot_tx_id.seqno:
38373833
break
38383834
time.sleep(0.5)
38393835
assert (
38403836
snapshot_seqno is not None
3841-
), f"Timed out waiting for a committed snapshot in {snapshots_dir}"
3837+
), f"Timed out waiting for a committed snapshot covering {snapshot_tx_id.seqno} in {snapshots_dir}"
38423838
LOG.info(f"Latest committed snapshot seqno: {snapshot_seqno}")
38433839

38443840
# Step 2: Generate many chunks AFTER the snapshot so they exceed max_retained
@@ -3906,7 +3902,8 @@ def run_post_snapshot_chunk_retention(const_args):
39063902
# if the snapshot watermark were not respected
39073903
args.files_cleanup_max_committed_ledger_chunks = 1
39083904
args.files_cleanup_interval = "1s"
3909-
args.snapshot_tx_interval = 30
3905+
# High to avoid tx-count-triggered snapshots during chunk generation
3906+
args.snapshot_tx_interval = 100000
39103907

39113908
with tempfile.TemporaryDirectory() as tmp_dir:
39123909
args.common_read_only_ledger_dir = tmp_dir

tests/infra/node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import infra.interfaces
1313
import infra.clients
1414
import ccf.ledger
15+
from ccf.tx_id import TxID
1516
import os
1617
import socket
1718
import re
@@ -896,13 +897,14 @@ def refresh_network_state(self, **client_kwargs):
896897
LOG.debug(f"Failed to connect {e}")
897898
self.network_state = NodeNetworkState.stopped
898899

899-
def trigger_snapshot(self):
900+
def trigger_snapshot(self) -> TxID:
900901
LOG.info(f"Triggering snapshot on {self.local_node_id}")
901902
with self.client(
902903
interface_name=infra.interfaces.FILE_SERVING_RPC_INTERFACE
903904
) as c:
904905
r = c.post("/node/snapshot:create")
905906
assert r.status_code == http.HTTPStatus.NO_CONTENT, r
907+
return TxID(r.view, r.seqno)
906908

907909
def log_stack_trace(self, timeout=20):
908910
if self.remote and self.network_state is not NodeNetworkState.stopped:

0 commit comments

Comments
 (0)