-
Notifications
You must be signed in to change notification settings - Fork 18
251 lines (221 loc) · 10.4 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
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
defaults:
run:
working-directory: ${{ github.workspace }}
permissions:
contents: read
packages: write
steps:
- name: Get binaries
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Login to Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- 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: ${{ github.workspace }}/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}" == "master" ]]; 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 JDK 21
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # 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: Start up KinD cluster with local images
working-directory: ${{ github.workspace }}/helm-charts
run: |
kind create cluster
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: ${{ github.workspace }}/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: ${{ github.workspace }}/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 -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@6f51ac03b9356f520e9adb1b1b7802705f340c2b # 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 -n test
helm uninstall operator-test --wait
kubectl get pods -A
smoke-test-legacy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ github.workspace }}
permissions:
contents: read
packages: write
steps:
- name: Get binaries
run: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
curl -Lo kind https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-linux-amd64 && chmod +x kind && sudo mv kind /usr/local/bin/
- name: Set up Docker QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
- name: Login to Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Checkout HiveMQ Helm Charts
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: helm-charts
- name: Checkout HiveMQ Operator (legacy) 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 Operator (legacy) on the same or target branch
working-directory: ${{ github.workspace }}/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 JDK 21
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b # v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4
with:
gradle-home-cache-includes: |
caches
notifications
jdks
- name: Build HiveMQ Operator (legacy) images
working-directory: helm-charts
run: ./gradlew :tests-hivemq-operator:build :tests-hivemq-operator:saveDockerImages
- name: Start up KinD cluster with local images
working-directory: ${{ github.workspace }}/helm-charts
run: |
kind create cluster
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 Operator (legacy)
working-directory: ${{ github.workspace }}/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 -n test
- name: Capture HiveMQ Operator (legacy) 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 Operator (legacy) Pods logs on failure
if: failure()
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4
with:
name: Pod logs
path: ${{ runner.temp }}/logs/*.log
retention-days: 5
- name: Uninstall HiveMQ Operator (legacy) charts
if: always()
run: |
helm uninstall $RELEASE_NAME --wait -n test
kubectl get pods -A