diff --git a/control_plane/src/compute.rs b/control_plane/src/compute.rs index 1d0db731f5..b39d901be7 100644 --- a/control_plane/src/compute.rs +++ b/control_plane/src/compute.rs @@ -113,7 +113,7 @@ impl ComputeControlPlane { pub fn new_test_master_node(&mut self) -> Arc { let node = self.new_vanilla_node(true).unwrap(); - + println!("Create vanilla node at {:?}", node.address); node.append_conf( "postgresql.conf", "synchronous_standby_names = 'safekeeper_proxy'\n", @@ -405,7 +405,9 @@ impl PostgresNode { .args(&["-h", &self.address.ip().to_string()]) .args(&["-p", &self.address.port().to_string()]) .arg("-v") - .stderr(File::create(self.env.data_dir.join("safepkeeper_proxy.log")).unwrap()) + .stderr(OpenOptions::new() + .append(true) + .open(self.env.data_dir.join("safepkeeper_proxy.log")).unwrap()) .spawn() { Ok(child) => WalProposerNode { pid: child.id() }, diff --git a/integration_tests/tests/test_wal_acceptor.rs b/integration_tests/tests/test_wal_acceptor.rs index 523c568bb4..f4f7675b07 100644 --- a/integration_tests/tests/test_wal_acceptor.rs +++ b/integration_tests/tests/test_wal_acceptor.rs @@ -41,6 +41,53 @@ fn test_acceptors_normal_work() { // check wal files equality } +#[test] +fn test_multitenancy() { + // Start pageserver that reads WAL directly from that postgres + const REDUNDANCY: usize = 3; + const N_NODES: usize = 5; + let storage_cplane = TestStorageControlPlane::fault_tolerant(REDUNDANCY); + let mut compute_cplane = ComputeControlPlane::local(&storage_cplane.pageserver); + let wal_acceptors = storage_cplane.get_wal_acceptor_conn_info(); + + // start postgres + let mut nodes = Vec::new(); + let mut proxies = Vec::new(); + for _ in 0..N_NODES { + let node = compute_cplane.new_test_master_node(); + nodes.push(node); + nodes.last().unwrap().start().unwrap(); + proxies.push(nodes.last().unwrap().start_proxy(wal_acceptors.clone())); + } + + // create schema + for node in &nodes { + node.safe_psql( + "postgres", + "CREATE TABLE t(key int primary key, value text)", + ); + } + + // Populate data + for node in &nodes { + node.safe_psql( + "postgres", + "INSERT INTO t SELECT generate_series(1,100000), 'payload'", + ); + } + + // Check data + for node in &nodes { + let count: i64 = node + .safe_psql("postgres", "SELECT sum(key) FROM t") + .first() + .unwrap() + .get(0); + println!("sum = {}", count); + assert_eq!(count, 5000050000); + } +} + // Majority is always alive #[test] fn test_acceptors_restarts() {