Skip to content

Commit

Permalink
Merge test changes from core integration-tests (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG authored Sep 11, 2023
1 parent e41e93a commit 546e665
Show file tree
Hide file tree
Showing 47 changed files with 1,562 additions and 1,187 deletions.
224 changes: 65 additions & 159 deletions .github/workflows/integration-tests.yml

Large diffs are not rendered by default.

57 changes: 19 additions & 38 deletions integration-tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,55 @@ BIN_DIR = bin
export GOPATH ?= $(shell go env GOPATH)
export GO111MODULE ?= on

LINUX = LINUX
OSX = OSX
WINDOWS = WIN32
OSFLAG :=
LINUX=LINUX
OSX=OSX
WINDOWS=WIN32
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG = $(WINDOWS)
OSFLAG = $(WINDOWS)
else
UNAME_S := $(shell uname -s)

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSFLAG = $(LINUX)
OSFLAG = $(LINUX)
endif

ifeq ($(UNAME_S),Darwin)
OSFLAG = $(OSX)
OSFLAG = $(OSX)
endif
endif


install_qa_tools:
ifeq ($(OSFLAG),$(WINDOWS))
echo "If you are running windows and know how to install what is needed, please contribute by adding it here!"
echo "You will need nodejs, golang, k3d, and helm."
exit 1
endif
else

# linux and mac can use asdf to install all of the dependencies
ifeq ($(shell which asdf), )

# install asdf
ifeq ($(shell which asdf),)
ifeq ($(OSFLAG),$(LINUX))
echo "You will need to install asdf via your linux installer https://asdf-vm.com/guide/getting-started.html"
exit 1
endif
else
ifeq ($(OSFLAG),$(OSX))
brew install asdf
endif
endif

endif
# install the plugins if needed and then install the dependencies
asdf plugin-add nodejs || true
asdf plugin-add golang || true
asdf plugin-add k3d || true
asdf plugin-add helm || true
asdf plugin-add kubectl || true
asdf install

endif
# Now install the helm charts that are needed (should be os agnostic)
helm repo add chainlink-qa https://raw.githubusercontent.com/smartcontractkit/qa-charts/gh-pages/
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update


.PHONY: install_gotestfmt
install_gotestfmt:
go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
Expand All @@ -70,11 +68,7 @@ build_test_image:
#Build a chainlink docker image for local testing and push to k3d registry
.PHONY: build_push_docker_image
build_push_docker_image:
docker build -f ../core/chainlink.Dockerfile \
--build-arg COMMIT_SHA=$(shell git rev-parse HEAD) \
--build-arg CHAINLINK_USER=chainlink \
-t localhost:5000/chainlink:develop ../
docker push localhost:5000/chainlink:develop
docker build -f ../core/chainlink.Dockerfile --build-arg COMMIT_SHA=$(git rev-parse HEAD) --build-arg CHAINLINK_USER=chainlink -t localhost:5000/chainlink:develop ../ ; docker push localhost:5000/chainlink:develop

## Test Runner
.PHONY: run
Expand Down Expand Up @@ -135,16 +129,6 @@ test_chaos_network: install_gotestfmt ## Run all smoke tests
test_chaos_verbose: ## Run all smoke tests with verbose logging
go test -timeout 24h -count=1 -v $(args) ./chaos

.PHONY: test_chaos_ccip_pods_raw
test_chaos_ccip_pods_raw:
DATABASE_URL="postgresql://postgres:node@localhost:5432/chainlink_test?sslmode=disable" \
go test -timeout 2h -v -count=1 $(args) -p 2 -run 'TestChaosCCIP/.*pod-chaos' ./chaos

.PHONY: test_chaos_ccip_network_raw
test_chaos_ccip_network_raw:
DATABASE_URL="postgresql://postgres:node@localhost:5432/chainlink_test?sslmode=disable" \
go test -timeout 2h -v -count=1 $(args) -p 2 -run 'TestChaosCCIP/.*network-chaos' ./chaos

# Performance
.PHONY: test_perf
test_perf: test_need_operator_assets ## Run core node performance tests.
Expand Down Expand Up @@ -208,16 +192,13 @@ test_benchmark_automation: ## Run the automation benchmark tests
test_reorg_automation: ## Run the automation reorg tests
go test -timeout 300m -v -run ^TestAutomationReorg$$ ./reorg -count=1 | tee automation_reorg_run_`date +"%Y%m%d-%H%M%S"`.log


# image: the name for the chainlink image being built, example: image=chainlink
# tag: the tag for the chainlink image being built, example: tag=latest
# example usage: make build_docker_image image=chainlink tag=latest
.PHONY: build_docker_image
build_docker_image:
docker build -f ../core/chainlink.Dockerfile \
--build-arg COMMIT_SHA=$(git rev-parse HEAD) \
--build-arg CHAINLINK_USER=chainlink \
-t $(image):$(tag) ../
docker build -f ../core/chainlink.Dockerfile --build-arg COMMIT_SHA=$(git rev-parse HEAD) --build-arg CHAINLINK_USER=chainlink -t $(image):$(tag) ../


# image: the name for the chainlink image being built, example: image=chainlink
# tag: the tag for the chainlink image being built, example: tag=latest
Expand All @@ -231,4 +212,4 @@ run_test_with_local_image: build_docker_image
SELECTED_NETWORKS="SIMULATED,SIMULATED_1,SIMULATED_2" \
ARGS="$(args)" \
PRODUCT=$(product) \
./scripts/run_product_tests
./scripts/run_product_tests
67 changes: 1 addition & 66 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ increase minikube's resources significantly, or get a more substantial cluster.
This is necessary to deploy ephemeral testing environments, which include external adapters, chainlink nodes and their DBs,
as well as some simulated blockchains, all depending on the types of tests and networks being used.


### Setup Kubernetes Cluster using k3d

[k3d](https://k3d.io/) is a lightweight wrapper to run k3s (a lightweight kubernetes distribution) in docker. It's a great way to run a local kubernetes cluster for testing.
Expand Down Expand Up @@ -91,6 +90,7 @@ You can also specify `EVM_KEYS` and `EVM_URLS` for running on live chains, or us
Other `EVM_*` variables are retrieved when running with the `@general` tag, and is helpful for doing quick sanity checks on new chains or when tweaking variables.

**The tests will not automatically load your .env file. Remember to run `source .env` for changes to take effect.**

## How to Run

Most of the time, you'll want to run tests on a simulated chain, for the purposes of speed and cost.
Expand Down Expand Up @@ -186,71 +186,6 @@ Currently, all performance tests are only run on simulated blockchains.
make test_perf
```
## CCIP Tests
### Configure Environment for CCIP
> CCIP tests follow some additional set up as it needs multi-chain set-up to run the tests.
> To run any kind of CCIP tests you need to provide the some mandatory and optional env variables.
> See the [ccip-example.env](ccip/ccip-example.env) file and use it as a template for your own .env file.
> The tests will not automatically load your .env file. Remember to run source .env for changes to take effect.
### How to Run CCIP Tests
>After following the instructions [Install Dependencies](#setup) , [K8 Setup](#connect-to-a-kubernetes-cluster)
>and [Configure Environment](#configure-environment-for-ccip) , you can run the tests using the following commands.
#### Smoke tests
Mostly you would run tests on simulated networks for cost and speed-
```sh
make test_smoke_ccip_simulated
```
On specific networks (set up according to envionment variables) -
```sh
make test_smoke_ccip
```
#### Load tests
On simulated networks -
```sh
make test_load_ccip_simulated
```
On specific networks (set up according to envionment variables) -
```sh
make test_load_ccip
```
#### Soak tests
Soak tests are just load tests run with long duration and lesser rate of request triggering.
```sh
make test_soak_ccip
```
#### Chaos tests
Chaos tests can only be run in simulated networks to inject specific chaos events in custom environments.
You need to trigger podchaos tests and network chaos tests separately.
```sh
make test_chaos_ccip_pods_raw
```
```sh
make test_chaos_ccip_network_raw
```
#### Soak/Load/Smoke tests on Existing Deployments
> Tests can be run on existing deployments by setting the env var CCIP_TESTS_ON_EXISTING_DEPLOYMENT to true.
> 1. Create a branch out of the code ref using which the contracts were deployed. (This is to ensure that the gethwrappers are compatible with the deployed contracts)
> 2. Update [contracts.json](ccip/contracts/laneconfig/contracts.json) file with the contract addresses of the deployment under test.
> 3. Set the env var CCIP_TESTS_ON_EXISTING_DEPLOYMENT to true in the .env file.
> 4. Set up other env vars denoting the network and other load config parameters in .env file as mentioned in [Configure Environment](#configure-environment-for-ccip) section.
> 5. Run the tests in same branch using the following command -
> ```sh
> source <your .env file>
> make test_soak_ccip # Or the corresponding make <test_type>_test command for load or smoke tests
> ```
## Common Issues
- When upgrading to a new version, it's possible the helm charts have changed. There are a myriad of errors that can result from this, so it's best to just try running `helm repo update` when encountering an error you're unsure of.
Expand Down
25 changes: 25 additions & 0 deletions integration-tests/actions/actions_local.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Package actions enables common chainlink interactions
package actions

import (
"github.com/pkg/errors"

"github.com/smartcontractkit/chainlink/integration-tests/docker/test_env"
)

// UpgradeChainlinkNodeVersions upgrades all Chainlink nodes to a new version, and then runs the test environment
// to apply the upgrades
func UpgradeChainlinkNodeVersionsLocal(
newImage, newVersion string,
nodes ...*test_env.ClNode,
) error {
if newImage == "" && newVersion == "" {
return errors.New("unable to upgrade node version, found empty image and version, must provide either a new image or a new version")
}
for _, node := range nodes {
if err := node.UpgradeVersion(node.NodeConfig, newImage, newVersion); err != nil {
return err
}
}
return nil
}
Loading

0 comments on commit 546e665

Please sign in to comment.