Add multitenancy test for wal_acceptor

This commit is contained in:
Konstantin Knizhnik
2021-04-19 14:30:42 +03:00
parent 9809613c6f
commit 8879f747ee
2 changed files with 51 additions and 2 deletions

View File

@@ -113,7 +113,7 @@ impl ComputeControlPlane {
pub fn new_test_master_node(&mut self) -> Arc<PostgresNode> {
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() },

View File

@@ -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() {