chore: collab stress test - make number of edits configurable
This commit is contained in:
parent
547761d899
commit
45c1583837
|
|
@ -46,7 +46,7 @@ async fn run_multiple_text_edits() {
|
||||||
|
|
||||||
// run test scenario
|
// run test scenario
|
||||||
let collab = writer.collabs.get(&object_id).unwrap().collab.clone();
|
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
|
// wait for the writer to complete sync
|
||||||
writer.wait_object_sync_complete(&object_id).await.unwrap();
|
writer.wait_object_sync_complete(&object_id).await.unwrap();
|
||||||
|
|
|
||||||
|
|
@ -133,13 +133,8 @@ impl TestScenario {
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(&self, collab: CollabRef) -> String {
|
pub async fn execute(&self, collab: CollabRef, step_count: usize) -> String {
|
||||||
let len = self.txns.len();
|
for t in self.txns.iter().take(step_count) {
|
||||||
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());
|
|
||||||
}
|
|
||||||
let mut lock = collab.write().await;
|
let mut lock = collab.write().await;
|
||||||
let collab = lock.borrow_mut();
|
let collab = lock.borrow_mut();
|
||||||
let mut txn = collab.context.transact_mut();
|
let mut txn = collab.context.transact_mut();
|
||||||
|
|
@ -159,13 +154,11 @@ impl TestScenario {
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate after applying all patches
|
// validate after applying all patches
|
||||||
let expected = self.end_content.as_str();
|
|
||||||
let lock = collab.read().await;
|
let lock = collab.read().await;
|
||||||
let collab = lock.borrow();
|
let collab = lock.borrow();
|
||||||
let txn = collab.context.transact();
|
let txn = collab.context.transact();
|
||||||
let txt: TextRef = collab.data.get_with_txn(&txn, "text-id").unwrap();
|
let txt: TextRef = collab.data.get_with_txn(&txn, "text-id").unwrap();
|
||||||
let actual = txt.get_string(&txn);
|
let actual = txt.get_string(&txn);
|
||||||
assert_eq!(actual, expected);
|
|
||||||
actual
|
actual
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue