()
| 235 | |
| 236 | #[test] |
| 237 | fn full_lifecycle() { |
| 238 | let mut m = test_migration(); |
| 239 | assert!(!m.is_active()); |
| 240 | |
| 241 | // Phase 1. |
| 242 | m.start_base_copy(1_000_000); |
| 243 | assert!(m.is_active()); |
| 244 | m.update_base_copy(500_000); |
| 245 | if let MigrationPhase::BaseCopy { |
| 246 | bytes_transferred, .. |
| 247 | } = m.phase |
| 248 | { |
| 249 | assert_eq!(bytes_transferred, 500_000); |
| 250 | } else { |
| 251 | panic!("expected BaseCopy"); |
| 252 | } |
| 253 | |
| 254 | // Phase 2. |
| 255 | m.start_wal_catchup(100, 200); |
| 256 | assert!(!m.is_catchup_ready()); |
| 257 | m.update_wal_catchup(195, 200); |
| 258 | assert!(m.is_catchup_ready()); |
| 259 | |
| 260 | // Phase 3. |
| 261 | m.start_cutover(500).unwrap(); |
| 262 | assert!(matches!(m.phase, MigrationPhase::AtomicCutOver { .. })); |
| 263 | |
| 264 | // Complete. |
| 265 | m.complete(450); |
| 266 | assert!(!m.is_active()); |
| 267 | if let MigrationPhase::Completed { |
| 268 | pause_duration_us, .. |
| 269 | } = m.phase |
| 270 | { |
| 271 | assert_eq!(pause_duration_us, 450); |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | #[test] |
| 276 | fn pause_budget_exceeded() { |
nothing calls this directly
no test coverage detected