()
| 472 | |
| 473 | #[test] |
| 474 | fn cardinality_eviction() { |
| 475 | let config = MemtableConfig { |
| 476 | max_memory_bytes: 10 * 1024 * 1024, |
| 477 | max_series: 3, |
| 478 | hard_memory_limit: 20 * 1024 * 1024, |
| 479 | }; |
| 480 | let mut mt = TimeseriesMemtable::with_config(config); |
| 481 | |
| 482 | // Insert 3 series (at limit). |
| 483 | for id in 0..3 { |
| 484 | mt.ingest_metric( |
| 485 | id, |
| 486 | MetricSample { |
| 487 | timestamp_ms: 1000 + id as i64, |
| 488 | value: 1.0, |
| 489 | }, |
| 490 | ); |
| 491 | } |
| 492 | assert_eq!(mt.series_count(), 3); |
| 493 | assert_eq!(mt.eviction_count(), 0); |
| 494 | |
| 495 | // Insert a 4th series — should evict the coldest. |
| 496 | mt.ingest_metric( |
| 497 | 99, |
| 498 | MetricSample { |
| 499 | timestamp_ms: 5000, |
| 500 | value: 99.0, |
| 501 | }, |
| 502 | ); |
| 503 | assert_eq!(mt.series_count(), 3); |
| 504 | assert_eq!(mt.eviction_count(), 1); |
| 505 | |
| 506 | // Drain should include the evicted series. |
| 507 | let flushed = mt.drain(); |
| 508 | assert_eq!(flushed.len(), 4); // 3 active + 1 evicted |
| 509 | } |
| 510 | |
| 511 | #[test] |
| 512 | fn hard_limit_rejection() { |
nothing calls this directly
no test coverage detected