Skip to content

Commit

Permalink
refactor(localnet): reduce number of docker compose files (#2365)
Browse files Browse the repository at this point in the history
* refactor(localnet): reduce number of docker compose files

* add ZETACORED_START_PERIOD and allow user to set E2E_ARGS

* fix upgrade tests

* fix upgrade-test height

* rebase for start-e2e-import-mainnet-test

* always use make stop-localnet

* newlines and readme
  • Loading branch information
gartnera authored Jun 24, 2024
1 parent 562a534 commit 3eb36cd
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 168 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ jobs:
- name: Full Log Dump On Failure
if: failure()
run: |
cd contrib/localnet
docker compose logs
make stop-localnet
- name: Notify Slack on Failure
if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/develop'
Expand All @@ -167,8 +166,7 @@ jobs:
- name: Stop Private Network
if: always()
run: |
cd contrib/localnet/
docker compose down
make stop-localnet
- name: Clean Up Workspace
if: always()
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/execute_advanced_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
- name: Full Log Dump On Failure
if: failure()
run: |
cd contrib/localnet
docker compose logs
make stop-localnet
- name: Notify Slack on Failure
if: failure() && github.event_name == 'schedule'
Expand Down Expand Up @@ -82,8 +81,7 @@ jobs:
- name: Full Log Dump On Failure
if: failure()
run: |
cd contrib/localnet
docker compose logs
make stop-localnet
- name: Notify Slack on Failure
if: failure() && github.event_name == 'schedule'
Expand Down Expand Up @@ -114,8 +112,7 @@ jobs:
- name: Full Log Dump On Failure
if: failure()
run: |
cd contrib/localnet
docker compose logs
make stop-localnet
e2e-performance-test:
if: ${{ github.event.inputs.e2e-performance-test == 'true' }}
Expand All @@ -137,5 +134,4 @@ jobs:
- name: Full Log Dump On Failure
if: failure()
run: |
cd contrib/localnet
docker compose logs
make stop-localnet
3 changes: 1 addition & 2 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,7 @@ jobs:
- name: Stop Private Network
if: ${{ always() && github.event.inputs.skip_checks != 'true' }}
run: |
cd contrib/localnet/
docker compose down
make stop-localnet
- name: Clean Up Workspace
if: always()
Expand Down
32 changes: 24 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test

export DOCKER_BUILDKIT := 1

# parameters for localnet docker compose files
# set defaults to empty to prevent docker warning
export LOCALNET_MODE
export E2E_ARGS := $(E2E_ARGS)
export UPGRADE_HEIGHT
export ZETACORED_IMPORT_GENESIS_DATA
export ZETACORED_START_PERIOD := 30s

clean: clean-binaries clean-dir clean-test-dir clean-coverage

clean-binaries:
Expand Down Expand Up @@ -217,15 +225,17 @@ start-e2e-test: zetanode

start-e2e-admin-test: zetanode
@echo "--> Starting e2e admin test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-admin.yml up -d
export E2E_ARGS="--skip-regular --test-admin" && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-additionalevm.yml up -d

start-e2e-performance-test: zetanode
@echo "--> Starting e2e performance test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-performance.yml up -d
export E2E_ARGS="--test-performance" && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d

start-stress-test: zetanode
@echo "--> Starting stress test"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stresstest.yml up -d
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-stress.yml up -d

#TODO: replace OLD_VERSION with v16 tag once its available
zetanode-upgrade: zetanode
Expand All @@ -236,24 +246,30 @@ zetanode-upgrade: zetanode

start-upgrade-test: zetanode-upgrade
@echo "--> Starting upgrade test"
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=225 && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-upgrade-test-light: zetanode-upgrade
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml -f docker-compose-upgrade-light.yml up -d
export LOCALNET_MODE=upgrade && \
export UPGRADE_HEIGHT=90 && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-localnet: zetanode start-localnet-skip-build

start-localnet-skip-build:
@echo "--> Starting localnet"
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-setup-only.yml up -d
export LOCALNET_MODE=setup-only && \
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml up -d

stop-localnet:
start-e2e-import-mainnet-test: zetanode
@echo "--> Starting e2e import-data test"
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml -f docker-compose-import-data.yml up -d
export ZETACORED_IMPORT_GENESIS_DATA=true && \
export ZETACORED_START_PERIOD=10m && \
cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER) compose -f docker-compose.yml up -d

stop-test:
stop-localnet:
cd contrib/localnet/ && $(DOCKER) compose down --remove-orphans

###############################################################################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
version: "3"

# This docker-compose file overrides the orchestrator service to specify the flag to test the admin functions
# and skip the regular tests
# it also adds another local Ethereum network to test EVM chain migration and use the additional-evm flag

