Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add admin and performance test and fix upgrade test #1805

Merged
merged 37 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
5af94c0
simplify docker compose
lumtis Feb 22, 2024
3a4a6ea
fix makefi;e
lumtis Feb 22, 2024
ba58886
add new version
lumtis Feb 22, 2024
67f79ed
type
lumtis Feb 22, 2024
c71c520
fix restart client
lumtis Feb 22, 2024
5ce7868
some fixes
lumtis Feb 22, 2024
09f81bd
add light upgrade test
lumtis Feb 22, 2024
e137e48
fix gov sending
lumtis Feb 23, 2024
1060abe
add admin function test command
lumtis Feb 23, 2024
e99e788
performance test
lumtis Feb 23, 2024
a7cb7f5
fix lint
lumtis Feb 23, 2024
6e495df
add pprof port
lumtis Feb 27, 2024
1b818c8
some fixes in tests
lumtis Feb 27, 2024
9d26592
test: emissions unit test (#1767)
kingpinXD Feb 22, 2024
6f0e9c4
ci: run build workflow on develop push for code coverage generation (…
lumtis Feb 22, 2024
0798c38
refactor: zetaclient metrics (#1783)
skosito Feb 26, 2024
8d3a78c
feat: initiated feature of zetaclient-restricted-address (#1790)
ws4charlie Feb 26, 2024
60077bc
chore(codecov.yml): fix ignore extension (#1814)
lumtis Feb 27, 2024
920279d
refactor: remove params from config and introduce app context (#1774)
skosito Feb 27, 2024
6dbb3c1
refactor(`crosschain`): move ballot voting logic into `observer` (#1511)
lumtis Feb 29, 2024
3cb13bc
remove unused comment
lumtis Mar 1, 2024
69a94c5
conflicts
lumtis Mar 5, 2024
b0971e1
fix bitcoin credentials
lumtis Mar 5, 2024
351ec83
change upgrade version
lumtis Mar 6, 2024
e00e34a
conflicts
lumtis Mar 6, 2024
a1c1232
fix performance tests
lumtis Mar 6, 2024
4803004
handler
lumtis Mar 6, 2024
d1f542d
fix setup handler
lumtis Mar 7, 2024
004da79
add light flag and use it for upgrade tests
lumtis Mar 7, 2024
880bbb9
changelog
lumtis Mar 7, 2024
d69550e
fix username
lumtis Mar 7, 2024
5684095
add performance test back
lumtis Mar 7, 2024
6be6697
Update cmd/zetae2e/local/ethereum.go
lumtis Mar 7, 2024
0694fc5
stefan comments
lumtis Mar 10, 2024
d1b5a19
conflicts
lumtis Mar 12, 2024
e32ea48
changelog
lumtis Mar 12, 2024
8838ac9
fix
lumtis Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ WORKDIR /go/delivery/zeta-node
# Copy module files and download dependencies
COPY go.mod .
COPY go.sum .

RUN go mod download

# Copy the rest of the source code and build the application
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ WORKDIR /go/delivery/zeta-node
RUN mkdir -p $GOPATH/bin/old
RUN mkdir -p $GOPATH/bin/new

ARG OLD_VERSION=v13.0.0
ENV NEW_VERSION=v14
ARG OLD_VERSION=v14.0.0
ENV NEW_VERSION=v15

# Build new release from the current source
COPY go.mod /go/delivery/zeta-node/
Expand Down
26 changes: 17 additions & 9 deletions LOCAL_TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ $ make zetanode

This Makefile rule builds the zetanode image. **Rebuild if zetacored/zetaclientd code is updated**.
```bash
# in zeta-node/
$ docker build -t zetanode .
```

### Run e2e tests

Now we have built all the docker images, we can run the e2e test with make command:
```bash
# in zeta-node/
make start-e2e-test
```

#### Run admin functions e2e tests

We define e2e tests allowing to test admin functionalities (emergency network pause for example).
Since these tests interact with the network functionalities, these can't be run concurrently with the regular e2e tests.
Moreover, these tests test scoped functionalities of the protocol, and won't be tested in the same pipeline as the regular e2e tests.
Therefore, we provide a separate command to run e2e admin functions tests:
```bash
make start-e2e-admin-test
```

### Run upgrade tests

Upgrade tests run the E2E tests with an older version, upgrade the nodes to the new version, and run the E2E tests again.
Expand All @@ -46,18 +54,22 @@ NOTE: We only specify the major version for `NEW_VERSION` since we use major ver

The upgrade tests can be run with the following command:
```bash
# in zeta-node/
make start-upgrade-test
```

The test the upgrade script faster a light version of the upgrade test can be run with the following command:
```bash
make start-upgrade-test-light
```
This command will run the upgrade test with a lower height and will not populate the state.

### Run stress tests

Stress tests run the E2E tests with a larger number of nodes and clients to test the performance of the network.
It also stresses the network by sending a large number of cross-chain transactions.

The stress tests can be run with the following command:
```bash
# in zeta-node/
make start-stress-test
```

Expand All @@ -68,15 +80,14 @@ If everything works fine, it should finish without panic.

The logs can be observed with the following command:
```bash
# in zeta-node/contrib/localnet/orchestrator
# in node/contrib/localnet/orchestrator
$ docker logs -f orchestrator
```

### Stop tests

To stop the tests,
```bash
# in zeta-node/
make stop-test
```

Expand All @@ -86,7 +97,6 @@ Before starting the monitoring setup, make sure the Zetacore API is up at http:/
You can also add any additional ETH addresses to monitor in `zeta-node/contrib/localnet/grafana/addresses.txt` file

```bash
# in zeta-node/
make start-monitoring
```

Expand All @@ -97,7 +107,6 @@ The Grafana default credentials are admin:admin. The dashboards are located at h
### Stop monitoring setup

```bash
# in zeta-node/
make stop-monitoring
```

Expand All @@ -108,7 +117,6 @@ In addition to running automated tests, you can also interact with the localnet
The localnet can be started without running tests with the following command:

```bash
# in zeta-node/
make start-localnet
```

Expand Down
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,35 @@ install-zetae2e: go.sum
@go install -mod=readonly $(BUILD_FLAGS) ./cmd/zetae2e
.PHONY: install-zetae2e

start-e2e-test:
start-e2e-test: zetanode
@echo "--> Starting e2e test"
cd contrib/localnet/ && $(DOCKER) compose up -d

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

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

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

start-upgrade-test:
@echo "--> Starting upgrade test"
$(DOCKER) build --build-arg -t zetanode -f ./Dockerfile-upgrade .
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade.yml up -d

start-localnet:
start-upgrade-test-light:
@echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)"
$(DOCKER) build -t zetanode -f ./Dockerfile-upgrade .
$(DOCKER) build -t orchestrator -f contrib/localnet/orchestrator/Dockerfile.fastbuild .
cd contrib/localnet/ && $(DOCKER) compose -f docker-compose.yml -f docker-compose-upgrade-light.yml up -d

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

Expand Down
9 changes: 5 additions & 4 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const releaseVersion = "v14"
const releaseVersion = "v15"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -17,7 +18,7 @@ func SetupHandlers(app *App) {
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}
VersionMigrator{v: vm}.TriggerMigration(crosschaintypes.ModuleName)
VersionMigrator{v: vm}.TriggerMigration(observertypes.ModuleName)

return app.mm.RunMigrations(ctx, app.configurator, vm)
})
Expand All @@ -28,7 +29,7 @@ func SetupHandlers(app *App) {
}
if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
// Added: []string{},
Added: []string{authoritytypes.ModuleName},
}
// Use upgrade store loader for the initial loading of all stores when app starts,
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* [1840](https://github.com/zeta-chain/node/pull/1840) - fix code coverage test failures ignored in CI
* [1851](https://github.com/zeta-chain/node/pull/1851) - rename usdt to erc20 in e2e tests
* [1872](https://github.com/zeta-chain/node/pull/1872) - remove usage of RPC in unit test
* [1805](https://github.com/zeta-chain/node/pull/1805) - add admin and performance test and fix upgrade test

### Fixes

Expand Down Expand Up @@ -93,7 +94,6 @@
* [1584](https://github.com/zeta-chain/node/pull/1584) - allow to run E2E tests on any networks
* [1746](https://github.com/zeta-chain/node/pull/1746) - rename smoke tests to e2e tests
* [1753](https://github.com/zeta-chain/node/pull/1753) - fix gosec errors on usage of rand package

* [1762](https://github.com/zeta-chain/node/pull/1762) - improve coverage for fungibile module
* [1782](https://github.com/zeta-chain/node/pull/1782) - improve coverage for fungibile module system contract

Expand Down
1 change: 0 additions & 1 deletion cmd/zetae2e/config/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func getBtcClient(rpcConf config.BitcoinRPC) (*rpcclient.Client, error) {
HTTPPostMode: rpcConf.HTTPPostMode,
DisableTLS: rpcConf.DisableTLS,
Params: param,
//Endpoint: "/wallet/user",
lumtis marked this conversation as resolved.
Show resolved Hide resolved
}
return rpcclient.New(connCfg, nil)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/zetae2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func ExportContractsFromRunner(r *runner.E2ERunner, conf config.Config) config.C
conf.Contracts.ZEVM.BTCZRC20Addr = r.BTCZRC20Addr.Hex()
conf.Contracts.ZEVM.UniswapFactoryAddr = r.UniswapV2FactoryAddr.Hex()
conf.Contracts.ZEVM.UniswapRouterAddr = r.UniswapV2RouterAddr.Hex()
conf.Contracts.ZEVM.ConnectorZEVMAddr = r.ConnectorZEVMAddr.Hex()
conf.Contracts.ZEVM.WZetaAddr = r.WZetaAddr.Hex()
conf.Contracts.ZEVM.ZEVMSwapAppAddr = r.ZEVMSwapAppAddr.Hex()
conf.Contracts.ZEVM.ContextAppAddr = r.ContextAppAddr.Hex()
conf.Contracts.ZEVM.TestDappAddr = r.TestDAppAddr.Hex()
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetae2e/config/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rpcs:
evm: "http://0.0.0.0:8545"
bitcoin:
host: "0.0.0.0:18443"
user: "e2e"
user: "smoketest"
lumtis marked this conversation as resolved.
Show resolved Hide resolved
pass: "123"
http_post_mode: true
disable_tls: true
Expand Down
5 changes: 2 additions & 3 deletions cmd/zetae2e/local/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func adminTestRoutine(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
testNames ...string,
) func() error {
return func() (err error) {
// return an error on panic
Expand Down Expand Up @@ -63,9 +64,7 @@ func adminTestRoutine(
// run erc20 advanced test
testsToRun, err := adminRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestPauseZRC20Name,
e2etests.TestUpdateBytecodeName,
e2etests.TestDepositEtherLiquidityCapName,
testNames...,
)
if err != nil {
return fmt.Errorf("admin tests failed: %v", err)
Expand Down
10 changes: 4 additions & 6 deletions cmd/zetae2e/local/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func bitcoinTestRoutine(
deployerRunner *runner.E2ERunner,
verbose bool,
initBitcoinNetwork bool,
testHeader bool,
testNames ...string,
) func() error {
return func() (err error) {
// return an error on panic
Expand Down Expand Up @@ -59,18 +61,14 @@ func bitcoinTestRoutine(
bitcoinRunner.WaitForMinedCCTX(txERC20Deposit)

bitcoinRunner.SetupBitcoinAccount(initBitcoinNetwork)
bitcoinRunner.DepositBTC(true)
bitcoinRunner.DepositBTC(testHeader)

// run bitcoin test
// Note: due to the extensive block generation in Bitcoin localnet, block header test is run first
// to make it faster to catch up with the latest block header
testsToRun, err := bitcoinRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestBitcoinWithdrawInvalidAddressName,
e2etests.TestBitcoinWithdrawName,
e2etests.TestZetaWithdrawBTCRevertName,
e2etests.TestCrosschainSwapName,
e2etests.TestBitcoinWithdrawRestrictedName,
testNames...,
)
if err != nil {
return fmt.Errorf("bitcoin tests failed: %v", err)
Expand Down
10 changes: 2 additions & 8 deletions cmd/zetae2e/local/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func erc20TestRoutine(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
testNames ...string,
) func() error {
return func() (err error) {
// return an error on panic
Expand Down Expand Up @@ -56,17 +57,10 @@ func erc20TestRoutine(
erc20Runner.WaitForMinedCCTX(txEtherDeposit)
erc20Runner.WaitForMinedCCTX(txERC20Deposit)

//erc20Runner.SetupBitcoinAccount()
//erc20Runner.DepositBTC()

// run erc20 test
testsToRun, err := erc20Runner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestERC20WithdrawName,
e2etests.TestMultipleWithdrawsName,
e2etests.TestERC20DepositAndCallRefundName,
e2etests.TestZRC20SwapName,
e2etests.TestERC20DepositRestrictedName,
testNames...,
)
if err != nil {
return fmt.Errorf("erc20 tests failed: %v", err)
Expand Down
10 changes: 4 additions & 6 deletions cmd/zetae2e/local/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ func ethereumTestRoutine(
conf config.Config,
deployerRunner *runner.E2ERunner,
verbose bool,
testHeader bool,
testNames ...string,
) func() error {
return func() (err error) {
// return an error on panic
Expand Down Expand Up @@ -47,19 +49,15 @@ func ethereumTestRoutine(
startTime := time.Now()

// depositing the necessary tokens on ZetaChain
txEtherDeposit := ethereumRunner.DepositEther(true)
txEtherDeposit := ethereumRunner.DepositEther(testHeader)
ethereumRunner.WaitForMinedCCTX(txEtherDeposit)

// run ethereum test
// Note: due to the extensive block generation in Ethereum localnet, block header test is run first
// to make it faster to catch up with the latest block header
testsToRun, err := ethereumRunner.GetE2ETestsToRunByName(
e2etests.AllE2ETests,
e2etests.TestEtherWithdrawName,
e2etests.TestContextUpgradeName,
e2etests.TestEtherDepositAndCallName,
e2etests.TestDepositAndCallRefundName,
e2etests.TestEtherWithdrawRestrictedName,
testNames...,
)
if err != nil {
return fmt.Errorf("ethereum tests failed: %v", err)
Expand Down
Loading
Loading