Skip to content

Commit

Permalink
refactor: eliminate separate go module for e2e tests (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
boecklim authored Nov 11, 2024
1 parent 0dbafa6 commit 262b528
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 132 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,24 @@ build_docker:

.PHONY: run
run:
docker compose -f test/docker-compose.yaml down --remove-orphans
docker compose -f test/docker-compose.yaml up --abort-on-container-exit migrate-blocktx migrate-metamorph migrate-callbacker
docker compose -f test/docker-compose.yaml up --build arc-blocktx arc-callbacker arc-metamorph arc
docker compose -f test/docker-compose.yaml down
docker compose down --remove-orphans
docker compose up --abort-on-container-exit migrate-blocktx migrate-metamorph migrate-callbacker
docker compose up --build arc-blocktx arc-callbacker arc-metamorph arc
docker compose down

.PHONY: run_e2e_tests
run_e2e_tests:
docker compose -f test/docker-compose.yaml down --remove-orphans
docker compose -f test/docker-compose.yaml up --abort-on-container-exit migrate-blocktx migrate-metamorph migrate-callbacker
docker compose -f test/docker-compose.yaml up --build --exit-code-from tests tests arc-blocktx arc-callbacker arc-metamorph arc --scale arc-blocktx=4 --scale arc-metamorph=2
docker compose -f test/docker-compose.yaml down
docker compose down --remove-orphans
docker compose up --abort-on-container-exit migrate-blocktx migrate-metamorph migrate-callbacker
docker compose up --build --exit-code-from tests tests arc-blocktx arc-callbacker arc-metamorph arc --scale arc-blocktx=4 --scale arc-metamorph=2
docker compose down

.PHONY: run_e2e_tests_with_tracing
run_e2e_tests_with_tracing:
docker compose -f test/docker-compose.yaml down --remove-orphans
docker compose -f test/docker-compose.yaml up --abort-on-container-exit migrate-blocktx migrate-metamorph migrate-callbacker
ARC_TRACING_ENABLED=TRUE docker compose -f test/docker-compose.yaml up --build --exit-code-from tests tests arc-blocktx arc-callbacker arc-metamorph arc arc-jaeger --scale arc-blocktx=4 --scale arc-metamorph=2
docker compose -f test/docker-compose.yaml down
docker compose down --remove-orphans
docker compose up --abort-on-container-exit migrate-blocktx migrate-metamorph migrate-callbacker
ARC_TRACING_ENABLED docker compose up --build --exit-code-from tests tests arc-blocktx arc-callbacker arc-metamorph arc arc-jaeger --scale arc-blocktx=4 --scale arc-metamorph=2
docker compose down

.PHONY: test
test:
Expand Down
36 changes: 19 additions & 17 deletions test/docker-compose.yaml → docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
healthcheck:
test: [ "CMD", "/entrypoint.sh", "bitcoin-cli", "getinfo" ]
volumes:
- ./config/bitcoin.conf:/data/bitcoin.conf
- ./test/config/bitcoin.conf:/data/bitcoin.conf
- node1-data:/data
command: [ "/entrypoint.sh", "bitcoind", "-connect=node2:18333", "-connect=node3:18333" ]

Expand All @@ -27,7 +27,7 @@ services:
healthcheck:
test: [ "CMD", "/entrypoint.sh", "bitcoin-cli", "getinfo" ]
volumes:
- ./config/bitcoin.conf:/data/bitcoin.conf
- ./test/config/bitcoin.conf:/data/bitcoin.conf
- node2-data:/data
command: [ "/entrypoint.sh", "bitcoind", "-connect=node1:18333", "-connect=node3:18333" ]

Expand All @@ -42,7 +42,7 @@ services:
healthcheck:
test: [ "CMD", "/entrypoint.sh", "bitcoin-cli", "getinfo" ]
volumes:
- ./config/bitcoin.conf:/data/bitcoin.conf
- ./test/config/bitcoin.conf:/data/bitcoin.conf
- node3-data:/data
command: [ "/entrypoint.sh", "bitcoind", "-connect=node1:18333", "-connect=node2:18333" ]

Expand Down Expand Up @@ -76,7 +76,7 @@ services:
]
command: [ "up" ]
volumes:
- ../internal/blocktx/store/postgresql/migrations:/migrations
- ./internal/blocktx/store/postgresql/migrations:/migrations
depends_on:
db:
condition: service_healthy
Expand All @@ -95,7 +95,7 @@ services:
]
command: [ "up" ]
volumes:
- ../internal/metamorph/store/postgresql/migrations:/migrations
- ./internal/metamorph/store/postgresql/migrations:/migrations
depends_on:
db:
condition: service_healthy
Expand All @@ -114,7 +114,7 @@ services:
]
command: [ "up" ]
volumes:
- ../internal/callbacker/store/postgresql/migrations:/migrations
- ./internal/callbacker/store/postgresql/migrations:/migrations
depends_on:
db:
condition: service_healthy
Expand All @@ -129,7 +129,7 @@ services:
hostname: nats-server
volumes:
- nats1-data:/data
- ./config/nats-server-host-1.conf:/etc/nats/nats-server.conf
- ./test/config/nats-server-host-1.conf:/etc/nats/nats-server.conf
healthcheck:
test: wget http://localhost:8222/healthz -q -S -O -
interval: 5s
Expand All @@ -145,7 +145,7 @@ services:
hostname: nats-server
volumes:
- nats2-data:/data
- ./config/nats-server-host-2.conf:/etc/nats/nats-server.conf
- ./test/config/nats-server-host-2.conf:/etc/nats/nats-server.conf
healthcheck:
test: wget http://localhost:8222/healthz -q -S -O -
interval: 5s
Expand All @@ -163,11 +163,11 @@ services:
test: [ "CMD", "redis-cli", "ping" ]

