Kubernetes external clients compatibility tests with GKE #108
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 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 | |
java_client_run: | |
description: Java Client (Standard), (old name is Java thin client) = 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 | |
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@v4 | |
- 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: Set output of cluster_name | |
id: cluster_name | |
run: echo "::set-output name=cluster_name::${{env.clusterName}}" | |
- name: Set output of gke_zone | |
id: gke_zone | |
run: echo "::set-output name=gke_zone::${{env.GKE_ZONE}}" | |
- 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 | |
kubectl create secret generic hazelcast-license-key --from-literal=license-key=${{ secrets.HAZELCAST_ENTERPRISE_KEY_V7 }} | |
cat <<EOF | kubectl apply -f - | |
apiVersion: hazelcast.com/v1alpha1 | |
kind: Hazelcast | |
metadata: | |
name: hz-hazelcast | |
spec: | |
clusterSize: 3 | |
licenseKeySecretName: hazelcast-license-key | |
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 }}" | |
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@v4 | |
- name: Checkout the go client repo | |
uses: actions/checkout@v4 | |
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 | |
run_java: | |
name: Run Java Client (Standard) compatibility test | |
needs: [create-gke-cluster] | |
if: ${{ github.event.inputs.java_client_run != 'no' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Setup JRE" | |
uses: "actions/setup-java@v2" | |
with: | |
distribution: "zulu" | |
java-version: "17" | |
- name: Checkout to scripts | |
uses: actions/checkout@v4 | |
- name: Checkout the java client repo | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.inputs.organization_name }}/hazelcast-java-client | |
path: KubernetesExternalClients/java/clientSourceCode | |
ref: ${{ github.event.inputs.java_client_run }} | |
token: ${{ secrets.GH_PAT }} | |
- name: "Setup Local Maven Cache" | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: "Build OS" | |
working-directory: KubernetesExternalClients/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: Run test | |
working-directory: KubernetesExternalClients/java | |
run: | | |
sed -i "s/<EXTERNAL-IP>/${{needs.create-gke-cluster.outputs.external-ip}}/g" src/main/java/KubernetesExternalTest.java | |
sed -i "s/java-client-version/$HAZELCAST_VERSION/g" pom.xml | |
mvn clean install | |
mvn exec:java 2>&1 | tee 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@v5 | |
with: | |
python-version: 3.9 | |
- name: Checkout to scripts | |
uses: actions/checkout@v4 | |
- name: Checkout the Python client repo | |
uses: actions/checkout@v4 | |
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@v4 | |
- name: Checkout the Nodejs client repo | |
uses: actions/checkout@v4 | |
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@v4 | |
- name: Checkout the Csharp client repo | |
uses: actions/checkout@v4 | |
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/net8.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@v4 | |
- name: Checkout the Cpp client repo | |
uses: actions/checkout@v4 | |
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, run_java, 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 | |