generated from hazelcast-guides/base-guide
-
Notifications
You must be signed in to change notification settings - Fork 6
252 lines (213 loc) · 7.55 KB
/
integrational-tests.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
name: Test on GKE
on:
push:
paths-ignore:
- 'docs/**'
env:
GCP_PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_ZONE: europe-west1-b
GCP_NETWORK: tutorial-test-network
jobs:
create-gke-cluster:
name: Create GKE cluster
runs-on: ubuntu-latest
outputs:
CLUSTER_NAME: ${{ steps.cluster.outputs.CLUSTER_NAME }}
steps:
- name: Authenticate to GCP
uses: 'google-github-actions/[email protected]'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.GCP_PROJECT_ID }}
- name: Create GKE cluster
id: cluster
run: |-
CLUSTER_NAME="hpo-ex-ex-$GITHUB_RUN_NUMBER"
echo "CLUSTER_NAME=$CLUSTER_NAME" >> $GITHUB_ENV
echo "::set-output name=CLUSTER_NAME::${CLUSTER_NAME}"
gcloud container clusters create $CLUSTER_NAME \
--zone=${{ env.GKE_ZONE }} \
--project=${{ env.GCP_PROJECT_ID }} \
--network=${{ env.GCP_NETWORK }} \
--machine-type=n1-standard-2 \
--num-nodes=2
sleep 30
- name: Connect to the GKE cluster
run: |
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} \
--zone ${{ env.GKE_ZONE }} \
--project ${{ env.GCP_PROJECT_ID }}
- name: Install Kubectl
run: |-
gcloud components install kubectl
- name: Deploy operator
run: |-
helm repo add hazelcast https://hazelcast-charts.s3.amazonaws.com/
helm repo update
helm install operator hazelcast/hazelcast-platform-operator --set installCRDs=true,phoneHomeEnabled=false
run-tests:
name: Run Integration tests on GKE
runs-on: ubuntu-latest
needs: create-gke-cluster
env:
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
strategy:
max-parallel: 1
fail-fast: false
matrix:
include:
- type: smart
suffix: ""
- type: unisocket
suffix: "-unisocket"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'
cache: 'maven'
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Set up Golang
uses: actions/setup-go@v2
with:
go-version: '^1.17.2'
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
cache: 'pip'
- name: Authenticate to GCP
uses: 'google-github-actions/[email protected]'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.GCP_PROJECT_ID }}
- name: Install Kubectl
run: |-
gcloud components install kubectl
- name: Connect to the GKE cluster
run: |
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} \
--zone ${{ env.GKE_ZONE }} \
--project ${{ env.GCP_PROJECT_ID }}
- name: Deploy Hazelcast cluster
run: |-
kubectl apply -f hazelcast${{matrix.suffix}}.yaml
- name: Wait for external IP to get assigned
timeout-minutes: 5
run: |-
serviceType=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.spec.type}")
if [ "$serviceType" != "LoadBalancer" ]; then
exit 1
fi
EXTERNAL_IP=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
while [ "$EXTERNAL_IP" == "" ]; do
sleep 10
EXTERNAL_IP=$(kubectl get svc my-hazelcast${{matrix.suffix}} --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
done
echo "EXTERNAL_IP=${EXTERNAL_IP}" >> $GITHUB_ENV
- name: Wait for Smart type member IPs to get assigned
if: matrix.type == 'smart'
timeout-minutes: 5
run: |-
for i in {0..2}; do
SVC_NAME="my-hazelcast${{matrix.suffix}}-${i}"
SVC_EXTERNAL_IP=$(kubectl get svc "${SVC_NAME}" --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
while [ "$SVC_EXTERNAL_IP" == "" ]; do
sleep 10
SVC_EXTERNAL_IP=$(kubectl get svc "${SVC_NAME}" --output="jsonpath={.status.loadBalancer.ingress[0].ip}")
done
done
- name: Wait for Hazelcast pods
run: |-
kubectl wait --for=condition=ready pod/my-hazelcast${{matrix.suffix}}-0 --timeout=5m
kubectl wait --for=condition=ready pod/my-hazelcast${{matrix.suffix}}-1 --timeout=150s
kubectl wait --for=condition=ready pod/my-hazelcast${{matrix.suffix}}-2 --timeout=150s
- name: Test Java Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd java${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" src/main/java/com/hazelcast/Main.java
mvn package
java -jar target/*jar-with-dependencies*.jar >> output-java.txt &
PID=$!
sleep 30
kill $PID
cat output-java.txt | grep 'Successful connection!' -q
- name: Test Node.js Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd nodejs${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" client.js
npm install
npm start >> output-nodejs.txt &
PID=$!
sleep 30
kill $PID
cat output-nodejs.txt | grep 'Successful connection!' -q
- name: Test Go Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd go${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" main.go
go run main.go >> output-go.txt &
PID=$!
sleep 30
kill $PID
cat output-go.txt | grep 'Successful connection!' -q
- name: Test Python Client
run: |-
EXTERNAL_IP="${{ env.EXTERNAL_IP }}"
cd python${{matrix.suffix}}
sed -i "s/<EXTERNAL-IP>/$EXTERNAL_IP/g" main.py
pip install -r requirements.txt
python main.py >> output-python.txt &
PID=$!
sleep 30
kill $PID
cat output-python.txt | grep 'Successful connection!' -q
- name: Clean up
if: ${{ always() }}
run: |-
kubectl delete hazelcast my-hazelcast${{matrix.suffix}}
kubectl wait --for=delete pod/my-hazelcast${{matrix.suffix}}-0 --timeout=2m
kubectl get svc my-hazelcast${{matrix.suffix}} || exit 0
kubectl wait --for=delete svc/my-hazelcast${{matrix.suffix}} --timeout=5m
- name: Clean up Smart services
if: ${{ always() && matrix.type == 'smart' }}
run: |-
kubectl get svc my-hazelcast${{matrix.suffix}}-0 || exit 0
kubectl wait --for=delete svc/my-hazelcast${{matrix.suffix}}-0 --timeout=5m
clean-up:
name: Clean up GKE cluster
runs-on: ubuntu-latest
needs: [run-tests, create-gke-cluster]
if: ${{ always() }}
env:
CLUSTER_NAME: ${{ needs.create-gke-cluster.outputs.CLUSTER_NAME }}
steps:
- name: Authenticate to GCP
uses: 'google-github-actions/[email protected]'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.GCP_PROJECT_ID }}
# Clean up
- name: Delete cluster
run: |-
gcloud container clusters delete "$CLUSTER_NAME" --zone="$GKE_ZONE" --quiet