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.

121 lines
3.9 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. * `logs`: outputs all node logs.
  32. * `tail`: tails (follows) node logs until cancelled.
  33. ## Tests
  34. 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.
  35. ### Running Manual Tests
  36. 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.:
  37. ```sh
  38. ./build/runner -f networks/ci.toml start
  39. E2E_MANIFEST=networks/ci.toml go test -v ./tests/...
  40. ```
  41. Optionally, `E2E_NODE` specifies the name of a single testnet node to test.
  42. These environment variables can also be specified in `tests/e2e_test.go` to run tests from an editor or IDE:
  43. ```go
  44. func init() {
  45. // This can be used to manually specify a testnet manifest and/or node to
  46. // run tests against. The testnet must have been started by the runner first.
  47. os.Setenv("E2E_MANIFEST", "networks/ci.toml")
  48. os.Setenv("E2E_NODE", "validator01")
  49. }
  50. ```
  51. ### Debugging Failures
  52. If a command or test fails, the runner simply exits with an error message and
  53. non-zero status code. The testnet is left running with data in the testnet
  54. directory, and can be inspected with e.g. `docker ps`, `docker logs`, or
  55. `./build/runner -f <manifest> logs` or `tail`. To shut down and remove the
  56. testnet, run `./build/runner -f <manifest> cleanup`.
  57. If the standard `log_level` is not detailed enough (e.g. you want "debug" level
  58. logging for certain modules), you can change it in the manifest file.
  59. Each node exposes a [pprof](https://golang.org/pkg/runtime/pprof/) server. To
  60. find out the local port, run `docker port <NODENAME> 6060 | awk -F: '{print
  61. $2}'`. Then you may perform any queries supported by the pprof tool. Julia
  62. Evans has a [great
  63. post](https://jvns.ca/blog/2017/09/24/profiling-go-with-pprof/) on this
  64. subject.
  65. ```bash
  66. export PORT=$(docker port full01 6060 | awk -F: '{print $2}')
  67. go tool pprof http://localhost:$PORT/debug/pprof/goroutine
  68. go tool pprof http://localhost:$PORT/debug/pprof/heap
  69. go tool pprof http://localhost:$PORT/debug/pprof/threadcreate
  70. go tool pprof http://localhost:$PORT/debug/pprof/block
  71. go tool pprof http://localhost:$PORT/debug/pprof/mutex
  72. ```
  73. ## Enabling IPv6
  74. Docker does not enable IPv6 by default. To do so, enter the following in
  75. `daemon.json` (or in the Docker for Mac UI under Preferences → Docker Engine):
  76. ```json
  77. {
  78. "ipv6": true,
  79. "fixed-cidr-v6": "2001:db8:1::/64"
  80. }
  81. ```