services:
orchestrator:
entrypoint: ["/work/start-zetae2e.sh", "local --skip-regular --test-admin"]

eth2:
build:
context: ./anvil
Expand All @@ -21,7 +16,9 @@ services:
ipv4_address: 172.20.0.102

zetaclient0:
entrypoint: [ "/root/start-zetaclientd.sh", "additional-evm" ]
environment:
- ADDITIONAL_EVM=true

zetaclient1:
entrypoint: [ "/root/start-zetaclientd.sh", "additional-evm" ]
environment:
- ADDITIONAL_EVM=true
30 changes: 0 additions & 30 deletions contrib/localnet/docker-compose-import-data.yml

This file was deleted.

2 changes: 0 additions & 2 deletions contrib/localnet/docker-compose-monitoring.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
grafana:
image: grafana/grafana:latest
Expand Down
9 changes: 0 additions & 9 deletions contrib/localnet/docker-compose-performance.yml

This file was deleted.

9 changes: 0 additions & 9 deletions contrib/localnet/docker-compose-setup-only.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
version: "3"

# This docker-compose redefine the services:
# - ZetaChain with 4 nodes to test performance
# - ZetaChain observer set with 4 clients to test performance
# - Orchestrator call stress commands

services:
zetacore0:
entrypoint: ["/root/start-zetacored.sh", "4"]
environment:
- ZETACORED_REPLICAS=4

zetacore1:
entrypoint: ["/root/start-zetacored.sh", "4"]
environment:
- ZETACORED_REPLICAS=4

zetacore2:
image: zetanode:latest
container_name: zetacore2
build:
context: ../../.
dockerfile: Dockerfile-localnet
hostname: zetacore2
networks:
mynetwork:
Expand All @@ -26,6 +22,7 @@ services:
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
- ZETACORED_REPLICAS=4

zetacore3:
image: zetanode:latest
Expand All @@ -41,21 +38,11 @@ services:
environment:
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only

zetaclient0:
ports:
- "8123:8123"
entrypoint: /root/start-zetaclientd.sh

zetaclient1:
entrypoint: /root/start-zetaclientd.sh
- ZETACORED_REPLICAS=4

zetaclient2:
image: zetanode:latest
container_name: zetaclient2
build:
context: ../../.
dockerfile: Dockerfile-localnet
hostname: zetaclient2
networks:
mynetwork:
Expand All @@ -65,13 +52,13 @@ services:
- ETHDEV_ENDPOINT=http://eth:8545
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams

zetaclient3:
image: zetanode:latest
container_name: zetaclient3
build:
context: ../../.
dockerfile: Dockerfile-localnet
hostname: zetaclient3
networks:
mynetwork:
Expand All @@ -81,8 +68,6 @@ services:
- ETHDEV_ENDPOINT=http://eth:8545
- HOTKEY_BACKEND=file
- HOTKEY_PASSWORD=password # test purposes only

orchestrator:
build:
dockerfile: contrib/localnet/orchestrator/Dockerfile.fastbuild
entrypoint: ["/work/start-zetae2e.sh", "stress"]
volumes:
- ssh:/root/.ssh
- preparams:/root/preparams
11 changes: 0 additions & 11 deletions contrib/localnet/docker-compose-upgrade-light.yml

This file was deleted.

14 changes: 4 additions & 10 deletions contrib/localnet/docker-compose-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3"

# This docker-compose redefine the services:
# - ZetaChain with 2 nodes (zetacore0, zetacore1) using the upgrade option for cosmovisor
# - ZetaChain observer set with 2 clients (zetaclient0, zetaclient1) using the background option
Expand All @@ -13,17 +11,11 @@ services:
image: zetanode:old

zetaclient0:
entrypoint: ["/root/start-zetaclientd.sh"]
image: zetanode:old

zetaclient1:
entrypoint: ["/root/start-zetaclientd.sh"]
image: zetanode:old

orchestrator:
entrypoint: ["/work/start-zetae2e.sh", "local", "upgrade"]
image: orchestrator

upgrade-host:
image: zetanode:latest
container_name: upgrade-host
Expand All @@ -40,12 +32,14 @@ services:
image: zetanode:old
container_name: upgrade-orchestrator
hostname: upgrade-orchestrator
entrypoint: ["/root/start-upgrade-orchestrator.sh", "225"]
entrypoint: ["/root/start-upgrade-orchestrator.sh"]
networks:
mynetwork:
ipv4_address: 172.20.0.251
depends_on:
- zetacore0
- upgrade-host
environment:
- UPGRADE_HEIGHT=${UPGRADE_HEIGHT}
volumes:
- ssh:/root/.ssh
- ssh:/root/.ssh
Loading

0 comments on commit 3eb36cd

Please sign in to comment.