-
Notifications
You must be signed in to change notification settings - Fork 18
312 lines (267 loc) · 11 KB
/
KubernetesExternalClients.yaml
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: Kubernetes external clients compatibility tests with GKE
on:
workflow_dispatch:
inputs:
hazelcast_version:
description: Set hazelcast version
default: 5.0
organization_name:
description: Default is hazelcast, but if you would like to run the workflow with your forked repo, set your github username
required: true
default: hazelcast
python_run:
description: PYTHON = Set the branch name of client to run, otherwise set it as 'no' in order to skip running this client
required: true
default: master
nodejs_run:
description: NODEJS = Set the branch name of client to run, otherwise set it as 'no' in order to skip running this client
required: true
default: master
cpp_run:
description: CPP = Set the branch name of client to run, otherwise set it as 'no' in order to skip running this client
required: true
default: master
go_run:
description: GO = Set the branch name of client to run, otherwise set it as 'no' in order to skip running this client
required: true
default: master
csharp_run:
description: CSHARP = Set the branch name of client to run, otherwise set it as 'no' in order to skip running this client
required: true
default: master
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_ZONE: europe-west1-b
HAZELCAST_VERSION: ${{github.event.inputs.hazelcast_version}}
jobs:
create-gke-cluster:
name: Run Integration tests on GKE
outputs:
external-ip: ${{steps.external-ip.outputs.external-ip}}
cluster_name: ${{steps.cluster_name.outputs.cluster_name}}
GKE_ZONE: ${{steps.gke_zone.outputs.gke_zone}}
runs-on: ubuntu-latest
env:
GCP_NETWORK: operator-test-network
steps:
- name: Checkout
uses: actions/checkout@v2
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GKE_SA_KEY }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Install Kubectl
run: |-
gcloud components install kubectl
- name: Install Helm
uses: azure/setup-helm@v3
id: install
- name: Create GKE cluster
run: |-
repoName='kubernetes-clients-compatibility'
clusterName="$repoName-$GITHUB_RUN_NUMBER"
echo "clusterName=$clusterName" >> $GITHUB_ENV
gcloud container clusters create "$clusterName" \
--zone="$GKE_ZONE" \
--project=${{ secrets.PROJECT_ID }} \
--machine-type=n1-standard-2 \
--num-nodes=2 \
--network=${{env.GCP_NETWORK}}
sleep 30
- name: Deploy Hazelcast cluster
run: |-
helm repo add hazelcast https://hazelcast-charts.s3.amazonaws.com/
helm repo update
helm install operator hazelcast/hazelcast-platform-operator --set installCRDs=true
cat <<EOF | kubectl apply -f -
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
name: hz-hazelcast
spec:
clusterSize: 3
exposeExternally:
type: Smart
discoveryServiceType: LoadBalancer
memberAccess: LoadBalancer
EOF
- name: Wait for deployment to be running
run: |-
while [ "$(kubectl get hazelcast -o jsonpath='{.items[*].status.phase}')" != "Running" ]; do
sleep 2
echo "Current Status of the cluster: $(kubectl get hazelcast -o jsonpath='{.items[*].status.phase}')"
done
- name: Wait for external IP to get assigned
run: |-
EXTERNAL_IP=$(kubectl get svc hz-hazelcast --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
while [ "$EXTERNAL_IP" == "" ]; do
sleep 10
EXTERNAL_IP=$(kubectl get svc hz-hazelcast --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
done
echo "EXTERNAL_IP=${EXTERNAL_IP}" >> $GITHUB_ENV
- name: Set output of external-ip
id: external-ip
run: echo "::set-output name=external-ip::${{ env.EXTERNAL_IP }}"
- name: Set output of gke_zone
id: gke_zone
run: echo "::set-output name=gke_zone::${{env.GKE_ZONE}}"
- name: Set output of cluster_name
id: cluster_name
run: echo "::set-output name=cluster_name::${{env.clusterName}}"
run_go:
name: Run Go compatibility test
needs: [create-gke-cluster]
if: ${{ github.event.inputs.go_run != 'no' }}
runs-on: ubuntu-latest
steps:
- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: '^1.18.3'
- name: Checkout to scripts
uses: actions/checkout@v2
- name: Checkout the go client repo
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.organization_name }}/hazelcast-go-client
path: KubernetesExternalClients/go/clientSourceCode
ref: ${{ github.event.inputs.go_run }}
- name: Run test
run: |
cd KubernetesExternalClients/go
go get github.com/shirou/gopsutil/v3/[email protected]
sed -i "s/<EXTERNAL-IP>/${{needs.create-gke-cluster.outputs.external-ip}}/g" main.go
go run main.go &> output.txt && tail -n 20 output.txt &> last20lines.txt
cat last20lines.txt
if [ $(grep -o 'Current map size:' last20lines.txt | wc -l) != $"20" ]; then exit 1; fi
#TODO: More reliabe verification
run_python:
name: Run Python compatibility test
needs: [create-gke-cluster]
if: ${{ github.event.inputs.python_run != 'no' }}
runs-on: ubuntu-latest
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Checkout to scripts
uses: actions/checkout@v2
- name: Checkout the Python client repo
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.organization_name }}/hazelcast-python-client
path: KubernetesExternalClients/python/clientSourceCode
ref: ${{ github.event.inputs.python_run }}
- name: Run test
run: |
cp KubernetesExternalClients/python/client.py KubernetesExternalClients/python/clientSourceCode/
cd KubernetesExternalClients/python/clientSourceCode
sed -i "s/<EXTERNAL-IP>/${{needs.create-gke-cluster.outputs.external-ip}}/g" client.py
python client.py &> output.txt && tail -n 20 output.txt &> last20lines.txt
cat last20lines.txt
if [ $(grep -o 'Current map size:' last20lines.txt | wc -l) != $"20" ]; then exit 1; fi
#TODO: More reliabe verification.
run_nodejs:
name: Run Nodejs compatibility test
needs: [create-gke-cluster]
if: ${{ github.event.inputs.nodejs_run != 'no' }}
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Checkout to scripts
uses: actions/checkout@v2
- name: Checkout the Nodejs client repo
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.organization_name }}/hazelcast-nodejs-client
path: KubernetesExternalClients/nodejs/clientSourceCode
ref: ${{ github.event.inputs.nodejs_run }}
- name: Run test
run: |
cp KubernetesExternalClients/nodejs/client.js KubernetesExternalClients/nodejs/clientSourceCode/
cd KubernetesExternalClients/nodejs/clientSourceCode
npm install
npm run compile
sed -i "s/<EXTERNAL-IP>/${{needs.create-gke-cluster.outputs.external-ip}}/g" client.js
node client.js
run_csharp:
name: Run Csharp compatibility test
needs: [create-gke-cluster]
if: ${{ github.event.inputs.csharp_run != 'no' }}
runs-on: ubuntu-latest
steps:
- name: Setup .NET Core 8.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
8.0.x
- name: Checkout to scripts
uses: actions/checkout@v2
- name: Checkout the Csharp client repo
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.organization_name }}/hazelcast-csharp-client
path: KubernetesExternalClients/csharp/clientSourceCode
ref: ${{ github.event.inputs.csharp_run }}
- name: Run test
run: |
cp -R KubernetesExternalClients/csharp/KubernetesTest/ KubernetesExternalClients/csharp/clientSourceCode/src/KubernetesTest/
cd KubernetesExternalClients/csharp/clientSourceCode/src/KubernetesTest
sed -i "s/<EXTERNAL-IP>/${{needs.create-gke-cluster.outputs.external-ip}}/g" Program.cs
dotnet build -c Release
cd bin/Release/net7.0
dotnet KubernetesTest.dll &> output.txt && tail -n 20 output.txt &> last20lines.txt
cat last20lines.txt
if [ $(grep -o 'Current map size:' last20lines.txt | wc -l) != $"20" ]; then exit 1; fi
#TODO: More reliabe verification.
run_cpp:
name: Run Cpp compatibility test
needs: [create-gke-cluster]
if: ${{ github.event.inputs.cpp_run != 'no' }}
runs-on: ubuntu-latest
steps:
- name: Checkout to scripts
uses: actions/checkout@v2
- name: Checkout the Cpp client repo
uses: actions/checkout@v2
with:
repository: ${{ github.event.inputs.organization_name }}/hazelcast-cpp-client
path: KubernetesExternalClients/cpp/clientSourceCode
ref: ${{ github.event.inputs.cpp_run }}
- name: Install Boost
run: |
sudo apt-get install libboost-dev libboost-thread-dev libboost-chrono-dev
- name: Build&Install client
run: |
cd KubernetesExternalClients/cpp/clientSourceCode/ && mkdir build && cd build
cmake .. && cmake --build . --parallel && sudo cmake --build . --target install
- name: Run test
run: |
cd KubernetesExternalClients/cpp
sed -i "s/<EXTERNAL-IP>/${{needs.create-gke-cluster.outputs.external-ip}}/g" client.cpp
mkdir build && cd build && cmake .. && cmake --build .
./cppClientProject &> output.txt && tail -n 20 output.txt &> last20lines.txt
cat last20lines.txt
if [ $(grep -o 'Current map size:' last20lines.txt | wc -l) != $"14" ]; then exit 1; fi
#Count set it as 14 for verification because last 6 lines has shotdown logs of cpp client and there should be 14 'Current map size:'
#TODO: More reliabe verification
cleanup:
runs-on: ubuntu-latest
needs: [run_nodejs, run_python, run_go, run_cpp, run_csharp, create-gke-cluster]
if: always()
steps:
- id: 'auth'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.GKE_SA_KEY }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
- name: Delete cluster
run: |-
gcloud container clusters delete ${{ needs.create-gke-cluster.outputs.cluster_name}} --zone=${{ needs.create-gke-cluster.outputs.gke_zone }} --quiet