forked from rancher/distros-test-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
193 lines (157 loc) · 7.86 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
include ./config/.env
TAG_NAME := $(if $(TAG_NAME),$(TAG_NAME),distros)
test-env-up:
@docker build . -q -f ./scripts/Dockerfile.build -t acceptance-test-${TAG_NAME}
test-run:
@docker run -dt --name acceptance-test-${IMG_NAME} \
-e AWS_ACCESS_KEY_ID=$${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=$${AWS_SECRET_ACCESS_KEY} \
--env-file ./config/.env \
-v ${ACCESS_KEY_LOCAL}:/go/src/github.com/rancher/distros-test-framework/config/.ssh/aws_key.pem \
-v ./scripts/test-runner.sh:/go/src/github.com/rancher/distros-test-framework/scripts/test-runner.sh \
acceptance-test-${TAG_NAME} && \
make image-stats IMG_NAME=${IMG_NAME} && \
make test-logs USE=IMG_NAME acceptance-test-${IMG_NAME}
## Use this to run on the same environement + cluster from the previous last container -${TAGNAME} created
test-run-state:
DOCKER_COMMIT=$$? \
CONTAINER_ID=$(shell docker ps -a -q --filter ancestor=acceptance-test-${TAG_NAME} | head -n 1); \
if [ -z "$${CONTAINER_ID}" ]; then \
echo "No matching container found."; \
exit 1; \
else \
docker commit $$CONTAINER_ID teststate:latest; \
if [ $$DOCKER_COMMIT -eq 0 ]; then \
docker run -dt --name acceptance-test-${TEST_STATE} --env-file ./config/.env \
-e AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
-e AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
-v ${ACCESS_KEY_LOCAL}:/go/src/github.com/rancher/distros-test-framework/config/.ssh/aws_key.pem \
-v ./scripts/test-runner.sh:/go/src/github.com/rancher/distros-test-framework/scripts/test-runner.sh \
teststate:latest && \
make test-logs USE=TEST_STATE acceptance-test-${TEST_STATE} \
echo "Docker run exit code: $$?"; \
else \
echo "Failed to commit container"; \
exit 1; \
fi; \
fi
## use this to test a new run on a totally new fresh environment after delete also aws resources
test-complete: test-env-clean test-env-down remove-tf-state test-env-up test-run
test-logs:
@if [ "${USE}" = "IMG_NAME" ]; then \
docker logs -f acceptance-test-${IMG_NAME}; \
elif [ "${USE}" = "TEST_STATE" ]; then \
docker logs -f acceptance-test-${TEST_STATE}; \
fi;
image-stats:
@./scripts/docker_stats.sh $$IMG_NAME 2>> /tmp/image-${IMG_NAME}_stats_output.log &
.PHONY: test-env-down
test-env-down:
@echo "Removing containers"
@docker ps -a -q --filter="name=acceptance-test*" | xargs -r docker rm -f 2>/tmp/container_${IMG_NAME}.log || true
@echo "Removing acceptance-test images"
@docker images -q --filter="reference=acceptance-test*" | xargs -r docker rmi -f 2>/tmp/container_${IMG_NAME}.log || true
@echo "Removing dangling images"
@docker images -q -f "dangling=true" | xargs -r docker rmi -f 2>/tmp/container_${IMG_NAME}.log || true
@echo "Removing state images"
@docker images -q --filter="reference=teststate:latest" | xargs -r docker rmi -f 2>/tmp/container_${IMG_NAME}.log || true
.PHONY: test-env-clean
test-env-clean:
@./scripts/delete_resources.sh
#========================= Run acceptance tests locally =========================#
.PHONY: remove-tf-state
remove-tf-state:
@rm -rf ./modules/${ENV_PRODUCT}/.terraform
@rm -rf ./modules/${ENV_PRODUCT}/.terraform.lock.hcl ./modules/${ENV_PRODUCT}/terraform.tfstate ./modules/${ENV_PRODUCT}/terraform.tfstate.backup
.PHONY: test-create
test-create:
@go test -timeout=45m -v -count=1 ./entrypoint/createcluster/...
.PHONY: test-upgrade-suc
test-upgrade-suc:
@go test -timeout=45m -v -tags=upgradesuc -count=1 ./entrypoint/upgradecluster/... -sucUpgradeVersion ${SUC_UPGRADE_VERSION}
.PHONY: test-upgrade-manual
test-upgrade-manual:
@go test -timeout=45m -v -tags=upgrademanual -count=1 ./entrypoint/upgradecluster/... -installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT} -channel ${CHANNEL}
.PHONY: test-create-mixedos
test-create-mixedos:
@go test -timeout=45m -v -count=1 ./entrypoint/mixedoscluster/... $(if ${SONOBUOY_VERSION},-sonobuoyVersion ${SONOBUOY_VERSION})
.PHONY: test-create-dualstack
test-create-dualstack:
@go test -timeout=45m -v -count=1 ./entrypoint/dualstack/...
.PHONY: test-version-bump
test-version-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=versionbump \
-cmd "${CMD}" \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DESCRIPTION},-description "${DESCRIPTION}") \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD}) \
.PHONY: test-etcd-bump
test-etcd-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=etcd \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD})
.PHONY: test-runc-bump
test-runc-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=runc \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD})
.PHONY: test-cilium-bump
test-cilium-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=cilium \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD})
.PHONY: test-canal-bump
test-canal-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=canal \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD})
.PHONY: test-coredns-bump
test-coredns-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=coredns \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD})
.PHONY: test-cniplugin-bump
test-cniplugin-bump:
@go test -timeout=45m -v -count=1 ./entrypoint/versionbump/... -tags=cniplugin \
-expectedValue ${EXPECTED_VALUE} \
$(if ${VALUE_UPGRADED},-expectedValueUpgrade ${VALUE_UPGRADED}) \
$(if ${INSTALL_VERSION_OR_COMMIT},-installVersionOrCommit ${INSTALL_VERSION_OR_COMMIT}) \
$(if ${CHANNEL},-channel ${CHANNEL}) \
$(if ${TEST_CASE},-testCase "${TEST_CASE}") \
$(if ${WORKLOAD_NAME},-workloadName ${WORKLOAD_NAME}) \
$(if ${DEPLOY_WORKLOAD},-deployWorkload ${DEPLOY_WORKLOAD})
#========================= TestCode Static Quality Check =========================#
.PHONY: vet-lint
vet-lint:
@echo "Running go vet and lint"
@go vet ./${TEST_DIR} && golangci-lint run --tests