Line data Source code
1 : use tracing::info;
2 : use utils::lsn::Lsn;
3 :
4 : use crate::walproposer_sim::{log::init_logger, simulation::TestConfig};
5 :
6 : pub mod walproposer_sim;
7 :
8 : // Check that first start of sync_safekeepers() returns 0/0 on empty safekeepers.
9 : #[test]
10 6 : fn sync_empty_safekeepers() {
11 6 : let clock = init_logger();
12 6 : let config = TestConfig::new(Some(clock));
13 6 : let test = config.start(1337);
14 6 :
15 6 : let lsn = test.sync_safekeepers().unwrap();
16 6 : assert_eq!(lsn, Lsn(0));
17 6 : info!("Sucessfully synced empty safekeepers at 0/0");
18 :
19 6 : let lsn = test.sync_safekeepers().unwrap();
20 6 : assert_eq!(lsn, Lsn(0));
21 6 : info!("Sucessfully synced (again) empty safekeepers at 0/0");
22 6 : }
23 :
24 : // Check that there are no panics when we are writing and streaming WAL to safekeepers.
25 : #[test]
26 6 : fn run_walproposer_generate_wal() {
27 6 : let clock = init_logger();
28 6 : let config = TestConfig::new(Some(clock));
29 6 : let test = config.start(1337);
30 6 :
31 6 : let lsn = test.sync_safekeepers().unwrap();
32 6 : assert_eq!(lsn, Lsn(0));
33 6 : info!("Sucessfully synced empty safekeepers at 0/0");
34 :
35 6 : let mut wp = test.launch_walproposer(lsn);
36 6 :
37 6 : // wait for walproposer to start
38 6 : test.poll_for_duration(30);
39 :
40 : // just write some WAL
41 606 : for _ in 0..100 {
42 600 : wp.write_tx(1);
43 600 : test.poll_for_duration(5);
44 600 : }
45 6 : }
|