()
| 106 | |
| 107 | #[test] |
| 108 | fn bootstrap_creates_cluster() { |
| 109 | let (_dir, catalog) = temp_catalog(); |
| 110 | let config = ClusterConfig { |
| 111 | node_id: 1, |
| 112 | listen_addr: "127.0.0.1:9400".parse().unwrap(), |
| 113 | seed_nodes: vec!["127.0.0.1:9400".parse().unwrap()], |
| 114 | num_groups: 4, |
| 115 | replication_factor: 1, |
| 116 | data_dir: _dir.path().to_path_buf(), |
| 117 | force_bootstrap: false, |
| 118 | join_retry: Default::default(), |
| 119 | swim_udp_addr: None, |
| 120 | election_timeout_min: Duration::from_millis(150), |
| 121 | election_timeout_max: Duration::from_millis(300), |
| 122 | install_snapshot_chunk_bytes: 4 * 1024 * 1024, |
| 123 | orphan_partial_max_age_secs: 300, |
| 124 | }; |
| 125 | |
| 126 | let state = bootstrap(&config, &catalog, None).unwrap(); |
| 127 | let topo = state.topology.read().unwrap(); |
| 128 | let routing = state.routing.read().unwrap(); |
| 129 | let multi_raft = state.multi_raft.lock().unwrap(); |
| 130 | |
| 131 | assert_eq!(topo.node_count(), 1); |
| 132 | assert_eq!(topo.active_nodes().len(), 1); |
| 133 | // num_groups() includes the metadata group (id 0); 4 data groups + metadata = 5. |
| 134 | assert_eq!(routing.num_groups(), 5); |
| 135 | assert_eq!(multi_raft.group_count(), 5); |
| 136 | |
| 137 | assert!(catalog.is_bootstrapped().unwrap()); |
| 138 | let settings = catalog.load_cluster_settings().unwrap().unwrap(); |
| 139 | assert_eq!(settings.replication_factor, 1); // clamped to 1 for single node |
| 140 | let loaded_topo = catalog.load_topology().unwrap().unwrap(); |
| 141 | assert_eq!(loaded_topo.node_count(), 1); |
| 142 | let loaded_rt = catalog.load_routing().unwrap().unwrap(); |
| 143 | assert_eq!(loaded_rt.num_groups(), 5); |
| 144 | } |
| 145 | } |
nothing calls this directly
no test coverage detected