forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(system): Introduce system tests - initial version heavily inspir…
…ed by wasmd (cosmos#20013)
- Loading branch information
Showing
18 changed files
with
3,333 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,57 @@ jobs: | |
name: "${{ github.sha }}-e2e-coverage" | ||
path: ./tests/e2e-profile.out | ||
|
||
test-system: | ||
needs: [tests, test-integration, test-e2e] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: true | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.22" | ||
check-latest: true | ||
cache: true | ||
cache-dependency-path: | | ||
simapp/go.sum | ||
systemtest/go.sum | ||
- uses: technote-space/[email protected] | ||
id: git_diff | ||
with: | ||
PATTERNS: | | ||
**/*.go | ||
go.mod | ||
go.sum | ||
**/go.mod | ||
**/go.sum | ||
**/Makefile | ||
Makefile | ||
- name: Install musl lib for simd (docker) binary | ||
if: env.GIT_DIFF | ||
run: | | ||
sudo apt-get install -y musl | ||
- name: system tests v1 | ||
if: env.GIT_DIFF | ||
run: | | ||
COSMOS_BUILD_OPTIONS=legacy make test-system | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: "testnet-setup" | ||
path: ./systemtests/testnet/ | ||
retention-days: 3 | ||
# - name: system tests v2 | ||
# if: env.GIT_DIFF | ||
# run: | | ||
# make test-system | ||
- uses: actions/upload-artifact@v3 | ||
if: failure() | ||
with: | ||
name: "testnet-setup" | ||
path: ./systemtests/testnet/ | ||
retention-days: 3 | ||
|
||
repo-analysis: | ||
runs-on: ubuntu-latest | ||
needs: [tests, test-integration, test-e2e] | ||
|
@@ -1245,7 +1296,7 @@ jobs: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
with: | ||
projectBaseDir: x/mint/ | ||
|
||
test-x-epochs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/testnet | ||
/binaries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/make -f | ||
|
||
WAIT_TIME ?= 45s | ||
|
||
all: test | ||
|
||
test: | ||
go test -mod=readonly -failfast -tags='system_test' ./... --wait-time=$(WAIT_TIME) --verbose | ||
|
||
format: | ||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gofumpt -w | ||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs misspell -w | ||
find . -name '*.go' -type f -not -path "./vendor*" -not -path "./tests/system/vendor*" -not -path "*.git*" -not -path "./client/lcd/statik/statik.go" | xargs gci write --skip-generated -s standard -s default -s "prefix(cosmossdk.io)" -s "prefix(github.com/cosmos/cosmos-sdk)" --custom-order | ||
|
||
.PHONY: all test format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Testing | ||
|
||
Test framework for system tests. | ||
Starts and interacts with a (multi node) blockchain in Go. | ||
Supports | ||
* CLI | ||
* Servers | ||
* Events | ||
* RPC | ||
|
||
Uses: | ||
* testify | ||
* gjson | ||
* sjson | ||
Server and client side are executed on the host machine | ||
|
||
## Developer | ||
### Test strategy | ||
System tests cover the full stack via cli and a running (multi node) network. They are more expensive (in terms of time/ cpu) | ||
to run compared to unit or integration tests. | ||
Therefore, we focus on the **critical path** and do not cover every condition. | ||
|
||
### Execute a single test | ||
|
||
```sh | ||
go test -tags system_test -count=1 -v . --run TestStakeUnstake -verbose | ||
``` | ||
|
||
Test cli parameters | ||
|
||
* `-verbose` verbose output | ||
* `-wait-time` duration - time to wait for chain events (default 30s) | ||
* `-nodes-count` int - number of nodes in the cluster (default 4) | ||
|
||
# Port ranges | ||
With *n* nodes: | ||
* `26657` - `26657+n` - RPC | ||
* `1317` - `1317+n` - API | ||
* `9090` - `9090+n` - GRPC | ||
* `16656` - `16656+n` - P2P | ||
|
||
For example Node *3* listens on `26660` for RPC calls | ||
|
||
## Resources | ||
|
||
* [gjson query syntax](https://github.com/tidwall/gjson#path-syntax) | ||
|
||
## Disclaimer | ||
|
||
This is based on the system test framework in [wasmd](https://github.com/CosmWasm/wasmd) built by Confio. |
Oops, something went wrong.