add regression tests runner

This commit is contained in:
Stas Kelvich
2021-03-31 11:58:57 +03:00
parent 91700e56de
commit 1348915655
3 changed files with 54 additions and 5 deletions

View File

@@ -235,8 +235,8 @@ impl ComputeControlPlane {
pub struct PostgresNode {
_node_id: usize,
port: u16,
ip: IpAddr,
pub port: u16,
pub ip: IpAddr,
pgdata: PathBuf,
pg_bin_dir: PathBuf,
}
@@ -269,6 +269,8 @@ impl PostgresNode {
if check_ok && !pg_ctl.success() {
panic!("pg_ctl failed");
}
self.safe_psql("postgres", "CREATE DATABASE regression");
}
pub fn start(&self) {
@@ -289,7 +291,7 @@ impl PostgresNode {
}
// XXX: cache that in control plane
fn whoami(&self) -> String {
pub fn whoami(&self) -> String {
let output = Command::new("whoami")
.output()
.expect("failed to execute whoami");
@@ -330,3 +332,28 @@ impl Drop for PostgresNode {
// fs::remove_dir_all(self.pgdata.clone()).unwrap();
}
}
pub fn regress_check(pg : &PostgresNode) {
let regress_build_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("tmp_install/build/src/test/regress");
let regress_src_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("vendor/postgres/src/test/regress");
let _regress_check = Command::new(regress_build_path.join("pg_regress"))
.args(&[
"--bindir=''",
"--use-existing",
format!("--bindir={}", PG_BIN_DIR.to_str().unwrap()).as_str(),
format!("--dlpath={}", regress_build_path.to_str().unwrap()).as_str(),
format!("--schedule={}", regress_src_path.join("parallel_schedule").to_str().unwrap()).as_str(),
format!("--inputdir={}", regress_src_path.to_str().unwrap()).as_str(),
])
.env_clear()
.env("LD_LIBRARY_PATH", PG_LIB_DIR.to_str().unwrap())
.env("PGPORT", pg.port.to_string())
.env("PGUSER", pg.whoami())
.env("PGHOST", pg.ip.to_string())
.status()
.expect("pg_regress failed");
}

View File

@@ -1,5 +1,4 @@
use pageserver::control_plane::ComputeControlPlane;
use pageserver::control_plane::StorageControlPlane;
#[test]
fn test_actions() {

View File

@@ -44,7 +44,30 @@ fn test_redo_cases() {
// Runs pg_regress on a compute node
#[test]
fn test_regress() {}
fn test_regress() {
// Allocate postgres instance, but don't start
let mut compute_cplane = ComputeControlPlane::local();
let node = compute_cplane.new_vanilla_node();
// Start pageserver that reads WAL directly from that postgres
let storage_cplane = StorageControlPlane::one_page_server(node.connstr());
let pageserver_addr = storage_cplane.page_server_addr();
// Configure that node to take pages from pageserver
node.append_conf("postgresql.conf", format!("\
page_server_connstring = 'host={} port={}'\n\
", pageserver_addr.ip(), pageserver_addr.port()).as_str());
// start postgres
node.start();
println!("await pageserver connection...");
sleep(Duration::from_secs(3));
//////////////////////////////////////////////////////////////////
pageserver::control_plane::regress_check(node);
}
// Runs recovery with minio
#[test]