diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml index af20fb410880..7eeb96ed31d7 100644 --- a/.github/workflows/on-pr.yml +++ b/.github/workflows/on-pr.yml @@ -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: @@ -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: @@ -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 \ No newline at end of file + ./scripts/run_unit_test.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 76837ac28997..12703cef4ec3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/scripts/run_unit_test.sh b/scripts/run_unit_test.sh new file mode 100755 index 000000000000..98a7ead5eece --- /dev/null +++ b/scripts/run_unit_test.sh @@ -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/ diff --git a/statediff/indexer/database/sql/postgres/config.go b/statediff/indexer/database/sql/postgres/config.go index 42509abc668b..8ff8137d6555 100644 --- a/statediff/indexer/database/sql/postgres/config.go +++ b/statediff/indexer/database/sql/postgres/config.go @@ -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", }