github.com/MetalBlockchain/metalgo@v1.11.9/tests/e2e/README.md (about)

     1  # Avalanche e2e test suites
     2  
     3  - Works with fixture-managed temporary networks.
     4  - Compiles to a single binary with customizable configurations.
     5  
     6  ## Running tests
     7  
     8  ```bash
     9  go install -v github.com/onsi/ginkgo/v2/ginkgo@v2.0.0
    10  ACK_GINKGO_RC=true ginkgo build ./tests/e2e
    11  ./tests/e2e/e2e.test --help
    12  
    13  ./tests/e2e/e2e.test \
    14  --metalgo-path=./build/metalgo
    15  ```
    16  
    17  See [`tests.e2e.sh`](../../scripts/tests.e2e.sh) for an example.
    18  
    19  ### Filtering test execution with labels
    20  
    21  In cases where a change can be verified against only a subset of
    22  tests, it is possible to filter the tests that will be executed by the
    23  declarative labels that have been applied to them. Available labels
    24  are defined as constants in [`describe.go`](./describe.go) with names
    25  of the form `*Label`. The following example runs only those tests that
    26  primarily target the X-Chain:
    27  
    28  
    29  ```bash
    30  ./tests/e2e/e2e.test \
    31    --metalgo-path=./build/avalanchego \
    32    --ginkgo.label-filter=x
    33  ```
    34  
    35  The ginkgo docs provide further detail on [how to compose label
    36  queries](https://onsi.github.io/ginkgo/#spec-labels).
    37  
    38  ## Adding tests
    39  
    40  Define any flags/configurations in [`e2e.go`](./e2e.go).
    41  
    42  Create a new package to implement feature-specific tests, or add tests to an existing package. For example:
    43  
    44  ```
    45  tests
    46  └── e2e
    47      ├── README.md
    48      ├── e2e.go
    49      ├── e2e_test.go
    50      └── x
    51          └── transfer.go
    52              └── virtuous.go
    53  ```
    54  
    55  `e2e.go` defines common configuration for other test
    56  packages. `x/transfer/virtuous.go` defines X-Chain transfer tests,
    57  labeled with `x`, which can be selected by `./tests/e2e/e2e.test
    58  --ginkgo.label-filter "x"`.
    59  
    60  ## Testing against an existing network
    61  
    62  By default, a new temporary test network will be started before each
    63  test run and stopped at the end of the run. When developing e2e tests,
    64  it may be helpful to create a temporary network that can be used
    65  across multiple test runs. This can increase the speed of iteration by
    66  removing the requirement to start a new network for every invocation
    67  of the test under development.
    68  
    69  To create a temporary network for use across test runs:
    70  
    71  ```bash
    72  # From the root of the avalanchego repo
    73  
    74  # Build the tmpnetctl binary
    75  $ ./scripts/build_tmpnetctl.sh
    76  
    77  # Start a new network
    78  $ ./build/tmpnetctl start-network --avalanchego-path=/path/to/avalanchego
    79  ...
    80  Started network 1000 @ /home/me/.tmpnet/networks/1000
    81  
    82  Configure tmpnetctl and the test suite to target this network by default
    83  with one of the following statements:
    84   - source /home/me/.tmpnet/networks/1000/network.env
    85   - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/1000
    86   - export TMPNET_NETWORK_DIR=/home/me/.tmpnet/networks/latest
    87  
    88  # Start a new test run using the existing network
    89  ginkgo -v ./tests/e2e -- \
    90      --avalanchego-path=/path/to/avalanchego \
    91      --ginkgo.focus-file=[name of file containing test] \
    92      --use-existing-network \
    93      --network-dir=/path/to/network
    94  
    95  # It is also possible to set the AVALANCHEGO_PATH env var instead of supplying --avalanchego-path
    96  # and to set TMPNET_NETWORK_DIR instead of supplying --network-dir.
    97  ```
    98  
    99  See the tmpnet fixture [README](../fixture/tmpnet/README.md) for more details.
   100  
   101  ## Skipping bootstrap checks
   102  
   103  By default many tests will attempt to bootstrap a new node with the
   104  post-test network state. While this is a valuable activity to perform
   105  in CI, it can add considerable latency to test development. To disable
   106  these bootstrap checks during development, set the
   107  `E2E_SKIP_BOOTSTRAP_CHECKS` env var to a non-empty value:
   108  
   109  ```bash
   110  E2E_SKIP_BOOTSTRAP_CHECKS=1 ginkgo -v ./tests/e2e ...
   111  ```