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

Function test_multiple_consecutive_ops

src/models/wal.rs:522–556  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

520
521 #[test]
522 fn test_multiple_consecutive_ops() {
523 let dir = tempdir().unwrap();
524 let version = 0;
525
526 let entries: Vec<VectorOp> = (0..10)
527 .map(|i| {
528 if i % 2 == 0 {
529 VectorOp::Upsert(vec![random_vector()])
530 } else {
531 VectorOp::Delete(VectorId::from(random_string(8)))
532 }
533 })
534 .collect();
535
536 {
537 let wal = WALFile::new().unwrap();
538 for op in &entries {
539 wal.append(op.clone()).unwrap();
540 }
541 wal.flush(dir.as_ref(), VersionNumber::from(version))
542 .unwrap();
543 }
544
545 {
546 let wal = reopen_wal(dir.path(), version);
547 for expected in &entries {
548 let read = wal.read().unwrap().expect("Expected some op");
549 match (expected, &read) {
550 (VectorOp::Upsert(ev), VectorOp::Upsert(rv)) => assert_eq!(ev[0].id, rv[0].id),
551 (VectorOp::Delete(eid), VectorOp::Delete(rid)) => assert_eq!(eid, rid),
552 _ => panic!("Mismatched operation types"),
553 }
554 }
555 }
556 }
557}

Callers

nothing calls this directly

Calls 6

reopen_walFunction · 0.85
cloneMethod · 0.80
random_stringFunction · 0.70
appendMethod · 0.45
flushMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected