-
Notifications
You must be signed in to change notification settings - Fork 18
292 lines (254 loc) · 11.2 KB
/
smoke-test.yml
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: Smoke Test
on:
pull_request:
branches:
- "**"
workflow_dispatch:
concurrency:
group: smoke-test-${{ github.ref }}
cancel-in-progress: true
env:
RELEASE_NAME: "smoke-test-release"
jobs:
smoke-test-platform:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Platform Operator on the default branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: hivemq/hivemq-platform-operator
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
path: hivemq-platform-operator
- name: Checkout HiveMQ Platform Operator on the same or target branch
working-directory: hivemq-platform-operator
run: |
echo "Checking if branch \"${GITHUB_HEAD_REF}\" exists on hivemq-platform-operator"
BRANCH=$(git ls-remote origin ${GITHUB_HEAD_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out branch with the same name"
git fetch --all
git checkout origin/${GITHUB_HEAD_REF}
exit
fi
if [[ "${GITHUB_BASE_REF}" == "develop" ]]; then
exit
fi
echo "Checking if branch \"${GITHUB_BASE_REF}\" exists on hivemq-platform-operator"
BRANCH=$(git ls-remote origin ${GITHUB_BASE_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out target branch"
git fetch --all
git checkout origin/${GITHUB_BASE_REF}
fi
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3
- name: Login to Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up JDK 21
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
with:
distribution: temurin
java-version: 21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4
with:
gradle-home-cache-includes: |
caches
notifications
jdks
- name: Build HiveMQ Platform Operator and HiveMQ Platform Operator Init images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-platform-operator:build :tests-hivemq-platform-operator:saveDockerImages
- name: Create K8s Kind Cluster
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3
with:
cluster_name: "kind"
- name: Load local images into KinD cluster
working-directory: helm-charts
run: |
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform-operator-init.tar
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform-operator.tar
kind load image-archive ./tests-hivemq-platform-operator/build/hivemq-platform.tar
- name: Install HiveMQ Platform Operator
working-directory: helm-charts
run: helm install operator-test --set image.name=hivemq-platform-operator-test --set image.initImageName=hivemq-platform-operator-init-test --set image.tag=snapshot ./charts/hivemq-platform-operator --wait
- name: Install HiveMQ Platform
working-directory: helm-charts
run: helm install $RELEASE_NAME --set nodes.replicaCount=1,nodes.resources.cpu=512m ./charts/hivemq-platform --wait --create-namespace -n test
- name: Test HiveMQ Platform
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME --logs -n test
- name: Capture HiveMQ Platform Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/operator-pod.log
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n test > ${{ runner.temp }}/logs/platform-pod.log
- name: Upload HiveMQ Platform Pods logs on failure
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Platform charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait --ignore-not-found -n test
helm uninstall operator-test --wait --ignore-not-found
kubectl get pods -A
smoke-test-legacy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Legacy Operator on the default branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
repository: hivemq/hivemq-operator
token: ${{ secrets.JENKINS_GITHUB_TOKEN }}
path: hivemq-operator
- name: Checkout HiveMQ Legacy Operator on the same or target branch
working-directory: hivemq-operator
run: |
echo "Checking if branch \"${GITHUB_HEAD_REF}\" exists on hivemq-operator"
BRANCH=$(git ls-remote origin ${GITHUB_HEAD_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out branch with the same name"
git fetch --all
git checkout origin/${GITHUB_HEAD_REF}
exit
fi
if [[ "${GITHUB_BASE_REF}" == "master" ]]; then
exit
fi
echo "Checking if branch \"${GITHUB_BASE_REF}\" exists on hivemq-operator"
BRANCH=$(git ls-remote origin ${GITHUB_BASE_REF})
if [[ -n "${BRANCH}" ]]; then
echo "Checking out target branch"
git fetch --all
git checkout origin/${GITHUB_BASE_REF}
fi
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3
- name: Login to Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up JDK 21
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4
with:
distribution: temurin
java-version: 21
- name: Set up Gradle
uses: gradle/actions/setup-gradle@94baf225fe0a508e581a564467443d0e2379123b # v4
with:
gradle-home-cache-includes: |
caches
notifications
jdks
- name: Build HiveMQ Legacy Operator images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-operator:build :tests-hivemq-operator:saveDockerImages
- name: Create K8s Kind Cluster
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3
with:
cluster_name: "kind"
- name: Load local images into KinD cluster
working-directory: helm-charts
run: |
kind load image-archive ./tests-hivemq-operator/build/hivemq-dns-init-wait.tar
kind load image-archive ./tests-hivemq-operator/build/hivemq-k8s.tar
kind load image-archive ./tests-hivemq-operator/build/hivemq-operator.tar
- name: Install HiveMQ Legacy Operator
working-directory: helm-charts
run: |
helm repo add prometheus https://prometheus-community.github.io/helm-charts
helm dependency build ./charts/hivemq-operator
helm install $RELEASE_NAME ./charts/hivemq-operator -f ./examples/hivemq-operator/localStatefulTest.yml --wait --create-namespace -n test
- name: Test HiveMQ Cluster
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l hivemq-cluster=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME --logs -n test
- name: Capture HiveMQ Legacy Operator Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/operator-pod.log
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n test > ${{ runner.temp }}/logs/platform-pod.log
- name: Upload HiveMQ Legacy Operator Pods logs on failure
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Legacy Operator charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait --ignore-not-found -n test
kubectl get pods -A
smoke-test-edge:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: helm-charts
- name: Create K8s Kind Cluster
uses: helm/kind-action@a1b0e391336a6ee6713a0583f8c6240d70863de3
with:
cluster_name: "kind"
- name: Install HiveMQ Edge
working-directory: helm-charts
run: helm install $RELEASE_NAME ./charts/hivemq-edge --wait --create-namespace -n test
- name: Test HiveMQ Edge
run: |
kubectl get events -n test -w &
# Otherwise the pods are not created and the next step fails
echo Waiting for statefulSet to be created && sleep 15 && echo Done Waiting
kubectl wait --for=condition=ready pod -l app.kubernetes.io/instance=$RELEASE_NAME --timeout=5m -n test
helm test $RELEASE_NAME --logs -n test
- name: Capture HiveMQ Edge Pods logs on failure
if: failure()
run: |
mkdir ${{ runner.temp }}/logs
kubectl logs -l app.kubernetes.io/instance=$RELEASE_NAME --tail -1 -n default > ${{ runner.temp }}/logs/edge-pod.log
- name: Upload HiveMQ Edge Pods logs on failure
if: failure()
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Edge chart
if: always()
run: |
helm uninstall $RELEASE_NAME --wait --ignore-not-found -n test
kubectl get pods -A