Skip to content

Commit 8d4fcdd

Browse files
authored
test(ICRC_Index): FI-1617: Optimize retrieve_blocks_from_ledger_interval tests (#3236)
This PR proposes two things to optimize the `//rs/ledger_suite/icrc1/index-ng:index_ng_test_..._tests/retrieve_blocks_from_ledger_interval` tests which has seen P90 durations of over 5min: - Shorten the runtime of a couple of tests (from `10` to `4` cases for a `proptest`, and from `60s` to `10s` for a test checking the idle canister cycles consumption) - Limit the parallelism and increase the allocated resources, since the runtime of the test was increasing with increasing values of `--runs_per_test`
1 parent 0cc9215 commit 8d4fcdd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

rs/ledger_suite/icrc1/index-ng/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,14 @@ rust_test(
104104
conf["ledger_wasm"],
105105
],
106106
env = {
107+
"RUST_TEST_THREADS": "4",
107108
"CARGO_MANIFEST_DIR": "rs/ledger_suite/icrc1/index-ng",
108109
"IC_ICRC1_INDEX_NG_WASM_PATH": "$(rootpath " + conf["index_wasm"] + ")",
109110
"IC_ICRC1_INDEX_WASM_PATH": "$(rootpath //rs/ledger_suite/icrc1/index:index_canister.wasm)",
110111
"IC_ICRC1_LEDGER_WASM_PATH": "$(rootpath " + conf["ledger_wasm"] + ")",
111112
},
112113
extra_srcs = ["tests/common/mod.rs"],
114+
tags = ["cpu:4"],
113115
deps = [
114116
# Keep sorted.
115117
":index-ng",

rs/ledger_suite/icrc1/index-ng/tests/retrieve_blocks_from_ledger_interval.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ mod common;
2323
/// Corresponds to ic_icrc1_index_ng::DEFAULT_MAX_WAIT_TIME_IN_SECS
2424
const DEFAULT_MAX_WAIT_TIME_IN_SECS: u64 = 1;
2525
const GENESIS: Time = Time::from_nanos_since_unix_epoch(1_620_328_630_000_000_000);
26-
const IDLE_TIME_IN_SECS: u64 = 60;
26+
const IDLE_TIME_IN_SECS: u64 = 10;
2727
const INDEX_SYNC_TIME_TO_ADVANCE: Duration = Duration::from_secs(60);
2828
const MINTER_PRINCIPAL: Principal = Principal::from_slice(&[3_u8; 29]);
2929

@@ -172,7 +172,7 @@ fn should_sync_according_to_interval() {
172172
assert_eq!(ledger_chain_length, index_num_blocks_synced);
173173
}
174174

175-
let mut runner = TestRunner::new(proptest::test_runner::Config::with_cases(10));
175+
let mut runner = TestRunner::new(proptest::test_runner::Config::with_cases(4));
176176
runner
177177
.run(
178178
&(
@@ -375,8 +375,8 @@ fn should_consume_expected_amount_of_cycles() {
375375
initial_interval: Some(DEFAULT_MAX_WAIT_TIME_IN_SECS),
376376
upgrade_interval: Some(DEFAULT_MAX_WAIT_TIME_IN_SECS),
377377
assert_cost: |initial, upgrade| {
378-
const EXPECTED_LEDGER_CYCLES_CONSUMPTION: i128 = 706_075_016;
379-
const EXPECTED_INDEX_CYCLES_CONSUMPTION: i128 = 2_783_783_209;
378+
const EXPECTED_LEDGER_CYCLES_CONSUMPTION: i128 = 126_800_287;
379+
const EXPECTED_INDEX_CYCLES_CONSUMPTION: i128 = 474_143_016;
380380
for ledger_consumption in [initial.ledger, upgrade.ledger] {
381381
assert!(
382382
abs_relative_difference(

0 commit comments

Comments
 (0)