()
| 333 | |
| 334 | #[test] |
| 335 | fn snapshot_needed_after_compaction() { |
| 336 | let config = test_config(1, vec![2, 3]); |
| 337 | let mut node = RaftNode::new(config, MemStorage::new()); |
| 338 | |
| 339 | node.election_deadline = Instant::now() - Duration::from_millis(1); |
| 340 | node.tick(); |
| 341 | let _ready = node.take_ready(); |
| 342 | let resp = crate::message::RequestVoteResponse { |
| 343 | term: 1, |
| 344 | vote_granted: true, |
| 345 | }; |
| 346 | node.handle_request_vote_response(2, &resp); |
| 347 | assert_eq!(node.role(), NodeRole::Leader); |
| 348 | let _ = node.take_ready(); |
| 349 | |
| 350 | for i in 0..9 { |
| 351 | node.propose(vec![i]).unwrap(); |
| 352 | } |
| 353 | let _ = node.take_ready(); |
| 354 | |
| 355 | node.log.apply_snapshot(8, 1); |
| 356 | |
| 357 | node.replicate_to_all(); |
| 358 | let ready = node.take_ready(); |
| 359 | |
| 360 | assert!( |
| 361 | !ready.snapshots_needed.is_empty(), |
| 362 | "expected snapshots_needed to be non-empty" |
| 363 | ); |
| 364 | } |
| 365 | |
| 366 | #[test] |
| 367 | fn starts_as_learner_role() { |
nothing calls this directly
no test coverage detected