chore: collab stress test - make number of edits configurable

This commit is contained in:
Bartosz Sypytkowski 2024-10-28 14:18:15 +01:00
parent 547761d899
commit 45c1583837
2 changed files with 3 additions and 10 deletions

View File

@ -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();

View File

@ -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
}
}