This directory represent a place for different types of integration and system level tests. It utilizes Chainlink Testing Framework (CTF).
Tip
Testcontainers (Dockerized tests) If you want to have faster, locally running, more stable tests, utilize plain Docker containers (with the help of Testcontainers) instead of using GitHub Actions or Kubernetes.
-
For local testing, Installed Docker. Consider increasing resources limits needed by Docker as most tests require building several containers for a Decentralized Oracle Network (e.g. OCR requires 6 nodes, 6 DBs, and a mock server).
-
For remote testing, access to Kubernetes cluster/AWS Docker registry (if you are pulling images from private links).
-
Docker image. If there is no image to pull from a registry, you may run tests against a custom build. Run the following command to build the image:
make build_docker_image image=<your-image-name> tag=<your-tag>
Example:
make build_docker_image image=chainlink tag=test-tag
-
RPC node/s (for testnets/mainnets).
-
EOA's (wallet) Private Key (see How to export an account's private key)
-
Sufficient amount of native token and LINK on EOA per a target chain.
-
Setup
.env
file in the root ofintegration-tests
directory. See example.env for how to set test-runner log level (not a node's log level), Slack notifications, and Kubernetes-related settings.- Ensure to update you environment with the following commands:
cd integration-tests
source .env
- Ensure to update you environment with the following commands:
-
Setup test secrets. See "how-to" details in the Test Secrets in CTF. If you want to run tests in CI, you will have to push test secrets to GitHub (see Run GitHub Workflow with your test secrets).
-
Provide test and node configuration (for more details refer to testconfig README and
example.toml
files):- Defaults for all products are defined in
./testconfig/<product>/<product>.toml
files. - To override default values, create a
./testconfig/overrides.toml
file (yes, in the root oftestconfig
, not a product directory) specifying the values to override by your test (see some examples in ./testconfig/ocr2/overrides).
[!IMPORTANT] Image version and node configs
- Pay attention to the
[ChainlinkImage].version
to test against the necessary remotely accessible version or custom build. - When running OCR-related tests, pay attention to which version of OCR you enable/override in your
overrides.toml
. - Do not commit any sensitive data.
- Defaults for all products are defined in
-
[Optional] Configure Seth (or use defaults), an evm client used by tests. Detailed instructions on how to configure it can be found in the Seth README and Seth repository.
[!IMPORTANT] Simulated mode (no test secrets needed) Tests may run in a simulated mode, on a simulated chain (1337). In the
overrides.toml
file, set the following:[Network].selected_networks=["simulated"]
[[Seth.networks]].name = "Default"
Note
Resources utilization by Docker It's recommended to run only one test at a time (run tests sequentially) on a local machine as it needs a lot of docker containers and can peg your resources otherwise. You will see docker containers spin up on your machine for each component of the test where you can inspect logs.
-
Run CLI command(with
override.toml
):BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) go test -v -p 1 ./smoke/<product>_test.go
Example:
BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) go test -v -p 1 ./smoke/ocr_test.go
[!WARNING] Parallelized tests and nonce issues Most tests are paralelized by default. To avoid nonce-related issues, it is recommended to run tests with disabled parallelization, e.g. with
-p 1
. -
Alternatively, you may use
make
commands (see more in Makefile .PHONY lines) for running suites of tests. Example:make test_smoke_product product="ocr" ./scripts/run_product_tests
-
Logs of each Chainlink container will dump into the
smoke/logs/
. -
To enable debugging of HTTP and RPC clients set the following env vars:
export SETH_LOG_LEVEL=debug export RESTY_DEBUG=true
Run CLI command (with override.toml
):
BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) go test -v -timeout 15m -run <"TestNameToRun"> ./<directory_name_with_tests>
Example:
BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) go test -v -timeout 15m -run "TestOCRv2Basic" ./smoke
Such tests as Soak, Performance, Benchmark, and Chaos Tests remain bound to a Kubernetes run environment.
- Refer Tests Run Books to get more details on how to run specific per-product tests.
- Logs in CI are uploaded as GitHub artifacts.
-
Ensure all necessary configurations are provided (see Test and node configuration).
-
Log in to your Kubernetes cluster (with
aws sso login
) -
Run tests with the following CLI command:
BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) go test -v -timeout <max_test_timeout> -p 1 -run '<TestName>' ./<test_directory>
OR with
make
commands:BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) make test_<your_test>
Example (see make-commands in Makefile .PHONY lines):
BASE64_CONFIG_OVERRIDE=$(cat ./testconfig/overrides.toml | base64) make test_chaos_ocr/make test_soak_ocr2/test_node_migrations
-
Use Kubernetes namespace printed out in logs to monitor and analyze test runs.
-
Navigate to Grafana dashboards to for test results and logs.
- Ensure all necessary configurations are provided (see Test and node configuration).
- Follow instructions provided in E2E Tests on GitHub CI.
- Refer Tests Run Books to get more details on how to run specific per-product tests.