From 45c1583837e8bd19f0ca9f624714b2ca903b07d6 Mon Sep 17 00:00:00 2001 From: Bartosz Sypytkowski Date: Mon, 28 Oct 2024 14:18:15 +0100 Subject: [PATCH] chore: collab stress test - make number of edits configurable --- tests/collab/stress_test.rs | 2 +- tests/collab/util.rs | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/collab/stress_test.rs b/tests/collab/stress_test.rs index ea802c31..5e33b01d 100644 --- a/tests/collab/stress_test.rs +++ b/tests/collab/stress_test.rs @@ -46,7 +46,7 @@ async fn run_multiple_text_edits() { // run test scenario let collab = writer.collabs.get(&object_id).unwrap().collab.clone(); - let expected = test_scenario.execute(collab).await; + let expected = test_scenario.execute(collab, 50_000).await; // wait for the writer to complete sync writer.wait_object_sync_complete(&object_id).await.unwrap(); diff --git a/tests/collab/util.rs b/tests/collab/util.rs index 50d25e04..7fc6daa5 100644 --- a/tests/collab/util.rs +++ b/tests/collab/util.rs @@ -133,13 +133,8 @@ impl TestScenario { data } - pub async fn execute(&self, collab: CollabRef) -> String { - let len = self.txns.len(); - let start = Instant::now(); - for (i, t) in self.txns.iter().enumerate() { - if i % 10_000 == 0 { - tracing::info!("step #{}/{} - {:?}", i + 1, len, start.elapsed()); - } + pub async fn execute(&self, collab: CollabRef, step_count: usize) -> String { + for t in self.txns.iter().take(step_count) { let mut lock = collab.write().await; let collab = lock.borrow_mut(); let mut txn = collab.context.transact_mut(); @@ -159,13 +154,11 @@ impl TestScenario { } // validate after applying all patches - let expected = self.end_content.as_str(); let lock = collab.read().await; let collab = lock.borrow(); let txn = collab.context.transact(); let txt: TextRef = collab.data.get_with_txn(&txn, "text-id").unwrap(); let actual = txt.get_string(&txn); - assert_eq!(actual, expected); actual } }