arc-blocktx:
build: ../
build: ./
expose:
- "8011"
volumes:
- ./config/config.yaml:/service/config.yaml
- ./test/config/config.yaml:/service/config.yaml
command: [ "./arc", "-blocktx=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
Expand All @@ -194,14 +194,14 @@ services:
retries: 3

arc-callbacker:
build: ../
build: ./
expose:
- "8021"
command: [ "./arc", "-callbacker=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
volumes:
- ./config/config.yaml:/service/config.yaml
- ./test/config/config.yaml:/service/config.yaml
depends_on:
migrate-callbacker:
condition: service_completed_successfully
Expand All @@ -212,14 +212,14 @@ services:
retries: 3

arc-metamorph:
build: ../
build: ./
expose:
- "8001"
command: [ "./arc", "-metamorph=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
volumes:
- ./config/config.yaml:/service/config.yaml
- ./test/config/config.yaml:/service/config.yaml
depends_on:
arc-blocktx:
condition: service_healthy
Expand All @@ -236,7 +236,7 @@ services:
retries: 3

arc:
build: ../
build: ./
ports:
- "8011:8011"
- "9090:9090"
Expand All @@ -249,7 +249,7 @@ services:
environment:
- ARC_TRACING_ENABLED
volumes:
- ./config/config.yaml:/service/config.yaml
- ./test/config/config.yaml:/service/config.yaml
depends_on:
arc-metamorph:
condition: service_healthy
Expand All @@ -265,7 +265,9 @@ services:
- OTEL_EXPORTER_OTLP_INSECURE=true

tests:
build: .
build:
context: ./
dockerfile: ./test/Dockerfile
depends_on:
- arc

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22.5

require (
github.com/bitcoin-sv/go-sdk v1.0.0
github.com/bitcoinsv/bsvutil v0.0.0-20181216182056-1d77cf353ea9
github.com/cenkalti/backoff/v4 v4.3.0
github.com/coocood/freecache v1.2.4
github.com/enescakir/emoji v1.0.0
Expand Down Expand Up @@ -62,7 +63,6 @@ require (
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 // indirect
github.com/bitcoinsv/bsvutil v0.0.0-20181216182056-1d77cf353ea9 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down
18 changes: 9 additions & 9 deletions test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ COPY go.mod go.sum ./
# Download all dependencies. Dependencies will be cached if the go.mod and the go.sum files are not changed
RUN go mod download

COPY ./e2e_globals.go ./e2e_globals.go
COPY ./init_test.go ./init_test.go
COPY ./utils.go ./utils.go
COPY ./fixtures ./fixtures
COPY ./test/e2e_globals.go ./e2e_globals.go
COPY ./test/init_test.go ./init_test.go
COPY ./test/utils.go ./utils.go
COPY ./test/fixtures ./fixtures

# Copy tests to run
COPY ./submit_single_test.go ./submit_01_single_test.go
COPY ./submit_batch_test.go ./submit_02_batch_test.go
COPY ./submit_double_spending_test.go ./submit_03_double_spending_test.go
COPY ./submit_beef_test.go ./submit_04_beef_test.go
COPY ./test/submit_single_test.go ./submit_01_single_test.go
COPY ./test/submit_batch_test.go ./submit_02_batch_test.go
COPY ./test/submit_double_spending_test.go ./submit_03_double_spending_test.go
COPY ./test/submit_beef_test.go ./submit_04_beef_test.go

# This will compile and run the tests
CMD [ "go", "test", "-v", "-failfast", "./..."]
CMD [ "go", "test", "--tags=e2e", "-v", "-failfast", "./..."]
2 changes: 2 additions & 0 deletions test/e2e_globals.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down
31 changes: 0 additions & 31 deletions test/go.mod

This file was deleted.

62 changes: 0 additions & 62 deletions test/go.sum

This file was deleted.

2 changes: 2 additions & 0 deletions test/init_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions test/submit_batch_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions test/submit_beef_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions test/submit_double_spending_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions test/submit_single_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down
2 changes: 2 additions & 0 deletions test/utils.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build e2e

package test

import (
Expand Down

0 comments on commit 262b528

Please sign in to comment.