-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile.validation
224 lines (183 loc) · 12.3 KB
/
Makefile.validation
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
include variables.mk
### Lint
lint:
${GO_ENV_VARS} golangci-lint -v run ./...
### Unit tests
coverage:
go tool cover -html=coverage.out -o coverage.html
test:
${GO_ENV_VARS} go test --coverpkg=./pkg/...,./cmd/... ${LDFLAGS} `go list ./... | grep "pkg\|cmd"` -race -cover -coverprofile=coverage.out -covermode=atomic
# Run tests for pr-validation with writing output to log file
# Test are different (ginkgo, go testing, etc.) so can't use native ginkgo methods to print junit output.
test-pr-validation:
${GO_ENV_VARS} go test ${LDFLAGS} `go list ./... | grep -v halmgr` -v -race -cover -coverprofile=coverage.out > log.txt
install-junit-report:
${GO_ENV_VARS} go get -u github.com/jstemmer/go-junit-report
${GO_ENV_VARS} go install github.com/jstemmer/go-junit-report
# Convert go test output from log.txt to junit-style output. Split these steps because no matter if test fails,
# junit output must be collected
pr-validation-junit:
cat log.txt >&1 | go-junit-report > report.xml
### E2E
# Run e2e tests for CI. All of these tests use ginkgo so we can use native ginkgo methods to print junit output.
# Also go test doesn't provide functionnality to save test's log into the file. Use > to archieve artifatcs.
test-ci: hack-for-kind
cd tests && ${GO_ENV_VARS} CI=true CSI_VERSION=${CSI_VERSION} OPERATOR_VERSION=${OPERATOR_VERSION} go test ${LDFLAGS} -v e2e/baremetal_e2e_test.go -ginkgo.v -ginkgo.progress -ginkgo.skip="Serial" -ginkgo.junit-report=reports/report.xml -all-tests -kubeconfig=${HOME}/.kube/config -chartsDir ${CHARTS_DIR} -timeout 0 > log.txt
# Run e2e tests and run community tests only.
test-short-ci: hack-for-kind
cd tests && ${GO_ENV_VARS} CI=true CSI_VERSION=${CSI_VERSION} OPERATOR_VERSION=${OPERATOR_VERSION} go test ${LDFLAGS} -v e2e/baremetal_e2e_test.go -ginkgo.v -ginkgo.progress -ginkgo.failFast -ginkgo.skip="Serial|volume-expand" -ginkgo.junit-report=reports/report.xml -timeout-short-ci=${SHORT_CI_TIMEOUT} -kubeconfig=${HOME}/.kube/config -chartsDir ${CHARTS_DIR} -timeout 0 > log.txt
test-short-ci-k8s-122: hack-for-kind
cd tests && ${GO_ENV_VARS} CI=true CSI_VERSION=${CSI_VERSION} OPERATOR_VERSION=${OPERATOR_VERSION} go test ${LDFLAGS} -v e2e/baremetal_e2e_test.go -ginkgo.v -ginkgo.progress -ginkgo.failFast -ginkgo.skip="Serial|multiple" -ginkgo.junit-report=reports/report.xml -timeout-short-ci=${SHORT_CI_TIMEOUT} -kubeconfig=${HOME}/.kube/config -chartsDir ${CHARTS_DIR} -timeout 0 > log.txt
test-sanity-ci: hack-for-kind
cd tests && ${GO_ENV_VARS} CI=true CSI_VERSION=${CSI_VERSION} OPERATOR_VERSION=${OPERATOR_VERSION} go test ${LDFLAGS} -v e2e/baremetal_e2e_test.go -timeout 0 -ginkgo.focus="$(strip $(subst ',, ${SANITY_TEST}))" -ginkgo.v -ginkgo.progress -ginkgo.junit-report=reports/report.xml -all-tests -kubeconfig=${HOME}/.kube/config -chartsDir ${CHARTS_DIR} > log.txt
test-sanity-ci-k8s-122: hack-for-kind
cd tests && ${GO_ENV_VARS} CI=true CSI_VERSION=${CSI_VERSION} OPERATOR_VERSION=${OPERATOR_VERSION} go test ${LDFLAGS} -v e2e/baremetal_e2e_test.go -timeout 0 -ginkgo.focus="$(strip $(subst ',, ${SANITY_TEST}))" -ginkgo.v -ginkgo.progress -ginkgo.junit-report=reports/report.xml -ginkgo.skip="block" -all-tests -kubeconfig=${HOME}/.kube/config -chartsDir ${CHARTS_DIR} > log.txt
# Run commnity sanity tests for CSI.
# TODO enable tests back - https://github.com/dell/csi-baremetal/issues/371
test-sanity:
# ${GO_ENV_VARS} SANITY=true go test test/sanity/sanity_test.go -ginkgo.skip \
# "ExpandVolume|\
# ValidateVolumeCapabilities|\
# should fail when the node does not exist|\
# should fail when requesting to create a volume with already existing name and different capacity|\
# should not fail when requesting to create a volume with already existing name and same capacity" -ginkgo.v -timeout=0
### Workflows
prepare-env:
go install github.com/rhysd/actionlint/cmd/actionlint@latest
go install github.com/nektos/act@latest
workflows-lint:
actionlint
test-release-workflow:
act release -e .github/workflows/tests/release.json --secret-file .github/workflows/tests/wf.secrets
act release -e .github/workflows/tests/pre-release.json --secret-file .github/workflows/tests/wf.secrets
load-operator-image: pull-operator-image \
kind-tag-operator-image \
kind-load-operator-image
pull-operator-image:
docker pull ${REGISTRY}/${PROJECT}-${OPERATOR}:${OPERATOR_VERSION}
kind-tag-operator-image:
docker tag ${REGISTRY}/${PROJECT}-${OPERATOR}:${OPERATOR_VERSION} ${PROJECT}-${OPERATOR}:${OPERATOR_VERSION}
kind-load-operator-image:
$(KIND) load docker-image ${PROJECT}-${OPERATOR}:${OPERATOR_VERSION}
kind-pull-images: kind-pull-sidecar-images
docker pull ${REGISTRY}/${PROJECT}-${LOOPBACK_DRIVE_MGR}:${TAG}
docker pull ${REGISTRY}/${PROJECT}-${NODE}:${TAG}
docker pull ${REGISTRY}/${PROJECT}-${NODE}-kernel-5.4:${TAG}
docker pull ${REGISTRY}/${PROJECT}-${CONTROLLER}:${TAG}
docker pull ${REGISTRY}/${PROJECT}-${SCHEDULER}-${EXTENDER}:${TAG}
docker pull ${REGISTRY}/${PROJECT}-${EXTENDER_PATCHER}:${TAG}
# docker pull ${REGISTRY}/${PROJECT}-${SCHEDULER}:${TAG}
docker pull ${REGISTRY}/${PROJECT}-${NODE_CONTROLLER}:${TAG}
kind-pull-sidecar-images:
docker pull ${REGISTRY}/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
docker pull ${REGISTRY}/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
docker pull ${REGISTRY}/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
docker pull ${REGISTRY}/${CSI_RESIZER}:${CSI_RESIZER_TAG}
docker pull ${REGISTRY}/${BUSYBOX}:${BUSYBOX_TAG}
docker pull ${REGISTRY}/library/nginx:1.14-alpine
docker pull ${REGISTRY}/library/centos:latest
docker pull ${REGISTRY}/e2e-test-images/nginx:1.14-1
docker pull ${REGISTRY}/e2e-test-images/busybox:1.29-2
kind-tag-images:
docker tag ${REGISTRY}/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG} ${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
docker tag ${REGISTRY}/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG} ${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
docker tag ${REGISTRY}/${CSI_RESIZER}:${CSI_RESIZER_TAG} ${CSI_RESIZER}:${CSI_RESIZER_TAG}
docker tag ${REGISTRY}/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG} ${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
docker tag ${REGISTRY}/${BUSYBOX}:${BUSYBOX_TAG} ${BUSYBOX}:${BUSYBOX_TAG}
docker tag ${REGISTRY}/library/nginx:1.14-alpine docker.io/library/nginx:1.14-alpine
docker tag ${REGISTRY}/library/centos:latest docker.io/library/centos:latest
docker tag ${REGISTRY}/e2e-test-images/nginx:1.14-1 k8s.gcr.io/e2e-test-images/nginx:1.14-1
docker tag ${REGISTRY}/e2e-test-images/busybox:1.29-2 registry.k8s.io/e2e-test-images/busybox:1.29-2
docker tag ${REGISTRY}/${PROJECT}-${LOOPBACK_DRIVE_MGR}:${TAG} ${PROJECT}-${LOOPBACK_DRIVE_MGR}:${TAG}
docker tag ${REGISTRY}/${PROJECT}-${NODE}:${TAG} ${PROJECT}-${NODE}:${TAG}
docker tag ${REGISTRY}/${PROJECT}-${NODE}-kernel-5.4:${TAG} ${PROJECT}-${NODE}-kernel-5.4:${TAG}
docker tag ${REGISTRY}/${PROJECT}-${CONTROLLER}:${TAG} ${PROJECT}-${CONTROLLER}:${TAG}
docker tag ${REGISTRY}/${PROJECT}-${SCHEDULER}-${EXTENDER}:${TAG} ${PROJECT}-${SCHEDULER}-${EXTENDER}:${TAG}
docker tag ${REGISTRY}/${PROJECT}-${EXTENDER_PATCHER}:${TAG} ${PROJECT}-${EXTENDER_PATCHER}:${TAG}
# docker tag ${REGISTRY}/${PROJECT}-${SCHEDULER}:${TAG} ${PROJECT}-${SCHEDULER}:${TAG}
docker tag ${REGISTRY}/${PROJECT}-${NODE_CONTROLLER}:${TAG} ${PROJECT}-${NODE_CONTROLLER}:${TAG}
kind-load-images:
$(KIND) load docker-image ${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
$(KIND) load docker-image ${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
$(KIND) load docker-image ${CSI_RESIZER}:${CSI_RESIZER_TAG}
$(KIND) load docker-image ${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
$(KIND) load docker-image ${BUSYBOX}:${BUSYBOX_TAG}
$(KIND) load docker-image docker.io/library/nginx:1.14-alpine
$(KIND) load docker-image docker.io/library/centos:latest
$(KIND) load docker-image k8s.gcr.io/e2e-test-images/nginx:1.14-1
$(KIND) load docker-image registry.k8s.io/e2e-test-images/busybox:1.29-2
$(KIND) load docker-image ${PROJECT}-${LOOPBACK_DRIVE_MGR}:${TAG}
$(KIND) load docker-image ${PROJECT}-${NODE}:${TAG}
$(KIND) load docker-image ${PROJECT}-${NODE}-kernel-5.4:${TAG}
$(KIND) load docker-image ${PROJECT}-${CONTROLLER}:${TAG}
$(KIND) load docker-image ${PROJECT}-${SCHEDULER}-${EXTENDER}:${TAG}
$(KIND) load docker-image ${PROJECT}-${EXTENDER_PATCHER}:${TAG}
# $(KIND) load docker-image ${PROJECT}-${SCHEDULER}:${TAG}
$(KIND) load docker-image ${PROJECT}-${NODE_CONTROLLER}:${TAG}
kind-build:
chmod +x $(KIND_BUILD_DIR)/kind-build.sh
$(KIND_BUILD_DIR)/kind-build.sh $(KIND_BUILD_DIR)
kind-install: kind-build
# Delete actual
rm -f /usr/bin/kind
# Copy executive file
cp $(KIND) /usr/bin
# Check
kind version
kind-create-cluster:
KIND_EXPERIMENTAL_CONTAINERD_SNAPSHOTTER=native $(KIND) create cluster --config $(KIND_CONFIG_DIR)/$(KIND_CONFIG) --image kindest/node:$(KIND_IMAGE_VERSION) --wait $(KIND_WAIT)
kind-install-calico:
docker pull ${REGISTRY}/calico/cni:$(CALICO_VERSION)
docker pull ${REGISTRY}/calico/node:$(CALICO_VERSION)
docker pull ${REGISTRY}/calico/kube-controllers:$(CALICO_VERSION)
docker tag ${REGISTRY}/calico/cni:$(CALICO_VERSION) docker.io/calico/cni:$(CALICO_VERSION)
docker tag ${REGISTRY}/calico/node:$(CALICO_VERSION) docker.io/calico/node:$(CALICO_VERSION)
docker tag ${REGISTRY}/calico/kube-controllers:$(CALICO_VERSION) docker.io/calico/kube-controllers:$(CALICO_VERSION)
$(KIND) load docker-image docker.io/calico/cni:$(CALICO_VERSION)
$(KIND) load docker-image docker.io/calico/node:$(CALICO_VERSION)
$(KIND) load docker-image docker.io/calico/kube-controllers:$(CALICO_VERSION)
kubectl apply -f https://raw.githubusercontent.com/projectcalico/calico/$(CALICO_VERSION)/manifests/calico.yaml
kind-delete-cluster:
$(KIND) delete cluster
deps-docker-pull:
docker pull registry.k8s.io/sig-storage/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
docker pull registry.k8s.io/sig-storage/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
docker pull registry.k8s.io/sig-storage/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
docker pull registry.k8s.io/sig-storage/${CSI_RESIZER}:${CSI_RESIZER_TAG}
docker pull ${BUSYBOX}:${BUSYBOX_TAG}
docker pull nginx:1.14-alpine
docker pull centos:latest
docker pull k8s.gcr.io/e2e-test-images/nginx:1.14-1
docker pull registry.k8s.io/e2e-test-images/busybox:1.29-2
deps-docker-tag:
docker tag registry.k8s.io/sig-storage/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG} ${REGISTRY}/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
docker tag registry.k8s.io/sig-storage/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG} ${REGISTRY}/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
docker tag registry.k8s.io/sig-storage/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG} ${REGISTRY}/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
docker tag registry.k8s.io/sig-storage/${CSI_RESIZER}:${CSI_RESIZER_TAG} ${REGISTRY}/${CSI_RESIZER}:${CSI_RESIZER_TAG}
docker tag ${BUSYBOX}:${BUSYBOX_TAG} ${REGISTRY}/${BUSYBOX}:${BUSYBOX_TAG}
docker tag nginx:1.14-alpine ${REGISTRY}/library/nginx:1.14-alpine
docker tag centos:latest ${REGISTRY}/library/centos:latest
docker tag k8s.gcr.io/e2e-test-images/nginx:1.14-1 ${REGISTRY}/e2e-test-images/nginx:1.14-1
docker tag registry.k8s.io/e2e-test-images/busybox:1.29-2 ${REGISTRY}/e2e-test-images/busybox:1.29-2
deps-docker-push:
docker push ${REGISTRY}/${CSI_PROVISIONER}:${CSI_PROVISIONER_TAG}
docker push ${REGISTRY}/${CSI_REGISTRAR}:${CSI_REGISTRAR_TAG}
docker push ${REGISTRY}/${LIVENESS_PROBE}:${LIVENESS_PROBE_TAG}
docker push ${REGISTRY}/${CSI_RESIZER}:${CSI_RESIZER_TAG}
docker push ${REGISTRY}/${BUSYBOX}:${BUSYBOX_TAG}
docker push ${REGISTRY}/library/nginx:1.14-alpine
docker push ${REGISTRY}/library/centos:latest
docker push ${REGISTRY}/e2e-test-images/nginx:1.14-1
docker push ${REGISTRY}/e2e-test-images/busybox:1.29-2
# for kind version >= 0.12.0, the created k8s cluter replace master role with control-plane and
# also the same applied to taint. and csi scheduler extender now have an affinity to only deployed
# on master role node. Here we hack it to kind cluster to added back old master label.
# for compatiable with old k8s version, control-plane role may not exist, adding || true here to
# make sure this command will not break the testing and ignore it and continue to test.
hack-for-kind:
# add old compatiable master label, csi-baremetal-se have node affinity of master role
kubectl label node kind-control-plane node-role.kubernetes.io/master=true || true
# un-taint control-plane
kubectl taint node kind-control-plane node-role.kubernetes.io/control-plane- || true
# add master taint
kubectl taint node kind-control-plane node-role.kubernetes.io/master:NoSchedule || true