Skip to content

Commit 8a4583c

Browse files
committed
Run tests using multi-node database setup
1 parent d2c25c6 commit 8a4583c

File tree

4 files changed

+42
-23
lines changed

4 files changed

+42
-23
lines changed

.github/workflows/on-pr.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: Run geth unit test
1616
strategy:
1717
matrix:
18-
go-version: [ 1.16.x]
18+
go-version: [1.16.x]
1919
platform: [ubuntu-latest]
2020
runs-on: ${{ matrix.platform }}
2121
env:
@@ -43,7 +43,7 @@ jobs:
4343
GOPATH: /tmp/go
4444
strategy:
4545
matrix:
46-
go-version: [ 1.16.x]
46+
go-version: [1.16.x]
4747
platform: [ubuntu-latest]
4848
runs-on: ${{ matrix.platform }}
4949
steps:
@@ -58,9 +58,6 @@ jobs:
5858
- name: Checkout code
5959
uses: actions/checkout@v2
6060

61-
- name: Start database
62-
run: docker-compose -f docker-compose.yml up -d ipld-eth-db
63-
6461
- name: Run unit tests
6562
run:
66-
make statedifftest
63+
./scripts/run_unit_test.sh

docker-compose.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@ version: "3.2"
22

33
services:
44
ipld-eth-db:
5-
restart: always
6-
# image: vulcanize/ipld-eth-db:v3.2.0
7-
build:
8-
context: https://github.com/vulcanize/ipld-eth-db.git#sharding
9-
dockerfile: Dockerfile
5+
restart: on-failure
6+
depends_on:
7+
- access-node
8+
image: migrations-test
109
environment:
11-
POSTGRES_USER: "vdbm"
12-
POSTGRES_DB: "vulcanize_testing_v4"
13-
POSTGRES_PASSWORD: "password"
14-
volumes:
15-
- geth_node:/var/lib/postgresql/data
16-
ports:
17-
- "127.0.0.1:5432:5432"
18-
19-
volumes:
20-
geth_node:
10+
DATABASE_USER: "postgres"
11+
DATABASE_NAME: "vulcanize_testing_v4"
12+
DATABASE_PASSWORD: "password"
13+
DATABASE_HOSTNAME: "access-node"
14+
DATABASE_PORT: 5432

scripts/run_unit_test.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Build database image
6+
docker build -t migrations-test https://github.com/vulcanize/ipld-eth-db.git#sharding
7+
8+
mkdir -p out
9+
10+
# Remove existing docker-multi-node directory
11+
rm -rf out/docker-multi-node/
12+
13+
# Copy over files to setup multi-node database
14+
ID=$(docker create migrations-test)
15+
docker cp $ID:/app/docker-multi-node out/docker-multi-node/
16+
docker rm -v $ID
17+
18+
# Spin up multi-node database
19+
docker-compose -f out/docker-multi-node/docker-compose.test.yml -f docker-compose.yml up ipld-eth-db
20+
sleep 20
21+
22+
# Run unit tests
23+
go clean -testcache
24+
make statedifftest
25+
26+
# Clean up
27+
docker-compose -f out/docker-multi-node/docker-compose.test.yml -f docker-compose.yml down --remove-orphans --volumes
28+
rm -rf out/docker-multi-node/

statediff/indexer/database/sql/postgres/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ func ResolveDriverType(str string) (DriverType, error) {
4848
// DefaultConfig are default parameters for connecting to a Postgres sql
4949
var DefaultConfig = Config{
5050
Hostname: "localhost",
51-
Port: 5432,
51+
Port: 8066,
5252
DatabaseName: "vulcanize_testing_v4",
53-
Username: "vdbm",
53+
Username: "postgres",
5454
Password: "password",
5555
}
5656

0 commit comments

Comments
 (0)