Update scripts to run unit tests using TimescaleDB

This commit is contained in:
Prathamesh Musale 2022-05-19 10:13:33 +05:30
parent 9676690a2d
commit dc14656bbc
3 changed files with 48 additions and 23 deletions

View File

@ -8,22 +8,30 @@ temp_dir=$(mktemp -d)
cd $temp_dir cd $temp_dir
git clone -b $(cat /tmp/git_head_ref) "https://github.com/$(cat /tmp/git_repository).git" git clone -b $(cat /tmp/git_head_ref) "https://github.com/$(cat /tmp/git_repository).git"
cd ipld-eth-server cd ipld-eth-server
mkdir -p out
## Remove the branch and github related info. This way future runs wont be confused. ## Remove the branch and github related info. This way future runs wont be confused.
rm -f /tmp/git_head_ref /tmp/git_repository rm -f /tmp/git_head_ref /tmp/git_repository
# Spin up DB # Remove existing docker-tsdb directory
docker-compose up -d ipld-eth-db rm -rf out/docker-tsdb/
trap "docker-compose down --remove-orphans; cd $start_dir ; rm -r $temp_dir" SIGINT SIGTERM ERR
sleep 10 # Copy over files to setup TimescaleDB
ID=$(docker create vulcanize/ipld-eth-db:v4.1.1-alpha)
docker cp $ID:/app/docker-tsdb out/docker-tsdb/
docker rm -v $ID
# Spin up TimescaleDB
docker-compose -f out/docker-tsdb/docker-compose.test.yml -f docker-compose.yml up ipld-eth-db
trap "docker-compose -f out/docker-tsdb/docker-compose.test.yml -f docker-compose.yml down --remove-orphans --volumes; cd $start_dir ; rm -r $temp_dir" SIGINT SIGTERM ERR
sleep 45
# Remove old logs so there's no confusion, then run test # Remove old logs so there's no confusion, then run test
rm -f /tmp/test.log /tmp/return_test.txt rm -f /tmp/test.log /tmp/return_test.txt
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test > /tmp/test.log PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8066 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing_v4 make test > /tmp/test.log
echo $? > /tmp/return_test.txt echo $? > /tmp/return_test.txt
# Clean up # Clean up
docker-compose down -v --remove-orphans docker-compose -f out/docker-tsdb/docker-compose.test.yml -f docker-compose.yml down --remove-orphans --volumes
cd $start_dir cd $start_dir
rm -fr $temp_dir rm -fr $temp_dir

View File

@ -2,17 +2,16 @@ version: '3.2'
services: services:
ipld-eth-db: ipld-eth-db:
restart: always restart: on-failure
image: vulcanize/ipld-eth-db:v3.2.0 depends_on:
- access-node
image: vulcanize/ipld-eth-db:v4.1.1-alpha
environment: environment:
POSTGRES_USER: "vdbm" DATABASE_USER: "vdbm"
POSTGRES_DB: "vulcanize_testing" DATABASE_NAME: "vulcanize_testing_v4"
POSTGRES_PASSWORD: "password" DATABASE_PASSWORD: "password"
volumes: DATABASE_HOSTNAME: "access-node"
- vdb_db_eth_server:/var/lib/postgresql/data DATABASE_PORT: 5432
ports:
- "127.0.0.1:8077:5432"
command: ["postgres", "-c", "log_statement=all"]
eth-server: eth-server:
restart: unless-stopped restart: unless-stopped

View File

@ -1,8 +1,26 @@
# Clear up existing docker images and volume. #!/bin/bash
docker-compose down --remove-orphans --volumes
docker-compose -f docker-compose.yml up -d ipld-eth-db set -e
sleep 10
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test
docker-compose down --remove-orphans --volumes mkdir -p out
# Remove existing docker-tsdb directory
rm -rf out/docker-tsdb/
# Copy over files to setup TimescaleDB
ID=$(docker create vulcanize/ipld-eth-db:v4.1.1-alpha)
docker cp $ID:/app/docker-tsdb out/docker-tsdb/
docker rm -v $ID
# Spin up TimescaleDB
docker-compose -f out/docker-tsdb/docker-compose.test.yml -f docker-compose.yml up ipld-eth-db
trap "docker-compose -f out/docker-tsdb/docker-compose.test.yml -f docker-compose.yml down --remove-orphans --volumes; rm -rf out/" SIGINT SIGTERM ERR
sleep 45
# Run unit tests
go clean -testcache
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8066 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing_v4 make test
# Clean up
docker-compose -f out/docker-tsdb/docker-compose.test.yml -f docker-compose.yml down --remove-orphans --volumes
rm -rf out/