| 209 | |
| 210 | #[test] |
| 211 | fn single_thread_group_commit() { |
| 212 | let dir = tempfile::tempdir().unwrap(); |
| 213 | let path = dir.path().join("test.wal"); |
| 214 | |
| 215 | let writer = Mutex::new(WalWriter::open_without_direct_io(&path).unwrap()); |
| 216 | let gc = GroupCommitter::new(); |
| 217 | |
| 218 | let result = gc |
| 219 | .submit( |
| 220 | &writer, |
| 221 | PendingWrite { |
| 222 | record_type: RecordType::Put as u32, |
| 223 | tenant_id: 1, |
| 224 | vshard_id: 0, |
| 225 | database_id: 0, |
| 226 | payload: b"hello".to_vec(), |
| 227 | }, |
| 228 | ) |
| 229 | .unwrap(); |
| 230 | |
| 231 | assert!(result.durable); |
| 232 | assert_eq!(result.lsn, 1); |
| 233 | assert_eq!(gc.durable_lsn(), 1); |
| 234 | |
| 235 | // Verify the record is readable. |
| 236 | let reader = WalReader::open(&path).unwrap(); |
| 237 | let records: Vec<_> = reader |
| 238 | .records() |
| 239 | .collect::<crate::error::Result<_>>() |
| 240 | .unwrap(); |
| 241 | assert_eq!(records.len(), 1); |
| 242 | assert_eq!(records[0].payload, b"hello"); |
| 243 | } |
| 244 | |
| 245 | #[test] |
| 246 | fn concurrent_group_commit() { |