-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvstore test with cargo-make invoking docker (#748)
* kvstore test with cargo-make invoking docker * Moved integration tests into kvstore-test crate * subscription timeout upped to 5secs
- Loading branch information
1 parent
27b3b73
commit 8bbb09b
Showing
11 changed files
with
146 additions
and
77 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
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 @@ | ||
target/ | ||
Cargo.lock |
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,5 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"kvstore-test" | ||
] |
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 @@ | ||
[env] | ||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true |
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,36 @@ | ||
# Tools | ||
This folder contains tools that we use during development and testing. | ||
|
||
## kvstore-test | ||
This crate allows the developers to do integration testing against a Tendermint Go endpoint. Our CI also uses it. | ||
|
||
To run the tests locally, provided that a kvstore RPC endpoint is running on http://127.0.0.1:26657: | ||
```shell | ||
cargo test | ||
``` | ||
|
||
Alternatively, you can run: | ||
```shell | ||
cargo test-all-features | ||
``` | ||
which is exactly what we run in CI. | ||
|
||
If you don't have an endpoint running, but you have Docker installed, you can ask the testing framework to fire up a | ||
Docker container with the current stable Tendermint node. This happens automatically if you run: | ||
```shell | ||
cargo make | ||
``` | ||
|
||
and all tests will run while the docker container is available. As additional help, you can run | ||
|
||
```shell | ||
cargo make docker-up | ||
``` | ||
|
||
and | ||
|
||
```shell | ||
cargo make docker-down | ||
``` | ||
|
||
to manage the Docker container. |
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,17 @@ | ||
[package] | ||
name = "kvstore-test" | ||
version = "0.1.0" | ||
authors = ["Greg Szabo <[email protected]>"] | ||
edition = "2018" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
|
||
[dev-dependencies] | ||
futures = "0.3" | ||
tendermint = { version = "0.17.0", path = "../../tendermint" } | ||
tendermint-light-client = { version = "0.17.0", path = "../../light-client" } | ||
tendermint-rpc = { version = "0.17.0", path = "../../rpc", features = [ "http-client", "websocket-client" ] } | ||
tokio = { version = "0.2", features = [ "macros" ] } | ||
contracts = "0.4.0" |
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,38 @@ | ||
[env] | ||
CONTAINER_NAME = "kvstore-test" | ||
DOCKER_IMAGE = "informaldev/tendermint:0.34.0" | ||
HOST_RPC_PORT = 26657 | ||
CARGO_MAKE_WAIT_MILLISECONDS = 1000 | ||
|
||
[tasks.default] | ||
clear = true | ||
dependencies = [ "docker-up", "wait", "test", "docker-down" ] | ||
|
||
[tasks.docker-down] | ||
dependencies = [ "docker-stop", "docker-rm" ] | ||
|
||
[tasks.docker-up] | ||
command = "docker" | ||
args = ["run", "--name", "${CONTAINER_NAME}", "--rm", "--publish", "26657:${HOST_RPC_PORT}", "--detach", "${DOCKER_IMAGE}"] | ||
dependencies = ["docker-up-stop-old", "docker-up-rm-old"] | ||
|
||
[tasks.test] | ||
args = ["test-all-features"] | ||
|
||
[tasks.docker-stop] | ||
command = "docker" | ||
args = ["stop", "${CONTAINER_NAME}"] | ||
ignore_errors = true | ||
private = true | ||
|
||
[tasks.docker-rm] | ||
command = "docker" | ||
args = ["rm", "--force", "${CONTAINER_NAME}"] | ||
ignore_errors = true | ||
private = true | ||
|
||
[tasks.docker-up-stop-old] | ||
alias = "docker-stop" | ||
|
||
[tasks.docker-up-rm-old] | ||
alias = "docker-rm" |
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 @@ | ||
//! The kvstore-test crate enables online testing against a kvstore endpoint. | ||
//! Option 1: there is an existing kvstore RPC endpoint at 127.0.0.1:26657 | ||
//! for example in the CI setup this has been taken care of. | ||
//! Run: | ||
//! cargo test | ||
//! This will execute all integration tests against the RPC endpoint. | ||
//! | ||
//! Option 2: the docker daemon is installed and accessible on the machine where the test will happen | ||
//! for example: on a developer machine | ||
//! Run: | ||
//! cargo make | ||
//! This will start a docker container with Tendermint and attach port 26657 to the host machine. | ||
//! Then it will run all tests against the freshly created endpoint. | ||
//! Make sure you installed cargo-make by running `cargo install cargo-make` first. | ||
//! |
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