Skip to content

Commit ba93745

Browse files
Merge #6631: test: set default delay to 0.05s for wait_until in functional tests
0d9418e test: reduce delay in wait_until from 0.5s to 0.05s (Konstantin Akimov) 876d6c8 test: enforce 1 second delay for wait_for_sporks helper (Konstantin Akimov) ec6e7bf test: enforce 1s delay for feature_mnehf test (Konstantin Akimov) 6ab3f7c test: reduce spamming quorum list to logs while waiting (Konstantin Akimov) 9d9975f test: simplify wait_for_quorum_list (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Waiting for 0.5s in functional test for every action is a bit excessive, especially for p2p tests that sending messages by localnetwork and waiting at least 0.5 seconds before checking if message is received. ## What was done? Decreasing default delay from 0.5s to 0.05s. It affects mostly p2p tests, but many other tests become faster too. For quorum formation; for sporks and some other dash specific features bigger delays (0.5s, 1s) are used. Further improvements are blocked by #6673, #6672, #6671 and are out of scope this PR. ## How Has This Been Tested? Speed up on CI for 30% and more. [develop] linux64-test https://gitlab.com/dashpay/dash/-/jobs/10049432489 ALL | ✓ Passed | 7241 s (accumulated) Runtime: 1272 s [PR] linux64-test https://gitlab.com/dashpay/dash/-/jobs/10067158169 ALL | ✓ Passed | 5421 s (accumulated) Runtime: 938 s **-25%** [develop] linux64-nowallet https://gitlab.com/dashpay/dash/-/jobs/10049432511 ALL | ✓ Passed | 2739 s (accumulated) Runtime: 488 s [PR] linux64-nowallet https://gitlab.com/dashpay/dash/-/jobs/10067158174 ALL | ✓ Passed | 1232 s (accumulated) Runtime: 243 s **-49%** [develop] linux64-tsan https://gitlab.com/dashpay/dash/-/jobs/10049432499 ALL | ✓ Passed | 10399 s (accumulated) Runtime: 2023 s [PR] linux64-tsan https://gitlab.com/dashpay/dash/-/jobs/10072993489 ALL | ✓ Passed | 8710 s (accumulated) Runtime: 1543 s **-25%** [develop] Functional tests on localhost (-O3, debug, no sanitizers, -j20): ALL | ✓ Passed | 6680 s (accumulated) Runtime: 372 s [PR] Functional tests on localhost (-O3, debug, no sanitizers, -j20): ALL | ✓ Passed | 4609 s (accumulated) Runtime: 365 s **Benefits of running locally in 20 parallel jobs are very slight. Accumulated time is decreased for 32% as expected, but total time is improved less than 2%.** It is because the slowest tests requires many quorums to be formed and they are still slow. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: PastaPastaPasta: utACK 0d9418e; hopefully it doesn't make tests flakey UdjinM6: utACK 0d9418e Tree-SHA512: 32405bd1f229af5146c96aea6031cee3f084d3ebfb3ec515ad743e79c3bc29a5c891d4330688d07b63b0e06ef7cd50240ab8b6d1a3939a56fe3e64a55918edd1
2 parents d9e2bad + 0d9418e commit ba93745

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

test/functional/feature_mnehf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def check_ehf_activated(self):
229229
self.bump_mocktime(1)
230230
self.generate(self.nodes[1], 1)
231231
return get_bip9_details(self.nodes[0], 'testdummy')['status'] == 'active'
232-
self.wait_until(lambda: check_ehf_activated(self))
232+
self.wait_until(lambda: check_ehf_activated(self), sleep=1)
233233

234234
if __name__ == '__main__':
235235
MnehfTest().main()

test/functional/test_framework/test_framework.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ def _initialize_mocktime(self, is_genesis):
896896
for node in self.nodes:
897897
node.mocktime = self.mocktime
898898

899-
def wait_until(self, test_function, timeout=60, lock=None, sleep=0.5, do_assert=True):
899+
def wait_until(self, test_function, timeout=60, lock=None, sleep=0.05, do_assert=True):
900900
return wait_until_helper(test_function, timeout=timeout, lock=lock, timeout_factor=self.options.timeout_factor, sleep=sleep, do_assert=do_assert)
901901

902902
# Private helper methods. These should not be accessed by the subclass test scripts.
@@ -1969,7 +1969,7 @@ def check_sporks_same():
19691969
self.bump_mocktime(1)
19701970
sporks = self.nodes[0].spork('show')
19711971
return all(node.spork('show') == sporks for node in self.nodes[1:])
1972-
self.wait_until(check_sporks_same, timeout=timeout, sleep=0.5)
1972+
self.wait_until(check_sporks_same, timeout=timeout, sleep=1)
19731973

19741974
def wait_for_quorum_connections(self, quorum_hash, expected_connections, mninfos, llmq_type_name="llmq_test", timeout = 60, wait_proc=None):
19751975
def check_quorum_connections():
@@ -2091,26 +2091,18 @@ def check_dkg_comitments():
20912091

20922092
self.wait_until(check_dkg_comitments, timeout=timeout, sleep=1)
20932093

2094-
def wait_for_quorum_list(self, quorum_hash, nodes, timeout=15, sleep=2, llmq_type_name="llmq_test"):
2094+
def wait_for_quorum_list(self, quorum_hash, nodes, timeout=15, llmq_type_name="llmq_test"):
20952095
def wait_func():
2096-
self.log.info("quorums: " + str(self.nodes[0].quorum("list")))
2097-
if quorum_hash in self.nodes[0].quorum("list")[llmq_type_name]:
2098-
return True
2099-
self.bump_mocktime(sleep, nodes=nodes)
2100-
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
2101-
return False
2102-
self.wait_until(wait_func, timeout=timeout, sleep=sleep)
2096+
return quorum_hash in self.nodes[0].quorum('list')[llmq_type_name]
2097+
self.log.info(f"quorums: {self.nodes[0].quorum('list')}")
2098+
self.wait_until(wait_func, timeout=timeout, sleep=0.05)
21032099

2104-
def wait_for_quorums_list(self, quorum_hash_0, quorum_hash_1, nodes, llmq_type_name="llmq_test", timeout=15, sleep=2):
2100+
def wait_for_quorums_list(self, quorum_hash_0, quorum_hash_1, nodes, llmq_type_name="llmq_test", timeout=15):
21052101
def wait_func():
2106-
self.log.info("h("+str(self.nodes[0].getblockcount())+") quorums: " + str(self.nodes[0].quorum("list")))
2107-
if quorum_hash_0 in self.nodes[0].quorum("list")[llmq_type_name]:
2108-
if quorum_hash_1 in self.nodes[0].quorum("list")[llmq_type_name]:
2109-
return True
2110-
self.bump_mocktime(sleep, nodes=nodes)
2111-
self.generate(self.nodes[0], 1, sync_fun=lambda: self.sync_blocks(nodes))
2112-
return False
2113-
self.wait_until(wait_func, timeout=timeout, sleep=sleep)
2102+
quorums = self.nodes[0].quorum("list")[llmq_type_name]
2103+
return quorum_hash_0 in quorums and quorum_hash_1 in quorums
2104+
self.log.info(f"h({self.nodes[0].getblockcount()}) quorums: {self.nodes[0].quorum('list')}")
2105+
self.wait_until(wait_func, timeout=timeout, sleep=0.05)
21142106

21152107
def move_blocks(self, nodes, num_blocks):
21162108
self.bump_mocktime(1, nodes=nodes)

test/functional/test_framework/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def satoshi_round(amount):
247247
return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
248248

249249

250-
def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'), sleep=0.5, timeout_factor=1.0, lock=None, do_assert=True, allow_exception=False):
250+
def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'), sleep=0.05, timeout_factor=1.0, lock=None, do_assert=True, allow_exception=False):
251251
"""Sleep until the predicate resolves to be True.
252252
253253
Warning: Note that this method is not recommended to be used in tests as it is

0 commit comments

Comments
 (0)