Skip to content

Commit

Permalink
test: add e2e tests for hybrid communication
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain committed Dec 31, 2024
1 parent 274b960 commit b8c8f95
Show file tree
Hide file tree
Showing 7 changed files with 533 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ run_e2e_tests_with_tracing:
docker compose down --remove-orphans
ARC_TRACING_ENABLED=TRUE docker compose up --build blocktx callbacker metamorph api tests jaeger --scale blocktx=4 --scale metamorph=2 --no-attach jaeger

.PHONY: run_e2e_mcast_tests
run_e2e_mcast_tests:
docker compose -f docker-compose-mcast.yaml down --remove-orphans
docker compose -f docker-compose-mcast.yaml up --build mcast_sidecar blocktx metamorph api tests --scale blocktx=6 --exit-code-from tests
docker compose -f docker-compose-mcast.yaml down

.PHONY: test
test:
go test -race -count=1 ./...
Expand Down
333 changes: 333 additions & 0 deletions docker-compose-mcast.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
version: '3'
services:
node1:
container_name: node1
image: bitcoinsv/bitcoin-sv:1.1.0
ports:
- "18332:18332"
expose:
- "18332"
- "18333"
- "28332"
healthcheck:
test: [ "CMD", "/entrypoint.sh", "bitcoin-cli", "getinfo" ]
volumes:
- ./test/config/bitcoin.conf:/data/bitcoin.conf
- node1-data:/data
command: [ "/entrypoint.sh", "bitcoind", "-connect=node2:18333", "-connect=node3:18333" ]
networks:
- multicast_bridge

node2:
container_name: node2
image: bitcoinsv/bitcoin-sv:1.1.0
expose:
- "18332"
- "18333"
healthcheck:
test: [ "CMD", "/entrypoint.sh", "bitcoin-cli", "getinfo" ]
volumes:
- ./test/config/bitcoin.conf:/data/bitcoin.conf
- node2-data:/data
command: [ "/entrypoint.sh", "bitcoind", "-connect=node1:18333", "-connect=node3:18333" ]
networks:
- multicast_bridge

node3:
container_name: node3
image: bitcoinsv/bitcoin-sv:1.1.0
expose:
- "18332"
- "18333"
healthcheck:
test: [ "CMD", "/entrypoint.sh", "bitcoin-cli", "getinfo" ]
volumes:
- ./test/config/bitcoin.conf:/data/bitcoin.conf
- node3-data:/data
command: [ "/entrypoint.sh", "bitcoind", "-connect=node1:18333", "-connect=node2:18333" ]
networks:
- multicast_bridge

db:
image: postgres:15.4
restart: always
environment:
- POSTGRES_USER=arcuser
- POSTGRES_PASSWORD=arcpass
- POSTGRES_DB=main
healthcheck:
test: [ "CMD-SHELL", "pg_isready", "-d blocktx", "-U arcuser" ]
interval: 5s
timeout: 5s
retries: 5
ports:
- '5432:5432'
expose:
- "5432"
networks:
- multicast_bridge

migrate-blocktx:
container_name: migrate-blocktx
image: migrate/migrate:v4.16.2
entrypoint:
[
"migrate",
"-path",
"/migrations",
"-database",
"postgres://arcuser:arcpass@db:5432/main?sslmode=disable&x-migrations-table=blocktx",

Check failure

Code scanning / SonarCloud

PostgreSQL database passwords should not be disclosed High

Make sure this PostgreSQL database password gets changed and removed from the code. See more on SonarQube Cloud
]
command: [ "up" ]
volumes:
- ./internal/blocktx/store/postgresql/migrations:/migrations
depends_on:
db:
condition: service_healthy
restart: on-failure
networks:
- multicast_bridge

migrate-metamorph:
container_name: migrate-metamorph
image: migrate/migrate:v4.16.2
entrypoint:
[
"migrate",
"-path",
"/migrations",
"-database",
"postgres://arcuser:arcpass@db:5432/main?sslmode=disable&x-migrations-table=metamorph",

Check failure

Code scanning / SonarCloud

PostgreSQL database passwords should not be disclosed High

Make sure this PostgreSQL database password gets changed and removed from the code. See more on SonarQube Cloud
]
command: [ "up" ]
volumes:
- ./internal/metamorph/store/postgresql/migrations:/migrations
depends_on:
db:
condition: service_healthy
restart: on-failure
networks:
- multicast_bridge

migrate-callbacker:
container_name: migrate-callbacker
image: migrate/migrate:v4.16.2
entrypoint:
[
"migrate",
"-path",
"/migrations",
"-database",
"postgres://arcuser:arcpass@db:5432/main?sslmode=disable&x-migrations-table=callbacker",

Check failure

Code scanning / SonarCloud

PostgreSQL database passwords should not be disclosed High

Make sure this PostgreSQL database password gets changed and removed from the code. See more on SonarQube Cloud
]
command: [ "up" ]
volumes:
- ./internal/callbacker/store/postgresql/migrations:/migrations
depends_on:
db:
condition: service_healthy
restart: on-failure
networks:
- multicast_bridge

