MCPcopy Create free account
hub / github.com/cosdata/cosdata / test_multiple_consecutive_ops

Function test_multiple_consecutive_ops

src/models/durable_wal.rs:300–334  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

298
299 #[test]
300 fn test_multiple_consecutive_ops() {
301 let dir = tempdir().unwrap();
302 let version = 0;
303
304 let entries: Vec<VectorOp> = (0..10)
305 .map(|i| {
306 if i % 2 == 0 {
307 VectorOp::Upsert(vec![random_vector()])
308 } else {
309 VectorOp::Delete(VectorId::from(random_string(8)))
310 }
311 })
312 .collect();
313
314 let mut wal = DurableWALFile::new(dir.path(), VersionNumber::from(version)).unwrap();
315 for op in &entries {
316 wal.append(op.clone()).unwrap();
317 }
318 wal.flush().unwrap();
319
320 let wal = WALFile::from_existing(dir.path(), VersionNumber::from(version)).unwrap();
321 let mut ops = Vec::new();
322 while let Some(op) = wal.read().unwrap() {
323 ops.push(op);
324 }
325 assert_eq!(ops.len(), entries.len());
326
327 for (expected, actual) in entries.iter().zip(ops.iter()) {
328 match (expected, actual) {
329 (VectorOp::Upsert(ev), VectorOp::Upsert(rv)) => assert_eq!(ev[0].id, rv[0].id),
330 (VectorOp::Delete(eid), VectorOp::Delete(rid)) => assert_eq!(eid, rid),
331 _ => panic!("Mismatched operation types"),
332 }
333 }
334 }
335
336 #[test]
337 fn test_durability() {

Callers

nothing calls this directly

Calls 7

cloneMethod · 0.80
random_stringFunction · 0.70
appendMethod · 0.45
flushMethod · 0.45
readMethod · 0.45
pushMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected