Merge pull request #111 from vulcanize/use-ipld-eth-db

Use ipld-eth-db docker image.
This commit is contained in:
Arijit Das 2021-10-12 12:48:59 +05:30 committed by GitHub
commit c3d267a6d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 42 deletions

View File

@ -28,11 +28,11 @@ jobs:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Run database - name: Run database
run: docker-compose up -d db run: docker-compose up -d ipld-eth-db
- name: Test - name: Test
run: | run: |
sleep 10 sleep 10
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 make test PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test
integrationtest: integrationtest:
name: Run integration tests name: Run integration tests
@ -52,7 +52,7 @@ jobs:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Run database - name: Run database
run: docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db dapptools contract eth-server run: docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db dapptools contract eth-server
- name: Test - name: Test
run: | run: |
while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \ while [ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8081)" != "200" ]; do echo "waiting for ipld-eth-server..." && sleep 5; done && \

View File

@ -57,10 +57,6 @@ TEST_CONNECT_STRING_LOCAL = postgresql://$(USER)@$(HOST_NAME):$(PORT)/$(TEST_DB)
test: | $(GINKGO) $(GOOSE) test: | $(GINKGO) $(GOOSE)
go vet ./... go vet ./...
go fmt ./... go fmt ./...
export PGPASSWORD=$(DATABASE_PASSWORD)
dropdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) --if-exists $(TEST_DB)
createdb -h $(DATABASE_HOSTNAME) -p $(DATABASE_PORT) -U $(DATABASE_USER) $(TEST_DB)
$(GOOSE) -dir db/migrations postgres "$(TEST_CONNECT_STRING)" up
$(GINKGO) -r --skipPackage=test $(GINKGO) -r --skipPackage=test
.PHONY: integrationtest .PHONY: integrationtest

View File

@ -4,36 +4,24 @@ services:
dapptools: dapptools:
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- statediff-migrations - ipld-eth-db
image: vulcanize/dapptools:v0.30.0-v1.10.9-statediff-0.0.27 image: vulcanize/dapptools:v0.30.0-v1.10.9-statediff-0.0.27
environment: environment:
DB_USER: vdbm DB_USER: vdbm
DB_NAME: vulcanize_public DB_NAME: vulcanize_testing
DB_HOST: db DB_HOST: ipld-eth-db
DB_PORT: 5432 DB_PORT: 5432
DB_PASSWORD: password DB_PASSWORD: password
ports: ports:
- "127.0.0.1:8545:8545" - "127.0.0.1:8545:8545"
- "127.0.0.1:8546:8546" - "127.0.0.1:8546:8546"
statediff-migrations: ipld-eth-db:
restart: on-failure
depends_on:
- db
image: vulcanize/statediff-migrations:v0.8.0
environment:
DATABASE_USER: vdbm
DATABASE_NAME: vulcanize_public
DATABASE_HOSTNAME: db
DATABASE_PORT: 5432
DATABASE_PASSWORD: password
db:
restart: always restart: always
image: postgres:10.12-alpine image: vulcanize/ipld-eth-db:v0.2.0
environment: environment:
POSTGRES_USER: "vdbm" POSTGRES_USER: "vdbm"
POSTGRES_DB: "vulcanize_public" POSTGRES_DB: "vulcanize_testing"
POSTGRES_PASSWORD: "password" POSTGRES_PASSWORD: "password"
volumes: volumes:
- vdb_db_eth_server:/var/lib/postgresql/data - vdb_db_eth_server:/var/lib/postgresql/data
@ -44,7 +32,7 @@ services:
eth-server: eth-server:
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- db - ipld-eth-db
build: build:
context: ./ context: ./
cache_from: cache_from:
@ -56,8 +44,8 @@ services:
ETH_SERVER_HTTPPATH: 0.0.0.0:8081 ETH_SERVER_HTTPPATH: 0.0.0.0:8081
VDB_COMMAND: "serve" VDB_COMMAND: "serve"
ETH_CHAIN_CONFIG: "/tmp/chain.json" ETH_CHAIN_CONFIG: "/tmp/chain.json"
DATABASE_NAME: "vulcanize_public" DATABASE_NAME: "vulcanize_testing"
DATABASE_HOSTNAME: "db" DATABASE_HOSTNAME: "ipld-eth-db"
DATABASE_PORT: 5432 DATABASE_PORT: 5432
DATABASE_USER: "vdbm" DATABASE_USER: "vdbm"
DATABASE_PASSWORD: "password" DATABASE_PASSWORD: "password"
@ -73,7 +61,7 @@ services:
graphql: graphql:
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- db - ipld-eth-db
image: vulcanize/postgraphile:v1.0.1 image: vulcanize/postgraphile:v1.0.1
environment: environment:
- PG_HOST=db - PG_HOST=db

View File

@ -19,6 +19,7 @@ package eth_test
import ( import (
"context" "context"
"math/big" "math/big"
"os"
"strconv" "strconv"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -184,12 +185,13 @@ var (
// SetupDB is use to setup a db for watcher tests // SetupDB is use to setup a db for watcher tests
func SetupDB() (*postgres.DB, error) { func SetupDB() (*postgres.DB, error) {
port, _ := strconv.Atoi(os.Getenv("DATABASE_PORT"))
uri := postgres.DbConnectionString(postgres.ConnectionParams{ uri := postgres.DbConnectionString(postgres.ConnectionParams{
User: "vdbm", User: os.Getenv("DATABASE_USER"),
Password: "password", Password: os.Getenv("DATABASE_PASSWORD"),
Hostname: "localhost", Hostname: os.Getenv("DATABASE_HOSTNAME"),
Name: "vulcanize_testing", Name: os.Getenv("DATABASE_NAME"),
Port: 8077, Port: port,
}) })
return postgres.NewDB(uri, postgres.ConnectionConfig{}, node.Info{}) return postgres.NewDB(uri, postgres.ConnectionConfig{}, node.Info{})
} }

View File

@ -20,6 +20,8 @@ import (
"context" "context"
"fmt" "fmt"
"math/big" "math/big"
"os"
"strconv"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
@ -45,12 +47,13 @@ import (
// SetupDB is use to setup a db for watcher tests // SetupDB is use to setup a db for watcher tests
func SetupDB() (*postgres.DB, error) { func SetupDB() (*postgres.DB, error) {
port, _ := strconv.Atoi(os.Getenv("DATABASE_PORT"))
uri := postgres.DbConnectionString(postgres.ConnectionParams{ uri := postgres.DbConnectionString(postgres.ConnectionParams{
User: "vdbm", User: os.Getenv("DATABASE_USER"),
Password: "password", Password: os.Getenv("DATABASE_PASSWORD"),
Hostname: "localhost", Hostname: os.Getenv("DATABASE_HOSTNAME"),
Name: "vulcanize_testing", Name: os.Getenv("DATABASE_NAME"),
Port: 8077, Port: port,
}) })
return postgres.NewDB(uri, postgres.ConnectionConfig{}, node.Info{}) return postgres.NewDB(uri, postgres.ConnectionConfig{}, node.Info{})
} }

View File

@ -7,7 +7,7 @@ docker-compose down --remove-orphans --volumes
# Build and start the containers. # Build and start the containers.
# Note: Build only if `ipld-eth-server` or other container code is modified. Otherwise comment this line. # Note: Build only if `ipld-eth-server` or other container code is modified. Otherwise comment this line.
docker-compose -f docker-compose.test.yml -f docker-compose.yml build eth-server docker-compose -f docker-compose.test.yml -f docker-compose.yml build eth-server
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db dapptools contract eth-server docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db dapptools contract eth-server
export PGPASSWORD=password export PGPASSWORD=password
export DATABASE_USER=vdbm export DATABASE_USER=vdbm

View File

@ -1,2 +1,5 @@
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d db # Clear up existing docker images and volume.
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 make test docker-compose down --remove-orphans --volumes
docker-compose -f docker-compose.test.yml -f docker-compose.yml up -d ipld-eth-db
PGPASSWORD=password DATABASE_USER=vdbm DATABASE_PORT=8077 DATABASE_PASSWORD=password DATABASE_HOSTNAME=127.0.0.1 DATABASE_NAME=vulcanize_testing make test