nats-1:
image: nats:2.10.18-alpine3.20
container_name: nats-server-1
restart: on-failure
ports:
- "4222:4222"
hostname: nats-server
volumes:
- nats1-data:/data
- ./test/config/nats-server-host-1.conf:/etc/nats/nats-server.conf
healthcheck:
test: wget http://localhost:8222/healthz -q -S -O -
interval: 5s
timeout: 5s
retries: 5
networks:
- multicast_bridge

nats-2:
image: nats:2.10.18-alpine3.20
container_name: nats-server-2
restart: on-failure
ports:
- "4223:4222"
hostname: nats-server
volumes:
- nats2-data:/data
- ./test/config/nats-server-host-2.conf:/etc/nats/nats-server.conf
healthcheck:
test: wget http://localhost:8222/healthz -q -S -O -
interval: 5s
timeout: 5s
retries: 5
networks:
- multicast_bridge

cache:
image: redis
hostname: redis
ports:
- "6379:6379"
volumes:
- redis-data:/data
healthcheck:
test: [ "CMD", "redis-cli", "ping" ]
networks:
- multicast_bridge

mcast_sidecar:
build:
context: ./
dockerfile: ./cmd/mcast/node_sidecar/Dockerfile
volumes:
- ./test/config/config_mcast.yaml:/service/config.yaml
command: [ "./sidecar", "-config=." ]
depends_on:
node1:
condition: service_healthy
node2:
condition: service_healthy
node3:
condition: service_healthy
networks:
- multicast_bridge

blocktx:
build: ./
expose:
- "8011"
volumes:
- ./test/config/config_mcast.yaml:/service/config.yaml
command: [ "./arc", "-blocktx=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
depends_on:
nats-1:
condition: service_healthy
nats-2:
condition: service_healthy
node1:
condition: service_healthy
node2:
condition: service_healthy
node3:
condition: service_healthy
migrate-blocktx:
condition: service_completed_successfully

healthcheck:
test: ["CMD", "/bin/grpc_health_probe", "-addr=:8006", "-service=liveness", "-rpc-timeout=5s"]
interval: 10s
timeout: 5s
retries: 3
networks:
- multicast_bridge

callbacker:
build: ./
expose:
- "8021"
command: [ "./arc", "-callbacker=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
volumes:
- ./test/config/config_mcast.yaml:/service/config.yaml
depends_on:
nats-1:
condition: service_healthy
nats-2:
condition: service_healthy
migrate-callbacker:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "/bin/grpc_health_probe", "-addr=:8022", "-service=liveness", "-rpc-timeout=5s"]
interval: 10s
timeout: 5s
retries: 3
networks:
- multicast_bridge

metamorph:
build: ./
expose:
- "8001"
command: [ "./arc", "-metamorph=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
volumes:
- ./test/config/config_mcast.yaml:/service/config.yaml
depends_on:
blocktx:
condition: service_healthy
callbacker:
condition: service_healthy
cache:
condition: service_healthy
migrate-metamorph:
condition: service_completed_successfully
healthcheck:
test: ["CMD", "/bin/grpc_health_probe", "-addr=:8005", "-service=liveness", "-rpc-timeout=5s"]
interval: 10s
timeout: 5s
retries: 3
networks:
- multicast_bridge

api:
build: ./
ports:
- "8011:8011"
- "9090:9090"
- "9999:9999"
- "2112:2112"
expose:
- "9090"
- "2112"
command: [ "./arc", "-api=true", "-config=." ]
environment:
- ARC_TRACING_ENABLED
volumes:
- ./test/config/config.yaml:/service/config.yaml
depends_on:
metamorph:
condition: service_healthy
networks:
- multicast_bridge

tests:
build:
context: ./
dockerfile: ./test/Dockerfile
environment:
- TEST_LOCAL_MCAST=TRUE
depends_on:
- api
networks:
- multicast_bridge

volumes:
node1-data:
external: false
node2-data:
external: false
node3-data:
external: false
nats1-data:
external: false
nats2-data:
external: false
redis-data:
external: false

networks:
multicast_bridge:
driver: bridge
enable_ipv6: true
ipam:
driver: default
config:
- subnet: "2001:db8:9::/64"
gateway: "2001:db8:9::1"
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ services:
volumes:
- ./test/config/config.yaml:/service/config.yaml
depends_on:
nats-1:
condition: service_healthy
nats-2:
condition: service_healthy
migrate-callbacker:
condition: service_completed_successfully
healthcheck:
Expand Down
Loading

0 comments on commit b8c8f95

Please sign in to comment.