run tests with github actions

This commit is contained in:
Stas Kelvich
2021-03-29 22:40:10 +03:00
parent 5912d0b9da
commit 98b0d3d32c
5 changed files with 50 additions and 15 deletions

30
.github/workflows/testing.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: regression check
on: [push, pull_request]
jobs:
regression-check:
name: run regrsession test suite
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Install postgres dependencies
run: |
sudo apt install build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libcurl-dev
- name: Build postgres
run: |
pgbuild.sh
- name: Install rust
run: |
sudo apt install -y cargo
- name: Run test
run: |
cargo test --test test_pageserver -- --nocapture

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
/target
/tmp_check
/tmp_install

4
.gitmodules vendored
View File

@@ -12,5 +12,5 @@
url = https://github.com/libzenith/pageserver
[submodule "vendor/postgres"]
path = vendor/postgres
url = https://github.com/libzenith/vendor-postgres
branch = zenith
url = https://github.com/libzenith/postgres
branch = main

View File

@@ -10,13 +10,13 @@
#
# 2) installs postgres to REPO_ROOT/tmp_install/
#
REPO_ROOT=$(dirname "$0")/..
REPO_ROOT=$(dirname "$0")
REPO_ROOT="`( cd \"$REPO_ROOT\" && pwd )`"
# configure
mkdir -p $REPO_ROOT/tmp_install/build
cd $REPO_ROOT/tmp_install/build
../../configure CFLAGS='-O0' --enable-debug --enable-cassert \
../../vendor/postgres/configure CFLAGS='-O0' --enable-debug --enable-cassert \
--enable-depend --with-libxml --prefix=/
# compile

View File

@@ -22,17 +22,15 @@ use lazy_static::lazy_static;
lazy_static! {
// postgres would be there if it was build by 'make postgres' here in the repo
pub static ref PG_BIN_DIR : PathBuf = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../tmp_install/bin");
.join("tmp_install/bin");
pub static ref PG_LIB_DIR : PathBuf = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../tmp_install/lib");
.join("tmp_install/lib");
pub static ref CARGO_BIN_DIR : PathBuf = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("./target/debug/");
.join("target/debug/");
pub static ref TEST_WORKDIR : PathBuf = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("./tmp_check");
// XXX: drop dots
.join("tmp_check");
}
//
@@ -86,10 +84,14 @@ impl PageServerNode {
// TODO: make wal-redo-postgres workable without data directory?
pub fn init(&self) {
fs::create_dir(self.data_dir.clone()).unwrap();
fs::create_dir_all(self.data_dir.clone()).unwrap();
let datadir_path = self.data_dir.join("wal_redo_pgdata");
fs::remove_dir_all(datadir_path.to_str().unwrap()).ok();
let initdb = Command::new(PG_BIN_DIR.join("initdb"))
.args(&["-D", self.data_dir.join("wal_redo_pgdata").to_str().unwrap()])
.args(&["-D", datadir_path.to_str().unwrap()])
.arg("-N")
.env_clear()
.env("LD_LIBRARY_PATH", PG_LIB_DIR.to_str().unwrap())
.status()
@@ -112,7 +114,7 @@ impl PageServerNode {
.env("PATH", PG_BIN_DIR.to_str().unwrap()) // path to postres-wal-redo binary
.env("PGDATA", self.data_dir.join("wal_redo_pgdata")) // postres-wal-redo pgdata
.status()
.expect("failed to execute initdb");
.expect("failed to start pageserver");
if !status.success() {
panic!("pageserver start failed");
@@ -191,10 +193,12 @@ impl ComputeControlPlane {
let node = self.nodes.last().unwrap();
// initialize data directory
fs::remove_dir_all(node.pgdata.to_str().unwrap()).ok();
let initdb_path = self.pg_bin_dir.join("initdb");
println!("initdb_path: {}", initdb_path.to_str().unwrap());
let initdb = Command::new(initdb_path)
.args(&["-D", node.pgdata.to_str().unwrap()])
.arg("-N")
.env_clear()
.env("LD_LIBRARY_PATH", PG_LIB_DIR.to_str().unwrap())
.status()
@@ -319,8 +323,8 @@ impl PostgresNode {
impl Drop for PostgresNode {
// destructor to clean up state after test is done
// TODO: leave everything in place if test is failed
// TODO: put logs to a separate location to run `tail -F` on them
// XXX: we may detect failed test by setting some flag in catch_unwind()
// and checking it here. But let just clean datadirs on start.
fn drop(&mut self) {
self.pg_ctl("stop", false);
// fs::remove_dir_all(self.pgdata.clone()).unwrap();