-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding GH Actions for test automation (#257)
* Adding test automation files to cli repo * Updating text in .yml file * Updating text in .yml file * Updating GH Action * Updating GH Action * Commenting out make step in Dockerfile file * Commenting out make step in Dockerfile file * Update run_unit_tests_on_docker.yml
- Loading branch information
1 parent
624fbfc
commit 00ba2b5
Showing
12 changed files
with
1,500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Docker tests | ||
run-name: ${{ github.actor }} is running the test schedules. | ||
on: | ||
push: | ||
|
||
pull_request: | ||
|
||
|
||
jobs: | ||
run-scripts: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-22.04] | ||
pgver: [14, 15, 16, 17] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout cli | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Set up Docker | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build Docker Image | ||
run: | | ||
docker build --build-arg PGVER=${{ matrix.pgver }} -t cli . | ||
- name: Run Docker Container | ||
run: | | ||
docker run -d --name cli -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 cli | ||
- name: Wait for PostgreSQL to be ready | ||
run: | | ||
echo "Waiting for Postgres to be ready..." | ||
for i in {1..30}; do | ||
if pg_isready -h localhost -p 5432 -U postgres; then | ||
echo "PostgreSQL is ready!" | ||
exit 0 | ||
fi | ||
echo "PostgreSQL is not ready yet. Retrying in 5 seconds..." | ||
sleep 5 | ||
done | ||
echo "PostgreSQL did not become ready in time. Exiting." | ||
exit 1 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
|
||
- name: Install dependencies | ||
run: | | ||
sudo apt -y update | ||
sudo apt install -y postgresql-client \ | ||
libpq-dev \ | ||
python3-dev \ | ||
python3-psycopg2 \ | ||
python3-dotenv | ||
- name: Run Test Harness (runner.py) | ||
run: | | ||
python test/runner.py -c test/t/lib/${{ matrix.pgver }}config.env -s test/schedule_files/script_file -k | ||
cat latest.log | ||
- name: Upload Log File as Artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: latest-log-${{ matrix.pgver }} | ||
path: latest.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ARG PGVER | ||
FROM postgres:$PGVER-alpine | ||
|
||
RUN apk add --no-cache \ | ||
make \ | ||
gcc \ | ||
musl-dev \ | ||
postgresql-dev \ | ||
git \ | ||
clang \ | ||
llvm | ||
|
||
WORKDIR /home/postgres/snowflake | ||
|
||
COPY . /home/postgres/snowflake/ | ||
|
||
#RUN USE_PGXS=1 make && USE_PGXS=1 make install | ||
|
||
EXPOSE 5432 | ||
|
||
ENTRYPOINT ["docker-entrypoint.sh"] | ||
|
||
CMD ["postgres"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
cd /home/pgedge | ||
. /home/pgedge/pgedge/pg16/pg16.env | ||
echo 'export LD_LIBRARY_PATH=/home/pgedge/pgedge/pg16/lib/$LD_LIBRARY_PATH' >> /home/pgedge/.bashrc | ||
echo 'export PATH=/home/test/pgedge/pg16/bin:$PATH' >> /home/pgedge/.bashrc | ||
. /home/pgedge/.bashrc | ||
|
||
echo "==========Recompiling Spock==========" | ||
cd ~/spock-private | ||
make clean && make -j16 && make install | ||
|
||
echo "==========Installing Spockbench==========" | ||
cd ~/spockbench | ||
sudo python3 setup.py install | ||
|
||
cd ~/pgedge | ||
sed -i '/log_min_messages/s/^#//g' data/pg16/postgresql.conf | ||
sed -i -e '/log_min_messages =/ s/= .*/= debug1/' data/pg16/postgresql.conf | ||
./pgedge restart | ||
|
||
while ! pg_isready -h /tmp; do | ||
echo "Waiting for PostgreSQL to become ready..." | ||
sleep 1 | ||
done | ||
|
||
psql -h /tmp -U $DBUSER -d $DBNAME -c "drop extension spock;" | ||
psql -h /tmp -U $DBUSER -d $DBNAME -c "drop schema public cascade;" | ||
psql -h /tmp -U $DBUSER -d $DBNAME -c "create schema public;" | ||
psql -h /tmp -U $DBUSER -d $DBNAME -c "create extension spock;" | ||
|
||
./pgedge restart | ||
|
||
while ! pg_isready -h /tmp; do | ||
echo "Waiting for PostgreSQL to become ready..." | ||
sleep 1 | ||
done | ||
|
||
echo "==========Creating tables and repsets==========" | ||
./pgedge spock node-create $HOSTNAME "host=$HOSTNAME user=pgedge dbname=demo" demo | ||
./pgedge spock repset-create demo_replication_set demo | ||
|
||
IFS=',' read -r -a peer_names <<< "$PEER_NAMES" | ||
|
||
for PEER_HOSTNAME in "${peer_names[@]}"; | ||
do | ||
while : | ||
do | ||
mapfile -t node_array < <(psql -A -t demo -h $PEER_HOSTNAME -c "SELECT node_name FROM spock.node;") | ||
for element in "${node_array[@]}"; | ||
do | ||
if [[ "$element" == "$PEER_HOSTNAME" ]]; then | ||
break 2 | ||
fi | ||
done | ||
sleep 1 | ||
echo "Waiting for $PEER_HOSTNAME..." | ||
done | ||
done | ||
|
||
# TODO: Re-introduce parallel slots at a later point when the apply worker restarts are handled correctly | ||
# and transactions are not skipped on restart in parallel mode | ||
./pgedge spock sub-create sub_${peer_names[0]}$HOSTNAME "host=${peer_names[0]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[0]}$HOSTNAME"_1 "host=${peer_names[0]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[0]}$HOSTNAME"_2 "host=${peer_names[0]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[0]}$HOSTNAME"_3 "host=${peer_names[0]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[0]}$HOSTNAME"_4 "host=${peer_names[0]} port=5432 user=pgedge dbname=demo" demo | ||
|
||
./pgedge spock sub-create sub_${peer_names[1]}$HOSTNAME "host=${peer_names[1]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[1]}$HOSTNAME"_1 "host=${peer_names[1]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[1]}$HOSTNAME"_2 "host=${peer_names[1]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[1]}$HOSTNAME"_3 "host=${peer_names[1]} port=5432 user=pgedge dbname=demo" demo | ||
#./pgedge spock sub-create "sub_${peer_names[1]}$HOSTNAME"_4 "host=${peer_names[1]} port=5432 user=pgedge dbname=demo" demo | ||
|
||
psql -U admin -h /tmp -d demo -c "create table t1 (id serial primary key, data int8);" | ||
psql -U admin -h /tmp -d demo -c "create table t2 (id serial primary key, data int8);" | ||
psql -U admin -h /tmp -d demo -c "alter table t1 alter column data set (log_old_value=true, delta_apply_function=spock.delta_apply);" | ||
|
||
./pgedge spock sub-add-repset sub_${peer_names[0]}$HOSTNAME demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[0]}$HOSTNAME"_1 demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[0]}$HOSTNAME"_2 demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[0]}$HOSTNAME"_3 demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[0]}$HOSTNAME"_4 demo_replication_set demo | ||
|
||
./pgedge spock sub-add-repset sub_${peer_names[1]}$HOSTNAME demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[1]}$HOSTNAME"_1 demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[1]}$HOSTNAME"_2 demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[1]}$HOSTNAME"_3 demo_replication_set demo | ||
#./pgedge spock sub-add-repset "sub_${peer_names[1]}$HOSTNAME"_4 demo_replication_set demo | ||
|
||
|
||
cd /home/pgedge && ./run-tests.sh $peer_names |
Oops, something went wrong.