Skip to content

Commit

Permalink
cleanup postgres after run-tests.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed Oct 21, 2024
1 parent fbc8cda commit 2fbc8a5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
7 changes: 7 additions & 0 deletions nri-postgresql/cleanup-postgres.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

PGDATA="$(realpath ../_build/postgres/data)"
export PGDATA
export PGUSER=$USER
pg_ctl stop || true
rm -rf "$PGDATA"
3 changes: 1 addition & 2 deletions nri-postgresql/setup-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ mkdir -p "../_build/postgres/data"
PGDATA="$(realpath ../_build/postgres/data)"
export PGDATA
export PGUSER=$USER
pg_ctl stop || true
rm -rf "$PGDATA"
source cleanup-postgres.sh
initdb --no-locale --encoding=UTF8
pg_ctl start -o '-k . -p 5432'

Expand Down
28 changes: 14 additions & 14 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ popd
## block us, if it happens to be enabled. This is an instance for testing only.
mkdir -p ./_build/redis/data
redis-server --daemonize yes \
--dir ./_build/redis/data \
--save '' \
--stop-writes-on-bgsave-error no
--dir ./_build/redis/data \
--save '' \
--stop-writes-on-bgsave-error no

## start zookeeper (for kafka)
## start zookeeper (for kafka)
mkdir -p /tmp/zookeeper /tmp/zookeeper-logs
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
rm -rf /tmp/zookeeper/* /tmp/zookeeper-logs/*
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh start zoo_sample.cfg

## wait for zookeeper
echo "waiting for zookeeper to start"
until nc -vz localhost 2181
do
sleep 1
done
until nc -vz localhost 2181; do
sleep 1
done
echo "zookeeper available"

## start kafka
Expand All @@ -36,16 +35,17 @@ kafka-server-start.sh -daemon "$server_properties_path" --override num.partition

## wait for kafka
echo "waiting for kafka to start"
until nc -vz localhost 9092
do
sleep 1
until nc -vz localhost 9092; do
sleep 1
done
echo "kafka available"


cabal build --offline all
cabal test --offline all

# cleanup
kafka-server-stop.sh
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
ZOOPIDFILE=/tmp/zookeeper-logs/pid ZOO_LOG_DIR=/tmp/zookeeper-logs zkServer.sh stop zoo_sample.cfg
pushd nri-postgresql
source cleanup-postgres.sh
popd

0 comments on commit 2fbc8a5

Please sign in to comment.