mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-04 12:02:55 +00:00
Add multitenancy test for wal_acceptor
This commit is contained in:
@@ -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() },
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user