Test for embedded wal acceptor

This commit is contained in:
Konstantin Knizhnik
2021-04-29 10:48:38 +03:00
parent 158d1bbbb4
commit 26115818b7
3 changed files with 43 additions and 1 deletions

View File

@@ -107,6 +107,14 @@ impl TestStorageControlPlane {
.join(",")
}
pub fn get_wal_acceptor_conn_info_quoted(&self) -> String {
self.wal_acceptors
.iter()
.map(|wa| format!("\"{}\"", wa.listen))
.collect::<Vec<String>>()
.join(",")
}
pub fn is_running(&self) -> bool {
self.test_done.load(Ordering::Relaxed)
}

View File

@@ -12,6 +12,40 @@ use std::{thread, time};
const DOWNTIME: u64 = 2;
#[test]
fn test_embedded_wal_proposer() {
let local_env = local_env::test_env("test_embedded_wal_proposer");
const REDUNDANCY: usize = 3;
let storage_cplane = TestStorageControlPlane::fault_tolerant(&local_env, REDUNDANCY);
let mut compute_cplane = ComputeControlPlane::local(&local_env, &storage_cplane.pageserver);
let wal_acceptors = storage_cplane.get_wal_acceptor_conn_info_quoted();
// start postgres
let maintli = storage_cplane.get_branch_timeline("main");
let node = compute_cplane.new_test_master_node(maintli);
node.append_conf("postgresql.conf", &format!("wal_acceptors={}\n", wal_acceptors));
node.start().unwrap();
// check basic work with table
node.safe_psql(
"postgres",
"CREATE TABLE t(key int primary key, value text)",
);
node.safe_psql(
"postgres",
"INSERT INTO t SELECT generate_series(1,100000), 'payload'",
);
let count: i64 = node
.safe_psql("postgres", "SELECT sum(key) FROM t")
.first()
.unwrap()
.get(0);
println!("sum = {}", count);
assert_eq!(count, 5000050000);
// check wal files equality
}
#[test]
fn test_acceptors_normal_work() {
let local_env = local_env::test_env("test_acceptors_normal_work");