-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Makefile
248 lines (205 loc) · 9.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
BIN_DIR = bin
export GOPATH ?= $(shell go env GOPATH)
export GO111MODULE ?= on
LINUX=LINUX
OSX=OSX
WINDOWS=WIN32
OSFLAG :=
ifeq ($(OS),Windows_NT)
OSFLAG = $(WINDOWS)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSFLAG = $(LINUX)
endif
ifeq ($(UNAME_S),Darwin)
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
else
# linux and mac can use asdf to install all of the dependencies
ifeq ($(shell which asdf), )
# install 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
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_gotestloghelper
install_gotestloghelper:
go install github.com/smartcontractkit/chainlink-testing-framework/tools/gotestloghelper@latest
set -euo pipefail
lint:
golangci-lint --color=always run ./... --fix -v
build:
@go build ./... go test -run=^# ./...
# Builds the test image
# tag: the tag for the test image being built, example: tag=tate
# base_tag: the tag for the base-test-image to use, example: base_tag=latest
# suite: the test suites to build into the image, example: suite="chaos soak smoke reorg migration"
# push: set to true if you want the image pushed or leave blank if not, example: push=true
.PHONY: build_test_image
build_test_image:
./scripts/buildTestImage $(tag) $(base_tag) "$(suite)" $(push)
#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=$(git rev-parse HEAD) --build-arg CHAINLINK_USER=chainlink -t 127.0.0.1:5000/chainlink:develop ../ ; docker push 127.0.0.1:5000/chainlink:develop
#Build a chainlink docker image in plugin mode for local testing and push to k3d registry
.PHONY: build_push_plugin_docker_image
build_push_plugin_docker_image:
docker build -f ../plugins/chainlink.Dockerfile --build-arg COMMIT_SHA=$(git rev-parse HEAD) --build-arg CHAINLINK_USER=chainlink -t 127.0.0.1:5000/chainlink:develop ../ ; docker push 127.0.0.1:5000/chainlink:develop
# Spins up containers needed to collect traces for local testing
.PHONY: run_tracing
run_tracing:
cd ../.github/tracing
docker compose -f ../.github/tracing/local-smoke-docker-compose.yaml up
## Test Runner
.PHONY: run
run:
go run .
## All commands will use 16 threads to run tests in parallel. To change this, use -test.parallel n
## Remember to set selected_networks and CL image in the TOML file (e.g. overrides.toml)
# Smoke
.PHONY: test_smoke_product
test_smoke_product: ## Run smoke tests for specific product ex: make test_smoke_product product="cron" args="--focus @cron -p"
ARGS="$(args)" PRODUCT=$(product) ./scripts/run_product_tests
# Chaos
.PHONY: test_chaos_pods_raw
test_chaos_pods_raw: ## Run all chaos pod tests
go test -timeout 2h -v -count=1 $(args) -p 2 -run 'Test/.*pod-chaos' ./chaos
.PHONY: test_chaos_network_raw
test_chaos_network_raw: ## Run all chaos network tests
go test -timeout 2h -v -count=1 $(args) -p 2 -run 'Test/.*network-chaos' ./chaos
.PHONY: test_chaos_pods
test_chaos_pods: install_gotestloghelper ## Run all chaos pod tests with decorated output
TEST_LOG_LEVEL="disabled" \
go test -timeout 2h -count=1 -json $(args) -run 'Test/.*pod-chaos' ./chaos 2>&1 | tee ./gotest.log | gotestloghelper -json -hidepassingtests -tlogprefix -color -singlepackage
.PHONY: test_chaos_network
test_chaos_network: install_gotestloghelper ## Run all chaos network tests with decorated output
TEST_LOG_LEVEL="disabled" \
go test -timeout 2h -count=1 -json $(args) -run 'Test/.*network-chaos' ./chaos 2>&1 | tee ./gotest.log | gotestloghelper -json -hidepassingtests -tlogprefix -color -singlepackage
.PHONY: test_chaos_verbose
test_chaos_verbose: ## Run all smoke tests with verbose logging
go test -timeout 24h -count=1 -v $(args) ./chaos
.PHONY: test_chaos_ocr
test_chaos_ocr: ## Run only OCR chaos tests
go test -timeout 2h -v -count=1 $(args) -p 2 -run 'TestOCRChaos' ./chaos
.PHONY: test_chaos_automation
test_chaos_automation: ## Run only Automation chaos tests
go test -timeout 2h -v -count=1 $(args) -p 2 -run 'TestAutomationChaos' ./chaos
# Migrations
.PHONY: test_node_migrations
test_node_migrations: install_gotestloghelper ## Run all node migration tests.
TEST_LOG_LEVEL="disabled" \
go test -timeout 1h -count=1 -json $(args) ./migration 2>&1 | tee /tmp/gotest.log | gotestloghelper -json -tlogprefix -color -singlepackage -hidepassinglogs
.PHONY: test_node_migrations_simulated
test_node_migrations_simulated: install_gotestloghelper
TEST_LOG_LEVEL="disabled" \
go test -timeout 1h -count=1 -json $(args) ./migration 2>&1 | tee /tmp/gotest.log | gotestloghelper -json -tlogprefix -color -singlepackage -hidepassinglogs
.PHONY: test_node_migrations_verbose
test_node_migrations_verbose:
go test -timeout 1h -count=1 -v $(args) ./migration
.PHONY: test_node_migrations_simulated_verbose
test_node_migrations_simulated_verbose:
go test -timeout 1h -count=1 -v $(args) ./migration
# Soak
.PHONY: test_soak_ocr1
test_soak_ocr1:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestOCRv1Soak ./soak
.PHONY: test_soak_ocr2
test_soak_ocr2:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestOCRv2Soak ./soak
.PHONY: test_soak_forwarder_ocr1
test_soak_forwarder_ocr1:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestForwarderOCRv1Soak ./soak
.PHONY: test_soak_forwarder_ocr2
test_soak_forwarder_ocr2:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run TestForwarderOCRv2Soak ./soak
.PHONY: test_soak_ocr_reorg_1
test_soak_ocr_reorg_1:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_GethReorgBelowFinality_FinalityTagDisabled$$ ./soak
.PHONY: test_soak_ocr_reorg_2
test_soak_ocr_reorg_2:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_GethReorgBelowFinality_FinalityTagEnabled$$ ./soak
.PHONY: test_soak_ocr_gas_spike
test_soak_ocr_gas_spike:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_GasSpike$$ ./soak
.PHONY: test_soak_ocr_gas_limit_change
test_soak_ocr_gas_limit_change:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_ChangeBlockGasLimit$$ ./soak
.PHONY: test_soak_ocr_rpc_down_all_cl_nodes
test_soak_ocr_rpc_down_all_cl_nodes:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_RPCDownForAllCLNodes$$ ./soak
.PHONY: test_soak_ocr_rpc_down_half_cl_nodes
test_soak_ocr_rpc_down_half_cl_nodes:
. ./scripts/check_base64_env_var.sh
go test -v -count=1 -run ^TestOCRSoak_RPCDownForHalfCLNodes$$ ./soak
.PHONY: test_soak_automation
test_soak_automation:
. ./scripts/check_base64_env_var.sh
go test -v -run ^TestAutomationBenchmark$$ ./benchmark -count=1
.PHONY: test_benchmark_automation
test_benchmark_automation: ## Run the automation benchmark tests
. ./scripts/check_base64_env_var.sh
go test -timeout 30m -v -run ^TestAutomationBenchmark$$ ./benchmark -count=1
.PHONY: test_reorg_automation
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) ../
# 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_plugin_docker_image
build_plugin_docker_image:
docker build -f ../plugins/chainlink.Dockerfile --build-arg COMMIT_SHA=$(git rev-parse HEAD) --build-arg CHAINLINK_USER=chainlink -t 127.0.0.1:5000/chainlink:develop ../
# image: the name for the chainlink image being built, example: image=chainlink
# tag: the tag for the chainlink image being built, example: tag=latest
# args: the args to pass to the test runner, example: args="--focus @cron -p"
# product: the product to run tests for, example: product=cron
# example usage: make run_test_with_local_image image=chainlink tag=latest-dev product=cron
# remember to put the case CL image name and tag in the TOML config (and don't forget about selected network configuration)
.PHONY: run_test_with_local_image
run_test_with_local_image: build_docker_image
ARGS="$(args)" \
PRODUCT=$(product) \
./scripts/run_product_tests
# removes all occurrences of .run.id file in current folder and it's subdirectories
# before making any changes lists all file locations and awaits user confirmation
remove_test_execution_artefacts:
./scripts/search_and_delete.sh .run.id