Kubernetes internal clients compatibility tests #87
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Kubernetes internal clients compatibility tests | |
on: | |
workflow_dispatch: | |
inputs: | |
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 | |
java_client_run: | |
description: JAVA = Set the branch name of client to run, otherwise set it as 'no' in order to skip running this client | |
required: true | |
default: master | |
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 | |
jobs: | |
create-java-image: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.java_client_run != 'no' }} | |
steps: | |
- name: "Setup JRE" | |
uses: "actions/setup-java@v2" | |
with: | |
distribution: "zulu" | |
java-version: "17" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout the client repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.organization_name }}/hazelcast-java-client | |
path: KubernetesInternalClients/java/clientSourceCode | |
ref: ${{ github.event.inputs.java_client_run }} | |
token: ${{ secrets.GH_PAT }} | |
- name: "Build OS" | |
working-directory: KubernetesInternalClients/java/clientSourceCode | |
run: | | |
chmod +x mvnw | |
HAZELCAST_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "HAZELCAST_VERSION=${HAZELCAST_VERSION}" >> $GITHUB_ENV | |
./mvnw -B -V -e clean install -DskipTests | |
- name: Build client application | |
working-directory: KubernetesInternalClients/java | |
run: | | |
sed -i "s/java-client-version/$HAZELCAST_VERSION/g" pom.xml | |
mvn clean install -DskipTests | |
docker build -t hazelcast-java-client:test . | |
- name: Upload image | |
uses: ishworkh/docker-image-artifact-upload@v1 | |
with: | |
image: "hazelcast-java-client:test" | |
create-csharp-image: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.csharp_run != 'no' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout the client repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.organization_name }}/hazelcast-csharp-client | |
path: KubernetesInternalClients/csharp/clientSourceCode | |
ref: ${{ github.event.inputs.csharp_run }} | |
- name: Setup .NET Core 8.0 | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: | | |
8.0.x | |
- name: Copy KubernetesTest project to csharp project | |
run: | | |
cp -R KubernetesInternalClients/csharp/KubernetesTest KubernetesInternalClients/csharp/clientSourceCode/src/ | |
- name: Build KubernetesTest project | |
run: | | |
cd KubernetesInternalClients/csharp/clientSourceCode/src/KubernetesTest | |
dotnet build -c Release | |
- name: Build client application | |
run: |- | |
docker build -t hazelcast-csharp-client:test KubernetesInternalClients/csharp | |
- name: Upload image | |
uses: ishworkh/docker-image-artifact-upload@v1 | |
with: | |
image: "hazelcast-csharp-client:test" | |
create-python-image: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.python_run != 'no' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout the client repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.organization_name }}/hazelcast-python-client | |
path: KubernetesInternalClients/python/clientSourceCode | |
ref: ${{ github.event.inputs.python-run }} | |
- name: Build client application | |
run: |- | |
docker build -t hazelcast-python-client:test KubernetesInternalClients/python | |
- name: Upload image | |
uses: ishworkh/docker-image-artifact-upload@v1 | |
with: | |
image: "hazelcast-python-client:test" | |
create-nodejs-image: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.nodejs_run != 'no' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout the client repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.organization_name }}/hazelcast-nodejs-client | |
path: KubernetesInternalClients/nodejs/clientSourceCode | |
ref: ${{ github.event.inputs.nodejs_run }} | |
- name: Build client project | |
run: | | |
cd KubernetesInternalClients/nodejs/clientSourceCode | |
npm install | |
npm run compile | |
- name: Build client application | |
run: |- | |
docker build -t hazelcast-nodejs-client:test KubernetesInternalClients/nodejs | |
- name: Upload image | |
uses: ishworkh/docker-image-artifact-upload@v1 | |
with: | |
image: "hazelcast-nodejs-client:test" | |
create-cpp-image: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.cpp_run != 'no' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout the client repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.organization_name }}/hazelcast-cpp-client | |
path: KubernetesInternalClients/cpp/clientSourceCode | |
ref: ${{ github.event.inputs.cpp_run }} | |
- name: Build client application | |
run: |- | |
docker build -t hazelcast-cpp-client:test KubernetesInternalClients/cpp | |
- name: Upload image | |
uses: ishworkh/docker-image-artifact-upload@v1 | |
with: | |
image: "hazelcast-cpp-client:test" | |
create-go-image: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.go_run != 'no' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Give the branch name to go.mod file | |
run: | | |
cd KubernetesInternalClients/go | |
sed -i "s/<InputBranchName>/${{ github.event.inputs.go_run }}/g" go.mod | |
- name: Build client application | |
run: |- | |
docker build -t hazelcast-go-client:test KubernetesInternalClients/go | |
- name: Upload image | |
uses: ishworkh/docker-image-artifact-upload@v1 | |
with: | |
image: "hazelcast-go-client:test" | |
wait-for-images: | |
name: Waits for image creation and create json for which clients run | |
needs: [create-python-image, create-nodejs-image, create-go-image, create-csharp-image, create-cpp-image, create-java-image] | |
if: always() | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set which client will be run | |
id: set-matrix | |
run: echo "::set-output name=matrix::$( python set_which_client_run.py | |
--java ${{ github.event.inputs.java_client_run }} | |
--nodejs ${{ github.event.inputs.nodejs_run }} | |
--go ${{ github.event.inputs.go_run }} | |
--cpp ${{ github.event.inputs.cpp_run }} | |
--csharp ${{ github.event.inputs.csharp_run }} | |
--python ${{ github.event.inputs.python_run }})" | |
run-tests: | |
name: Run kubernetes compatibility test | |
needs: [wait-for-images] | |
if: always() | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
deployment-type: [ 'helm' ] | |
client-language: ${{ fromJson(needs.wait-for-images.outputs.matrix) }} | |
steps: | |
- name: Setup Kubernetes in Docker | |
uses: engineerd/[email protected] | |
with: | |
version: "v0.11.1" | |
- name: Deploy Hazelcast cluster (Helm) | |
if: startsWith(matrix.deployment-type, 'helm') | |
run: |- | |
helm repo add hazelcast https://hazelcast-charts.s3.amazonaws.com/ | |
helm repo update | |
helm install hz-hazelcast hazelcast/hazelcast | |
- name: Wait for Hazelcast cluster | |
run: |- | |
kubectl wait --for=condition=ready pod/hz-hazelcast-0 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-1 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-2 --timeout=180s | |
- name: Download image | |
uses: ishworkh/docker-image-artifact-download@v1 | |
with: | |
image: "hazelcast-${{ matrix.client-language }}-client:test" | |
- name: Deploy client application | |
run: |- | |
kind load docker-image hazelcast-${{ matrix.client-language }}-client:test | |
kubectl run hazelcast-${{ matrix.client-language }}-client --image=hazelcast-${{ matrix.client-language }}-client:test | |
kubectl wait --for=condition=ready pod/hazelcast-${{ matrix.client-language }}-client --timeout=180s | |
- name: Verify client application | |
run: |- | |
sleep 10 | |
kubectl logs pod/hazelcast-${{ matrix.client-language }}-client | grep 'Successful connection!' -q | |
- name: Scale up | |
run: | | |
helm upgrade hz-hazelcast --set cluster.memberCount=6 hazelcast/hazelcast | |
kubectl wait --for=condition=ready pod/hz-hazelcast-0 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-1 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-2 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-3 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-4 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-5 --timeout=180s | |
sleep 60 | |
- name: Verify after scale up | |
run: | | |
kubectl logs --tail=20 hazelcast-${{ matrix.client-language }}-client >> output-${{ matrix.client-language }}-scaleup.txt | |
cat output-${{ matrix.client-language }}-scaleup.txt | |
if [ $(grep -o 'Current map size:' output-${{ matrix.client-language }}-scaleup.txt | wc -l) != $"20" ]; then exit 1; fi | |
- name: Scale down | |
run: | | |
helm upgrade hz-hazelcast --set cluster.memberCount=3 hazelcast/hazelcast | |
sleep 120 | |
- name: Verify after scale down | |
run: | | |
kubectl logs --tail=20 hazelcast-${{ matrix.client-language }}-client >> output-${{ matrix.client-language }}-scaledown.txt | |
cat output-${{ matrix.client-language }}-scaledown.txt | |
if [ $(grep -o 'Current map size:' output-${{ matrix.client-language }}-scaledown.txt | wc -l) != $"20" ]; then exit 1; fi | |
- name: Delete pods | |
run: | | |
kubectl delete pod hz-hazelcast-0 hz-hazelcast-1 hz-hazelcast-2 | |
kubectl wait --for=condition=ready pod/hz-hazelcast-0 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-1 --timeout=180s | |
kubectl wait --for=condition=ready pod/hz-hazelcast-2 --timeout=180s | |
sleep 60 | |
- name: Verify after delete pods | |
run: | | |
kubectl logs --tail=20 hazelcast-${{ matrix.client-language }}-client >> output-${{ matrix.client-language }}-deletepods.txt | |
cat output-${{ matrix.client-language }}-deletepods.txt | |
if [ $(grep -o 'Current map size:' output-${{ matrix.client-language }}-deletepods.txt | wc -l) != $"20" ]; then exit 1; fi | |
kubectl cp hazelcast-java-client:/log/hazelcast.log hazelcast.log | |
- name: Upload hazelcast logs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hazelcast.log | |
path: hazelcast.log | |
- name: Logs | |
if: always() | |
run: | | |
kubectl logs pod/hazelcast-${{ matrix.client-language }}-client | |