Skip to content

Commit

Permalink
refactor: change integration to end-to-end (#108)
Browse files Browse the repository at this point in the history
* refactor: change integration to end-to-end

* refactor: move to integration in reward abci test
  • Loading branch information
JoowonYun authored Jan 8, 2024
1 parent d0e110b commit ebdc691
Show file tree
Hide file tree
Showing 52 changed files with 198 additions and 167 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration test
name: End-to-end test

on:
push:
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Setup network
run: |
mkdir ~/genesis
cd integration_test && docker-compose up -d
cd tests/e2e && docker-compose up -d
docker ps
sleep 20
Expand All @@ -26,8 +26,8 @@ jobs:
with:
go-version: 1.18.x

- name: Integration test
run: cd integration_test && go test
- name: End-to-end test
run: cd tests/e2e && go test

- name: Teardown
run: cd integration_test && docker-compose down
run: cd tests/e2e && docker-compose down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LDFLAGS='-linkmode=external -extldflag
FROM alpine:3.15 AS runtime

WORKDIR /opt
RUN [ "mkdir", "-p", "/opt/integration_test" ]
RUN [ "mkdir", "-p", "/opt/tests/integration" ]

COPY --from=build /localnet/build/xplad /usr/bin/xplad
COPY --from=build /localnet/integration_test /opt/integration_test
COPY --from=build /localnet/tests/e2e /opt/tests/e2e

# Expose Cosmos ports
EXPOSE 9090
Expand Down
48 changes: 0 additions & 48 deletions integration_test/README.md

This file was deleted.

File renamed without changes.
48 changes: 48 additions & 0 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# End-to-end Test

This module is basically for the automated end-to-end test. But if you want to execute by yourself for testing (test testing) purpose, this tests are also executable on your local. Please follow the step below:

## Prerequisites

- Docker >= 20.10
- Docker compose >= 2.12

## How to run

```bash
# 1. From the repo root, move to the tests/e2e, and execute docker compose
cd tests/e2e
docker-compose up -d

# 2. Wait for building. Once done without error, you may check the nodes running
docker ps

#CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
#648b7146ce8c e2e-node1 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 0.0.0.0:8545->8545/tcp, 0.0.0.0:9090->9090/tcp, 0.0.0.0:26656->26656/tcp xpla-localnet-validator1
#97279d567135 e2e-node2 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 8545/tcp, 9090/tcp, 0.0.0.0:9100->9100/tcp, 26656/tcp, 0.0.0.0:26666->26666/tcp xpla-localnet-validator2
#f604f68c3f82 e2e-node3 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 8545/tcp, 9090/tcp, 0.0.0.0:9110->9110/tcp, 26656/tcp, 0.0.0.0:26676->26676/tcp xpla-localnet-validator3
#c3d0d9daefd2 e2e-node4 "sh -c 'MONIKER=vali…" 44 minutes ago Up 44 minutes 8545/tcp, 9090/tcp, 0.0.0.0:9120->9120/tcp, 26656/tcp, 0.0.0.0:26686->26686/tcp xpla-localnet-validator4

# 3. Execute tests
go test

# Do not execute short mode
# (X) go test -short

# ...
# PASS
# ok github.com/xpladev/xpla/tests/e2e 29.365s

# If you see the pass sign, you may down the nodes
docker-compose down
```

## Test scenario

### WASM

- Send `delegation` tx
- Upload the contract binary and get a code ID
- With the code ID above, try to instantiate the contract
- Execute the contract
- Assert from querying the contract in each test step by assertion
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: xpla-localnet-validator1

build:
context: ../.
context: ../../.
target: runtime

volumes:
Expand All @@ -16,7 +16,7 @@ services:
- "36656:26656"
- "36657:26657"

entrypoint: sh -c "MONIKER=validator1 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_master.sh"
entrypoint: sh -c "MONIKER=validator1 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_master.sh"

networks:
vpcbr:
Expand All @@ -32,15 +32,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18555:8545"
- "19100:9090"
- "36666:26656"

entrypoint: sh -c "MONIKER=validator2 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=validator2 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -56,15 +56,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18565:8545"
- "19110:9090"
- "36676:26656"

entrypoint: sh -c "MONIKER=validator3 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=validator3 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -80,15 +80,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18575:8545"
- "19120:9090"
- "36686:26656"

entrypoint: sh -c "MONIKER=validator4 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=validator4 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -104,15 +104,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18585:8545"
- "19130:9090"
- "36696:26656"

entrypoint: sh -c "MONIKER=validator5_experimental XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=validator5_experimental XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -128,15 +128,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18595:8545"
- "19140:9090"
- "36706:26656"

entrypoint: sh -c "MONIKER=volunteer_validator1 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=volunteer_validator1 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -152,15 +152,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18605:8545"
- "19150:9090"
- "36716:26656"

entrypoint: sh -c "MONIKER=volunteer_validator2 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=volunteer_validator2 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand All @@ -176,15 +176,15 @@ services:
- node1

build:
context: ../.
context: ../../.
target: runtime

ports:
- "18615:8545"
- "19160:9090"
- "36726:26656"

entrypoint: sh -c "MONIKER=volunteer_validator3 XPLAHOME=$XPLAHOME sh /opt/integration_test/entrypoint_secondary.sh"
entrypoint: sh -c "MONIKER=volunteer_validator3 XPLAHOME=$XPLAHOME sh /opt/tests/e2e/entrypoint_secondary.sh"

networks:
vpcbr:
Expand Down
10 changes: 5 additions & 5 deletions integration_test/entrypoint.sh → tests/e2e/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/tests/e2e/entrypoint.sh

# 1. chain init
/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME

# 2. copy the node setting files to the node home dir
cp -r /opt/integration_test/$MONIKER/* /opt/.xpla/config
cp -r /opt/tests/e2e/$MONIKER/* /opt/.xpla/config

# 3. register my validator & users keyfile
/usr/bin/xplad keys add validator1 --recover --home $XPLAHOME < /opt/integration_test/test_keys/$MONIKER.mnemonics
/usr/bin/xplad keys add user1 --recover --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics
/usr/bin/xplad keys add user2 --recover --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics
/usr/bin/xplad keys add validator1 --recover --home $XPLAHOME < /opt/tests/e2e/test_keys/$MONIKER.mnemonics
/usr/bin/xplad keys add user1 --recover --home $XPLAHOME < /opt/tests/e2e/test_keys/user1.mnemonics
/usr/bin/xplad keys add user2 --recover --home $XPLAHOME < /opt/tests/e2e/test_keys/user2.mnemonics

# 4. check genesis.json
/usr/bin/xplad validate-genesis --home $XPLAHOME
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/tests/e2e/entrypoint.sh

# File is not atomic and somestimes secondary nodes copies the existing old genesisfile
# It should be cleared
Expand All @@ -10,25 +10,25 @@ rm -f /genesis/*

# 2. Register the keys
# xpla1z2k85n48ydfvzslrugwzl4j2u7vtdyf3xvucmc
/usr/bin/xplad keys add validator1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator1.mnemonics
/usr/bin/xplad keys add validator1 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/validator1.mnemonics
# xpla16wx7ye3ce060tjvmmpu8lm0ak5xr7gm2dp0kpt
/usr/bin/xplad keys add validator2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator2.mnemonics
/usr/bin/xplad keys add validator2 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/validator2.mnemonics
# xpla1pe9mc2q72u94sn2gg52ramrt26x5efw6hr5gt4
/usr/bin/xplad keys add validator3 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator3.mnemonics
/usr/bin/xplad keys add validator3 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/validator3.mnemonics
# xpla1luqjvjyns9e92h06tq6zqtw76k8xtegfcerzjr
/usr/bin/xplad keys add validator4 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator4.mnemonics
/usr/bin/xplad keys add validator4 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/validator4.mnemonics
# xpla1y6gnay0pv49asun56la09jcmhg2kc949mpftvt
/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics
/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/user1.mnemonics
# xpla1u27snswkjpenlscgvszcfjmz8uy2y5qacx0826
/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics
/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/user2.mnemonics
# xpla14xprgqlnuep23kmvsk5utd9pw7w27yeyjlcmcz -- validator5_experimental
/usr/bin/xplad keys add validator5_experimental --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/validator5_experimental.mnemonics
/usr/bin/xplad keys add validator5_experimental --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/validator5_experimental.mnemonics
# xpla1ur90l8ecppc55gll7k57dk2tvs2w5m9jzptpcj -- volunteer validator1
/usr/bin/xplad keys add volunteer_validator1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/volunteer_validator1.mnemonics
/usr/bin/xplad keys add volunteer_validator1 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/volunteer_validator1.mnemonics
# xpla1yct6tmmm0twn2wz637lt0yz62xwtqhyqa84uu5 -- volunteer validator2
/usr/bin/xplad keys add volunteer_validator2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/volunteer_validator2.mnemonics
/usr/bin/xplad keys add volunteer_validator2 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/volunteer_validator2.mnemonics
# xpla1unq7rvf4jkcpmqww09j0u8k37qkgjxm43llwx5 -- volunteer validator3
/usr/bin/xplad keys add volunteer_validator3 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/volunteer_validator3.mnemonics
/usr/bin/xplad keys add volunteer_validator3 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/volunteer_validator3.mnemonics

# 3. Add the genesis accounts
/usr/bin/xplad add-genesis-account $(/usr/bin/xplad keys show validator1 -a --keyring-backend test --home $XPLAHOME) 100000000000000000000axpla --keyring-backend test --home $XPLAHOME
Expand All @@ -49,8 +49,8 @@ rm -f /genesis/*
for IDX in 1 2 3 4
do
# 1) Copy the credentials
cp /opt/integration_test/validator$IDX/node_key.json $XPLAHOME/config
cp /opt/integration_test/validator$IDX/priv_validator_key.json $XPLAHOME/config
cp /opt/tests/e2e/validator$IDX/node_key.json $XPLAHOME/config
cp /opt/tests/e2e/validator$IDX/priv_validator_key.json $XPLAHOME/config

# 2) Execute a gentx
/usr/bin/xplad gentx validator$IDX 9000000000000000000axpla \
Expand Down Expand Up @@ -104,8 +104,8 @@ cp $XPLAHOME/config/genesis.json /genesis
### followings are for validator setting

# 1. Copy the node setting files to the node home dir
cp -r /opt/integration_test/$MONIKER/* $XPLAHOME/config
cp -r /opt/integration_test/common_configs/* $XPLAHOME/config
cp -r /opt/tests/e2e/$MONIKER/* $XPLAHOME/config
cp -r /opt/tests/e2e/common_configs/* $XPLAHOME/config

# 2. Get genesis.json from the shared
cp /genesis/genesis.json $XPLAHOME/config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/integration_test/entrypoint.sh
# MONIKER=validator1|validator2|validator3|validator4 sh /opt/tests/e2e/entrypoint.sh

# 1. chain init
/usr/bin/xplad init $MONIKER --chain-id localtest_1-1 --home $XPLAHOME

# 2. copy the node setting files to the node home dir
cp -r /opt/integration_test/$MONIKER/* $XPLAHOME/config
cp -r /opt/integration_test/common_configs/* $XPLAHOME/config
cp -r /opt/tests/e2e/$MONIKER/* $XPLAHOME/config
cp -r /opt/tests/e2e/common_configs/* $XPLAHOME/config

sed -i "s/moniker = \"validator1\"/moniker = \"$MONIKER\"/g" $XPLAHOME/config/config.toml

# 3. register my validator & users keyfile
/usr/bin/xplad keys add $MONIKER --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/$MONIKER.mnemonics
/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user1.mnemonics
/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/integration_test/test_keys/user2.mnemonics
/usr/bin/xplad keys add $MONIKER --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/$MONIKER.mnemonics
/usr/bin/xplad keys add user1 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/user1.mnemonics
/usr/bin/xplad keys add user2 --recover --keyring-backend test --home $XPLAHOME < /opt/tests/e2e/test_keys/user2.mnemonics

# 4. get genesis.json from the shared folder
# "depends_on" in docker-compose.yml means that it depends on Dockerfile image, not completely wait for the entrypoint exeuction.
Expand Down
Loading

0 comments on commit ebdc691

Please sign in to comment.