Skip to content

Commit

Permalink
Run tests using multi-node database setup
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed May 11, 2022
1 parent d2c25c6 commit 8a4583c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 23 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Run geth unit test
strategy:
matrix:
go-version: [ 1.16.x]
go-version: [1.16.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
env:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
GOPATH: /tmp/go
strategy:
matrix:
go-version: [ 1.16.x]
go-version: [1.16.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -58,9 +58,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Start database
run: docker-compose -f docker-compose.yml up -d ipld-eth-db

- name: Run unit tests
run:
make statedifftest
./scripts/run_unit_test.sh
24 changes: 9 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ version: "3.2"

services:
ipld-eth-db:
restart: always
# image: vulcanize/ipld-eth-db:v3.2.0
build:
context: https://github.com/vulcanize/ipld-eth-db.git#sharding
dockerfile: Dockerfile
restart: on-failure
depends_on:
- access-node
image: migrations-test
environment:
POSTGRES_USER: "vdbm"
POSTGRES_DB: "vulcanize_testing_v4"
POSTGRES_PASSWORD: "password"
volumes:
- geth_node:/var/lib/postgresql/data
ports:
- "127.0.0.1:5432:5432"

volumes:
geth_node:
DATABASE_USER: "postgres"
DATABASE_NAME: "vulcanize_testing_v4"
DATABASE_PASSWORD: "password"
DATABASE_HOSTNAME: "access-node"
DATABASE_PORT: 5432
28 changes: 28 additions & 0 deletions scripts/run_unit_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

# Build database image
docker build -t migrations-test https://github.com/vulcanize/ipld-eth-db.git#sharding

mkdir -p out

# Remove existing docker-multi-node directory
rm -rf out/docker-multi-node/

# Copy over files to setup multi-node database
ID=$(docker create migrations-test)
docker cp $ID:/app/docker-multi-node out/docker-multi-node/
docker rm -v $ID

# Spin up multi-node database
docker-compose -f out/docker-multi-node/docker-compose.test.yml -f docker-compose.yml up ipld-eth-db
sleep 20

# Run unit tests
go clean -testcache
make statedifftest

# Clean up
docker-compose -f out/docker-multi-node/docker-compose.test.yml -f docker-compose.yml down --remove-orphans --volumes
rm -rf out/docker-multi-node/
4 changes: 2 additions & 2 deletions statediff/indexer/database/sql/postgres/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func ResolveDriverType(str string) (DriverType, error) {
// DefaultConfig are default parameters for connecting to a Postgres sql
var DefaultConfig = Config{
Hostname: "localhost",
Port: 5432,
Port: 8066,
DatabaseName: "vulcanize_testing_v4",
Username: "vdbm",
Username: "postgres",
Password: "password",
}

Expand Down

0 comments on commit 8a4583c

Please sign in to comment.