You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
5.2 KiB

  1. # End-to-End Tests
  2. Spins up and tests Tendermint networks in Docker Compose based on a testnet manifest. To run the CI testnet:
  3. ```sh
  4. make
  5. ./build/runner -f networks/ci.toml
  6. ```
  7. This creates and runs a testnet named `ci` under `networks/ci/` (determined by the manifest filename).
  8. ## Testnet Manifests
  9. Testnets are specified as TOML manifests. For an example see [`networks/ci.toml`](networks/ci.toml), and for documentation see [`pkg/manifest.go`](pkg/manifest.go).
  10. ## Random Testnet Generation
  11. Random (but deterministic) combinations of testnets can be generated with `generator`:
  12. ```sh
  13. ./build/generator -d networks/generated/
  14. # Split networks into 8 groups (by filename)
  15. ./build/generator -g 8 -d networks/generated/
  16. ```
  17. Multiple testnets can be run with the `run-multiple.sh` script:
  18. ```sh
  19. ./run-multiple.sh networks/generated/gen-group3-*.toml
  20. ```
  21. ## Test Stages
  22. The test runner has the following stages, which can also be executed explicitly by running `./build/runner -f <manifest> <stage>`:
  23. * `setup`: generates configuration files.
  24. * `start`: starts Docker containers.
  25. * `load`: generates a transaction load against the testnet nodes.
  26. * `perturb`: runs any requested perturbations (e.g. node restarts or network disconnects).
  27. * `wait`: waits for a few blocks to be produced, and for all nodes to catch up to it.
  28. * `test`: runs test cases in `tests/` against all nodes in a running testnet.
  29. * `stop`: stops Docker containers.
  30. * `cleanup`: removes configuration files and Docker containers/networks.
  31. Auxiliary commands:
  32. * `logs`: outputs all node logs.
  33. * `tail`: tails (follows) node logs until cancelled.
  34. ## Tests
  35. Test cases are written as normal Go tests in `tests/`. They use a `testNode()` helper which executes each test as a parallel subtest for each node in the network.
  36. ### Running Manual Tests
  37. To run tests manually, set the `E2E_MANIFEST` environment variable to the path of the testnet manifest (e.g. `networks/ci.toml`) and run them as normal, e.g.:
  38. ```sh
  39. ./build/runner -f networks/ci.toml start
  40. E2E_MANIFEST=networks/ci.toml go test -v ./tests/...
  41. ```
  42. Optionally, `E2E_NODE` specifies the name of a single testnet node to test.
  43. These environment variables can also be specified in `tests/e2e_test.go` to run tests from an editor or IDE:
  44. ```go
  45. func init() {
  46. // This can be used to manually specify a testnet manifest and/or node to
  47. // run tests against. The testnet must have been started by the runner first.
  48. os.Setenv("E2E_MANIFEST", "networks/ci.toml")
  49. os.Setenv("E2E_NODE", "validator01")
  50. }
  51. ```
  52. ### Debugging Failures
  53. If a command or test fails, the runner simply exits with an error message and
  54. non-zero status code. The testnet is left running with data in the testnet
  55. directory, and can be inspected with e.g. `docker ps`, `docker logs`, or
  56. `./build/runner -f <manifest> logs` or `tail`. To shut down and remove the
  57. testnet, run `./build/runner -f <manifest> cleanup`.
  58. If the standard `log_level` is not detailed enough (e.g. you want "debug" level
  59. logging for certain modules), you can change it in the manifest file.
  60. Each node exposes a [pprof](https://golang.org/pkg/runtime/pprof/) server. To
  61. find out the local port, run `docker port <NODENAME> 6060 | awk -F: '{print
  62. $2}'`. Then you may perform any queries supported by the pprof tool. Julia
  63. Evans has a [great
  64. post](https://jvns.ca/blog/2017/09/24/profiling-go-with-pprof/) on this
  65. subject.
  66. ```bash
  67. export PORT=$(docker port full01 6060 | awk -F: '{print $2}')
  68. go tool pprof http://localhost:$PORT/debug/pprof/goroutine
  69. go tool pprof http://localhost:$PORT/debug/pprof/heap
  70. go tool pprof http://localhost:$PORT/debug/pprof/threadcreate
  71. go tool pprof http://localhost:$PORT/debug/pprof/block
  72. go tool pprof http://localhost:$PORT/debug/pprof/mutex
  73. ```
  74. ## Enabling IPv6
  75. Docker does not enable IPv6 by default. To do so, enter the following in
  76. `daemon.json` (or in the Docker for Mac UI under Preferences → Docker Engine):
  77. ```json
  78. {
  79. "ipv6": true,
  80. "fixed-cidr-v6": "2001:db8:1::/64"
  81. }
  82. ```
  83. ## Benchmarking Testnets
  84. It is also possible to run a simple benchmark on a testnet. This is done through the `benchmark` command. This manages the entire process: setting up the environment, starting the test net, waiting for a considerable amount of blocks to be used (currently 100), and then returning the following metrics from the sample of the blockchain:
  85. - Average time to produce a block
  86. - Standard deviation of producing a block
  87. - Minimum and maximum time to produce a block
  88. ## Running Individual Nodes
  89. The E2E test harness is designed to run several nodes of varying configurations within docker. It is also possible to run a single node in the case of running larger, geographically-dispersed testnets. To run a single node you can either run:
  90. **Built-in**
  91. ```bash
  92. make node
  93. tendermint init validator
  94. TMHOME=$HOME/.tendermint ./build/node ./node/built-in.toml
  95. ```
  96. To make things simpler the e2e application can also be run in the tendermint binary
  97. by running
  98. ```bash
  99. tendermint start --proxy-app e2e
  100. ```
  101. However this won't offer the same level of configurability of the application.
  102. **Socket**
  103. ```bash
  104. make node
  105. tendermint init validator
  106. tendermint start
  107. ./build/node ./node.socket.toml
  108. ```
  109. Check `node/config.go` to see how the settings of the test application can be tweaked.