1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-25 20:01:09 +00:00

try to reduce test failures

This commit is contained in:
Felix Ableitner 2024-02-09 11:08:57 +01:00
parent 3adcd98b3f
commit 36995bfcc7
3 changed files with 16 additions and 9 deletions

View file

@ -19,7 +19,6 @@ BETA_DB_PATH="$DB_FOLDER/beta"
ALPHA_DB_URL="postgresql://ibis:password@/ibis?host=$ALPHA_DB_PATH" ALPHA_DB_URL="postgresql://ibis:password@/ibis?host=$ALPHA_DB_PATH"
BETA_DB_URL="postgresql://ibis:password@/ibis?host=$BETA_DB_PATH" BETA_DB_URL="postgresql://ibis:password@/ibis?host=$BETA_DB_PATH"
echo $ALPHA_DB_URL
# get rid of processes leftover from previous runs # get rid of processes leftover from previous runs
killall ibis || true killall ibis || true
@ -32,3 +31,6 @@ CARGO_TARGET_DIR=target/frontend trunk build
sh -c "IBIS__BIND=127.0.0.1:8070 IBIS__FEDERATION__DOMAIN=ibis-alpha:8070 IBIS__DATABASE_URL=$ALPHA_DB_URL cargo run" & sh -c "IBIS__BIND=127.0.0.1:8070 IBIS__FEDERATION__DOMAIN=ibis-alpha:8070 IBIS__DATABASE_URL=$ALPHA_DB_URL cargo run" &
sh -c "IBIS__BIND=127.0.0.1:8080 IBIS__FEDERATION__DOMAIN=ibis-beta:8080 IBIS__DATABASE_URL=$BETA_DB_URL cargo run" & sh -c "IBIS__BIND=127.0.0.1:8080 IBIS__FEDERATION__DOMAIN=ibis-beta:8080 IBIS__DATABASE_URL=$BETA_DB_URL cargo run" &
) )
./tests/scripts/stop_dev_db.sh $ALPHA_DB_PATH
./tests/scripts/stop_dev_db.sh $BETA_DB_PATH

View file

@ -5,7 +5,7 @@ use ibis_lib::frontend::api::ApiClient;
use ibis_lib::frontend::error::MyResult; use ibis_lib::frontend::error::MyResult;
use reqwest::ClientBuilder; use reqwest::ClientBuilder;
use std::env::current_dir; use std::env::current_dir;
use std::fs::create_dir_all; use std::fs::{create_dir_all, remove_dir_all};
use std::ops::Deref; use std::ops::Deref;
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::sync::atomic::{AtomicI32, Ordering}; use std::sync::atomic::{AtomicI32, Ordering};
@ -90,11 +90,15 @@ pub struct IbisInstance {
impl IbisInstance { impl IbisInstance {
fn prepare_db(db_path: String) -> std::thread::JoinHandle<()> { fn prepare_db(db_path: String) -> std::thread::JoinHandle<()> {
// stop any db leftover from previous run
Self::stop_internal(db_path.clone());
// remove old db
remove_dir_all(&db_path).unwrap();
spawn(move || { spawn(move || {
Command::new("./tests/scripts/start_dev_db.sh") Command::new("./tests/scripts/start_dev_db.sh")
.arg(&db_path) .arg(&db_path)
.stdout(Stdio::null()) .stdout(Stdio::inherit())
.stderr(Stdio::null()) .stderr(Stdio::inherit())
.output() .output()
.unwrap(); .unwrap();
}) })
@ -135,9 +139,13 @@ impl IbisInstance {
fn stop(self) -> std::thread::JoinHandle<()> { fn stop(self) -> std::thread::JoinHandle<()> {
self.db_handle.abort(); self.db_handle.abort();
Self::stop_internal(self.db_path)
}
fn stop_internal(db_path: String) -> std::thread::JoinHandle<()> {
spawn(move || { spawn(move || {
Command::new("./tests/scripts/stop_dev_db.sh") Command::new("./tests/scripts/stop_dev_db.sh")
.arg(&self.db_path) .arg(db_path)
.stdout(Stdio::null()) .stdout(Stdio::null())
.stderr(Stdio::null()) .stderr(Stdio::null())
.output() .output()

View file

@ -12,9 +12,6 @@ then
pg_ctl stop pg_ctl stop
fi fi
# Remove any leftover data from revious run
rm -rf $1
# Create cluster # Create cluster
initdb --username=postgres --auth=trust --no-instructions initdb --username=postgres --auth=trust --no-instructions