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(system): Introduce system tests - initial version heavily inspired by wasmd #20013

Merged
merged 4 commits into from
Apr 30, 2024

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Apr 11, 2024

Description

System test against a multi node chain.
This package contains an orchestration framework and tooling to make it easy to run tests against a running system.
The idea is that tests run the CLI binary on the server and client side like production chains.

To reviewer:
I may be easier to start with the tests and then look into the framework code.

I have...

  • included the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new system testing framework for blockchain applications, including multi-node local testnet capabilities.
    • Added system test execution in continuous integration (CI) processes.
    • Enhanced command line interface (CLI) testing capabilities.
  • Bug Fixes

    • Ensured VERSION is set correctly in the build process when absent.
  • Documentation

    • Updated README to include information on the new system testing framework.
  • Chores

    • Updated CI workflows to exclude certain directories and incorporate system tests.
    • Included new makefile targets and .gitignore entries to support system testing.

Copy link
Contributor

coderabbitai bot commented Apr 11, 2024

Walkthrough

The changes involve introducing system testing capabilities for a blockchain system, excluding specific directories from security checks, and refining build and test workflows.

Changes

Files Changes Summary
.github/workflows/gosec.yml Excluded systemtests directory from security checks.
.github/workflows/test.yml Added test-system job, updated repo-analysis with environment variables, and other minor workflow enhancements.
CHANGELOG.md Documented addition of system tests for multi-node local testnets.
Makefile, systemtests/Makefile Updated to support system testing with new targets and versioning conditions.
systemtests/*.go, systemtests/README.md Introduced various Go files and a README for a new system testing framework, covering CLI interactions, genesis state manipulation, RPC communications, staking, upgrades, and more.

Possibly related issues

  • Add wasmd tests to e2e ibc-go#3940: The changes in this PR align with the objectives of enhancing testing frameworks for blockchain systems, potentially addressing the need for testing smart contract interactions and compatibility between different components as outlined in the issue.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

systemtests/testnet_init.go Fixed Show fixed Hide fixed
systemtests/testnet_init.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
@alpe alpe changed the title [WIP] Introduce system tests - initial version heavily inspired by wasmd test: [WIP] Introduce system tests - initial version heavily inspired by wasmd Apr 11, 2024
@alpe alpe force-pushed the alex/system_tests_wip branch 4 times, most recently from 354a977 to fafc2c9 Compare April 11, 2024 13:38
systemtests/testnet_init.go Fixed Show fixed Hide fixed
systemtests/cli.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Dismissed Show dismissed Hide dismissed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
@alpe alpe force-pushed the alex/system_tests_wip branch 3 times, most recently from f5bca81 to 590b8a2 Compare April 12, 2024 12:34
systemtests/system.go Fixed Show fixed Hide fixed
systemtests/system.go Fixed Show fixed Hide fixed
@alpe alpe force-pushed the alex/system_tests_wip branch 2 times, most recently from dce136b to aacf13a Compare April 12, 2024 13:34
systemtests/system.go Fixed Show fixed Hide fixed
@alpe alpe force-pushed the alex/system_tests_wip branch 9 times, most recently from 8a809a4 to c124edc Compare April 13, 2024 09:32
@@ -13,6 +13,10 @@ HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git
DOCKER := $(shell which docker)
PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)

ifeq ($(findstring .,$(VERSION)),)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the version contains no dot, then it is not a semantic version. This is the case for a PR branch for example. The CLI requires a valid sematic version so I default to an unused one


require (
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
github.com/cosmos/cosmos-sdk v0.50.5
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some SDK is used but as the system tests work with the current binary, this can be an older version.

@@ -0,0 +1,113 @@
//go:build system_test && linux
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the the old binary is fetched from docker, this does not run on mac. The hack for testing is to compile the old binary on the system and copy it to the binary folder, so that it is not fetched again

@alpe alpe marked this pull request as ready for review April 24, 2024 07:33
@alpe alpe requested a review from a team as a code owner April 24, 2024 07:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 13

Out of diff range and nitpick comments (5)
systemtests/staking_test.go (1)

12-54: The TestStakeUnstake function is well-structured for testing staking and unstaking scenarios. Consider adding more detailed comments to explain the steps and assertions for better readability and maintainability.

systemtests/upgrade_test.go (1)

19-90: The TestChainUpgrade function effectively simulates a chain upgrade scenario. Consider adding error handling for Docker commands to ensure robustness in case of command failures.

systemtests/testnet_init.go (2)

16-26: Ensure proper documentation for the SingleHostTestnetCmdInitializer type.

Adding a detailed comment explaining the purpose and usage of this type would improve code maintainability and readability.


68-79: Ensure proper documentation for the ModifyConfigYamlInitializer type.

Adding a detailed comment explaining the purpose and usage of this type would improve code maintainability and readability.

systemtests/cli.go (1)

33-46: Ensure proper documentation for the CLIWrapper type.

Adding a detailed comment explaining the purpose and usage of this type would improve code maintainability and readability.

Comment on lines +147 to +196
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/get-diff-action@v6.1.2
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure consistent artifact naming and avoid duplicate steps.

In the test-system job, the artifact name "testnet-setup" is used twice (lines 184 and 194) for uploading artifacts on failure. This could lead to overwriting of artifacts or confusion in artifact handling. Consider using unique names for each artifact or consolidating the steps if they are intended to capture the same files.

Comment on lines +73 to +79
if execBinary == "" {
panic("executable binary name must not be empty")
}
nameTokens := ExecBinaryUnversionedRegExp.FindAllString(execBinary, 1)
if len(nameTokens) == 0 || nameTokens[0] == "" {
panic("failed to parse project name from binary")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper error handling instead of panicking for empty executable binary names.

- panic("executable binary name must not be empty")
+ return nil, errors.New("executable binary name must not be empty")

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if execBinary == "" {
panic("executable binary name must not be empty")
}
nameTokens := ExecBinaryUnversionedRegExp.FindAllString(execBinary, 1)
if len(nameTokens) == 0 || nameTokens[0] == "" {
panic("failed to parse project name from binary")
}
if execBinary == "" {
return nil, errors.New("executable binary name must not be empty")
}
nameTokens := ExecBinaryUnversionedRegExp.FindAllString(execBinary, 1)
if len(nameTokens) == 0 || nameTokens[0] == "" {
panic("failed to parse project name from binary")
}

Comment on lines +117 to +119
if err := os.RemoveAll(filepath.Join(WorkDir, s.outputDir)); err != nil {
panic(err.Error())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace panic with proper error handling in SetupChain.

- panic(err.Error())
+ return fmt.Errorf("failed to remove all files in directory: %w", err)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if err := os.RemoveAll(filepath.Join(WorkDir, s.outputDir)); err != nil {
panic(err.Error())
}
if err := os.RemoveAll(filepath.Join(WorkDir, s.outputDir)); err != nil {
return fmt.Errorf("failed to remove all files in directory: %w", err)
}

Comment on lines +187 to +189
if err != nil {
panic(fmt.Sprintf("open logfile error %#+v", err))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace panic with proper error handling in watchLogs.

- panic(fmt.Sprintf("open logfile error %#+v", err))
+ return fmt.Errorf("open logfile error: %w", err)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if err != nil {
panic(fmt.Sprintf("open logfile error %#+v", err))
}
if err != nil {
return fmt.Errorf("open logfile error: %w", err)
}

Comment on lines 43 to +44
### Features

* (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure proper Markdown formatting by adding blank lines around the heading and the list.

+ Every module contains its own CHANGELOG.md. Please refer to the module you are interested in.
+
### Features
+
* (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI
* (runtime) [#19953](https://github.com/cosmos/cosmos-sdk/pull/19953) Implement `core/transaction.Service` in runtime.
* (client) [#19905](https://github.com/cosmos/cosmos-sdk/pull/19905) Add grpc client config to `client.toml`.
* (runtime) [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Implement `core/router.Service` in runtime. This service is present in all modules (when using depinject).
+

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
### Features
* (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI
Every module contains its own CHANGELOG.md. Please refer to the module you are interested in.
### Features
* (tests) [#20013](https://github.com/cosmos/cosmos-sdk/pull/20013) Introduce system tests to run multi node local testnet in CI
* (runtime) [#19953](https://github.com/cosmos/cosmos-sdk/pull/19953) Implement `core/transaction.Service` in runtime.
* (client) [#19905](https://github.com/cosmos/cosmos-sdk/pull/19905) Add grpc client config to `client.toml`.
* (runtime) [#19571](https://github.com/cosmos/cosmos-sdk/pull/19571) Implement `core/router.Service` in runtime. This service is present in all modules (when using depinject).

Comment on lines +919 to +921
in, err := os.Open(src)
if err != nil {
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure error handling when opening a file in copyFile.

- if err != nil {
-     return nil, err
- }
+ return nil, fmt.Errorf("failed to open source file: %w", err)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
in, err := os.Open(src)
if err != nil {
return nil, err
in, err := os.Open(src)
return nil, fmt.Errorf("failed to open source file: %w", err)

systemtests/testnet_init.go Show resolved Hide resolved
Comment on lines +102 to +150
func (s ModifyConfigYamlInitializer) Initialize() {
// init with legacy testnet command
args := []string{
"testnet",
"init-files",
"--chain-id=" + s.chainID,
"--output-dir=" + s.outputDir,
"--v=" + strconv.Itoa(s.initialNodesCount),
"--keyring-backend=test",
"--minimum-gas-prices=" + s.minGasPrice,
}
s.log(fmt.Sprintf("+++ %s %s\n", s.execBinary, strings.Join(args, " ")))

out, err := runShellCmdX(s.execBinary, args...)
if err != nil {
panic(err)
}
s.log(out)

nodeAddresses := make([]string, s.initialNodesCount)
for i := 0; i < s.initialNodesCount; i++ {
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
id := string(mustV(p2p.LoadNodeKey(filepath.Join(nodeDir, "node_key.json"))).ID())
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, p2pPortStart+i)
}

// then update configs
for i := 0; i < s.initialNodesCount; i++ {
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
nodeNumber := i
EditToml(filepath.Join(nodeDir, "config.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, rpcPortStart+i, "rpc", "laddr")
UpdatePort(doc, p2pPortStart+i, "p2p", "laddr")
SetBool(doc, false, "p2p", "addr_book_strict")
SetBool(doc, false, "p2p", "pex")
SetBool(doc, true, "p2p", "allow_duplicate_ip")
peers := make([]string, s.initialNodesCount)
copy(peers, nodeAddresses[0:nodeNumber])
copy(peers[nodeNumber:], nodeAddresses[nodeNumber+1:])
SetValue(doc, strings.Join(peers, ","), "p2p", "persistent_peers")
SetValue(doc, s.commitTimeout.String(), "consensus", "timeout_commit")
})
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, apiPortStart+i, "api", "address")
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
SetBool(doc, true, "grpc-web", "enable")
})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review the error handling strategy in the Initialize method.

Using panic for error handling is not recommended in production code as it can lead to abrupt termination of the program. Consider returning an error and handling it gracefully.

- panic(err)
+ return err

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
func (s ModifyConfigYamlInitializer) Initialize() {
// init with legacy testnet command
args := []string{
"testnet",
"init-files",
"--chain-id=" + s.chainID,
"--output-dir=" + s.outputDir,
"--v=" + strconv.Itoa(s.initialNodesCount),
"--keyring-backend=test",
"--minimum-gas-prices=" + s.minGasPrice,
}
s.log(fmt.Sprintf("+++ %s %s\n", s.execBinary, strings.Join(args, " ")))
out, err := runShellCmdX(s.execBinary, args...)
if err != nil {
panic(err)
}
s.log(out)
nodeAddresses := make([]string, s.initialNodesCount)
for i := 0; i < s.initialNodesCount; i++ {
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
id := string(mustV(p2p.LoadNodeKey(filepath.Join(nodeDir, "node_key.json"))).ID())
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, p2pPortStart+i)
}
// then update configs
for i := 0; i < s.initialNodesCount; i++ {
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
nodeNumber := i
EditToml(filepath.Join(nodeDir, "config.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, rpcPortStart+i, "rpc", "laddr")
UpdatePort(doc, p2pPortStart+i, "p2p", "laddr")
SetBool(doc, false, "p2p", "addr_book_strict")
SetBool(doc, false, "p2p", "pex")
SetBool(doc, true, "p2p", "allow_duplicate_ip")
peers := make([]string, s.initialNodesCount)
copy(peers, nodeAddresses[0:nodeNumber])
copy(peers[nodeNumber:], nodeAddresses[nodeNumber+1:])
SetValue(doc, strings.Join(peers, ","), "p2p", "persistent_peers")
SetValue(doc, s.commitTimeout.String(), "consensus", "timeout_commit")
})
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, apiPortStart+i, "api", "address")
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
SetBool(doc, true, "grpc-web", "enable")
})
}
}
func (s ModifyConfigYamlInitializer) Initialize() error {
// init with legacy testnet command
args := []string{
"testnet",
"init-files",
"--chain-id=" + s.chainID,
"--output-dir=" + s.outputDir,
"--v=" + strconv.Itoa(s.initialNodesCount),
"--keyring-backend=test",
"--minimum-gas-prices=" + s.minGasPrice,
}
s.log(fmt.Sprintf("+++ %s %s\n", s.execBinary, strings.Join(args, " ")))
out, err := runShellCmdX(s.execBinary, args...)
if err != nil {
return err
}
s.log(out)
nodeAddresses := make([]string, s.initialNodesCount)
for i := 0; i < s.initialNodesCount; i++ {
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
id := string(mustV(p2p.LoadNodeKey(filepath.Join(nodeDir, "node_key.json"))).ID())
nodeAddresses[i] = fmt.Sprintf("%s@127.0.0.1:%d", id, p2pPortStart+i)
}
// then update configs
for i := 0; i < s.initialNodesCount; i++ {
nodeDir := filepath.Join(WorkDir, NodePath(i, s.outputDir, s.projectName), "config")
nodeNumber := i
EditToml(filepath.Join(nodeDir, "config.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, rpcPortStart+i, "rpc", "laddr")
UpdatePort(doc, p2pPortStart+i, "p2p", "laddr")
SetBool(doc, false, "p2p", "addr_book_strict")
SetBool(doc, false, "p2p", "pex")
SetBool(doc, true, "p2p", "allow_duplicate_ip")
peers := make([]string, s.initialNodesCount)
copy(peers, nodeAddresses[0:nodeNumber])
copy(peers[nodeNumber:], nodeAddresses[nodeNumber+1:])
SetValue(doc, strings.Join(peers, ","), "p2p", "persistent_peers")
SetValue(doc, s.commitTimeout.String(), "consensus", "timeout_commit")
})
EditToml(filepath.Join(nodeDir, "app.toml"), func(doc *tomledit.Document) {
UpdatePort(doc, apiPortStart+i, "api", "address")
UpdatePort(doc, grpcPortStart+i, "grpc", "address")
SetBool(doc, true, "grpc-web", "enable")
})
}
return nil
}

systemtests/cli.go Show resolved Hide resolved
Comment on lines +3 to +50
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding blank lines around headings for better readability and correct the grammatical error: change "For example Node 3 listens on 26660 for RPC calls" to "For example, Node 3 listens on 26660 for RPC calls".

- For example Node *3* listens on `26660` for RPC calls
+ For example, Node *3* listens on `26660` for RPC calls

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
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.
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

Disclaimer

This is based on the system test framework in wasmd built by Confio.


</details>
<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

@tac0turtle
Copy link
Member

do the system tests also run the upgrade test?

Copy link
Member

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

we should create an issue to migrate our e2e tests to use the system tests to avoid all the duplication we currently have

"title": "my upgrade",
"summary": "testing"
}`, govAddr, upgradeName, upgradeHeight)
proposalID := cli.SubmitAndVoteGovProposal(proposal)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the upgrade proposal on the v0.50 chain

t.Log("Upgrade height was reached. Upgrading chain")
sut.SetExecBinary(currentBranchBinary)
sut.SetTestnetInitializer(currentInitializer)
sut.StartChain(t)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here the chain is started with the latest binary (compiled in the Makefile, copied to systemtests/binaries and default in main_test.go)

@testinginprod testinginprod self-requested a review April 30, 2024 09:04
@tac0turtle tac0turtle added this pull request to the merge queue Apr 30, 2024
Merged via the queue into main with commit 3d1925d Apr 30, 2024
62 checks passed
@tac0turtle tac0turtle deleted the alex/system_tests_wip branch April 30, 2024 12:59
@@ -0,0 +1,162 @@
module cosmossdk.io/systemtests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make a PR here: https://github.com/cosmos/vanity
cc @alpe

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, missed this. Thanks for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants