Skip to content

Language Comparison Tests #194

Language Comparison Tests

Language Comparison Tests #194

name: Language Comparison Tests
on:
workflow_dispatch:
schedule:
- cron: '0 18 * * 0'
jobs:
setup:
runs-on: ubuntu-latest
timeout-minutes: 600
steps:
- name: CHECKOUT
uses: actions/checkout@v2
- name: AZURE LOGIN
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Create Cluster
env:
AZURE_APP_ID: ${{ secrets.AZURE_APP_ID }}
AZURE_APP_PASSWORD: ${{ secrets.AZURE_APP_PASSWORD }}
RESOURCE_GROUP: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
run: |
az aks create \
--resource-group "${RESOURCE_GROUP}" \
--name "bal-perf-cluster-comp" \
--service-principal "${AZURE_APP_ID}"\
--client-secret "${AZURE_APP_PASSWORD}" \
--nodepool-name compnodepool \
--node-vm-size "Standard_F4s_v2" \
--node-osdisk-size 256 \
--node-osdisk-type Managed \
--node-count 1 \
--location "eastus" \
--generate-ssh-keys
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy Volume
run: |
kubectl apply -f https://raw.githubusercontent.com/ballerina-platform/ballerina-performance-cloud/main/base-image/volumes.yaml
ballerina:
needs: setup
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
payload: [0]
users: [60, 200]
env:
TEST_NAME: "ballerina_hello"
TEST_ROOT: "load-tests"
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Ballerina Build
uses: ballerina-platform/ballerina-action@nightly
env:
DOCKER_BUILDKIT: 0
WORKING_DIR: load-tests/ballerina_hello/src
with:
args:
build
- name: Docker push
run: docker push ballerina/${TEST_NAME}:latest
- name: Copy artifacts
run: |
ls -ltr
cp -a ${TEST_ROOT}/${TEST_NAME}/src/target/kubernetes/${TEST_NAME}/. ${TEST_ROOT}/${TEST_NAME}/deployment/
- name: 'Install Kustomize'
run: |
curl -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: 'Run Kustomize'
run: |
kustomize build ${TEST_ROOT}/${TEST_NAME}/deployment > ${TEST_ROOT}/${TEST_NAME}/final.yaml
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy artifacts
run: |
kubectl apply -f ${TEST_ROOT}/${TEST_NAME}/final.yaml
- name: Login via Az module
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Write values to outputs
id: write
run: |
echo "::set-output name=scenario-name::${TEST_NAME}"
echo "::set-output name=vm-name::bal-perf-vm-`echo ${TEST_NAME} | tr '_' '-'`-${{ matrix.users }}-${{ matrix.payload }}-${{ GITHUB.RUN_NUMBER }}"
echo "::set-output name=git-token::${{ secrets.BALLERINA_BOT_TOKEN }}"
echo "::set-output name=space-id::${{ secrets.SPACE_ID }}"
echo "::set-output name=message-key::${{ secrets.MESSAGE_KEY }}"
echo "::set-output name=chat-token::${{ secrets.CHAT_TOKEN }}"
echo "::set-output name=custom-image-name::$(cat image.txt)"
docker run --entrypoint "/ballerina/runtime/bin/bal" ballerina/ballerina:nightly "version" > tmp.txt
version_out=$(cat tmp.txt | head -n 1)
echo "::set-output name=version::${version_out}"
- name: Wait for VM instance
run: sleep 60s
shell: bash
- name: Deploy Jmeter container
run: |
sed -i -e 's/<<CLUSTER_IP>>//g' base-image/k8s.yaml
sed -i -e 's/<<REPO_NAME>>/ballerina-performance-cloud/g' base-image/k8s.yaml
sed -i -e 's/<<SCENARIO_NAME>>/${{ steps.write.outputs.scenario-name }}/g' base-image/k8s.yaml
sed -i -e 's/<<GITHUB_TOKEN>>/${{steps.write.outputs.git-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<PAYLOAD_SIZE>>/${{ matrix.payload }}/g' base-image/k8s.yaml
sed -i -e 's/<<SPACE_ID>>/${{steps.write.outputs.space-id}}/g' base-image/k8s.yaml
sed -i -e 's/<<MESSAGE_KEY>>/${{steps.write.outputs.message-key}}/g' base-image/k8s.yaml
sed -i -e 's/<<CHAT_TOKEN>>/${{steps.write.outputs.chat-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<DISPATCH_TYPE>>//g' base-image/k8s.yaml
sed -i -e 's/<<BRANCH_NAME>>//g' base-image/k8s.yaml
sed -i -e 's/<<CONCURRENT_USERS>>/${{ matrix.users }}/g' base-image/k8s.yaml
sed -i -e 's/<<VERSION>>/${{ steps.write.outputs.version }}/g' base-image/k8s.yaml
sed -i -e 's/<<BASE_BRANCH>>//g' base-image/k8s.yaml
kubectl apply -f base-image/k8s.yaml
echo "Waiting till the Jmeter job to finish"
attempt_num=1
until kubectl wait --for=condition=complete --timeout=2h job/jmeter-job
do
if ((attempt_num==3))
then
echo "Job waiting failed on the $attempt_num attempt and there are no more attempts left! Failing the workflow"
kubectl get jobs
kubectl get pods
kubectl logs job.batch/jmeter-job
exit 1
else
echo "Attempt $attempt_num failed! Trying again in 30 seconds..."
((attempt_num++))
sleep 30
kubectl get jobs
kubectl get pods
fi
done
kubectl logs job.batch/jmeter-job
- name: Pod logs
if: always()
run: |
kubectl logs -l logs=true
- name: Undeploy Kubernetes artifacts
if: always()
run: |
kubectl delete -f ${TEST_ROOT}/${TEST_NAME}/final.yaml
kubectl delete -f base-image/k8s.yaml
python:
needs: ballerina
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
payload: [0]
users: [60, 200]
env:
TEST_NAME: "python_hello"
TEST_ROOT: "load-tests"
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker build
env:
DOCKER_BUILDKIT: 0
run: docker build -t ballerina/${TEST_NAME} ${TEST_ROOT}/${TEST_NAME}/src
- name: Docker push
run: docker push ballerina/${TEST_NAME}
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy artifacts
run: |
kubectl apply -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
- name: Login via Az module
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Write values to outputs
id: write
run: |
echo "::set-output name=scenario-name::${TEST_NAME}"
echo "::set-output name=vm-name::bal-perf-vm-`echo ${TEST_NAME} | tr '_' '-'`-${{ matrix.users }}-${{ matrix.payload }}-${{ GITHUB.RUN_NUMBER }}"
echo "::set-output name=git-token::${{ secrets.BALLERINA_BOT_TOKEN }}"
echo "::set-output name=space-id::${{ secrets.SPACE_ID }}"
echo "::set-output name=message-key::${{ secrets.MESSAGE_KEY }}"
echo "::set-output name=chat-token::${{ secrets.CHAT_TOKEN }}"
echo "::set-output name=custom-image-name::$(cat image.txt)"
version_out="Python 3.8"
echo "::set-output name=version::${version_out}"
- name: Wait for VM instance
run: sleep 60s
shell: bash
- name: Deploy Jmeter container
run: |
sed -i -e 's/<<CLUSTER_IP>>//g' base-image/k8s.yaml
sed -i -e 's/<<REPO_NAME>>/ballerina-performance-cloud/g' base-image/k8s.yaml
sed -i -e 's/<<SCENARIO_NAME>>/${{ steps.write.outputs.scenario-name }}/g' base-image/k8s.yaml
sed -i -e 's/<<GITHUB_TOKEN>>/${{steps.write.outputs.git-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<PAYLOAD_SIZE>>/${{ matrix.payload }}/g' base-image/k8s.yaml
sed -i -e 's/<<SPACE_ID>>/${{steps.write.outputs.space-id}}/g' base-image/k8s.yaml
sed -i -e 's/<<MESSAGE_KEY>>/${{steps.write.outputs.message-key}}/g' base-image/k8s.yaml
sed -i -e 's/<<CHAT_TOKEN>>/${{steps.write.outputs.chat-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<DISPATCH_TYPE>>//g' base-image/k8s.yaml
sed -i -e 's/<<BRANCH_NAME>>//g' base-image/k8s.yaml
sed -i -e 's/<<CONCURRENT_USERS>>/${{ matrix.users }}/g' base-image/k8s.yaml
sed -i -e 's/<<VERSION>>/${{ steps.write.outputs.version }}/g' base-image/k8s.yaml
sed -i -e 's/<<BASE_BRANCH>>//g' base-image/k8s.yaml
kubectl apply -f base-image/k8s.yaml
echo "Waiting till the Jmeter job to finish"
attempt_num=1
until kubectl wait --for=condition=complete --timeout=2h job/jmeter-job
do
if ((attempt_num==3))
then
echo "Job waiting failed on the $attempt_num attempt and there are no more attempts left! Failing the workflow"
kubectl get jobs
kubectl get pods
kubectl logs job.batch/jmeter-job
exit 1
else
echo "Attempt $attempt_num failed! Trying again in 30 seconds..."
((attempt_num++))
sleep 30
kubectl get jobs
kubectl get pods
fi
done
kubectl logs job.batch/jmeter-job
- name: Pod logs
if: always()
run: |
kubectl logs -l logs=true
- name: Undeploy Kubernetes artifacts
if: always()
run: |
kubectl delete -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
kubectl delete -f base-image/k8s.yaml
python-flask:
needs: python
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
payload: [0]
users: [60, 200]
env:
TEST_NAME: "python_flask_hello"
TEST_ROOT: "load-tests"
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker build
env:
DOCKER_BUILDKIT: 0
run: docker build -t ballerina/${TEST_NAME} ${TEST_ROOT}/${TEST_NAME}/src
- name: Docker push
run: docker push ballerina/${TEST_NAME}
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy artifacts
run: |
kubectl apply -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
- name: Login via Az module
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Write values to outputs
id: write
run: |
echo "::set-output name=scenario-name::${TEST_NAME}"
echo "::set-output name=vm-name::bal-perf-vm-`echo ${TEST_NAME} | tr '_' '-'`-${{ matrix.users }}-${{ matrix.payload }}-${{ GITHUB.RUN_NUMBER }}"
echo "::set-output name=git-token::${{ secrets.BALLERINA_BOT_TOKEN }}"
echo "::set-output name=space-id::${{ secrets.SPACE_ID }}"
echo "::set-output name=message-key::${{ secrets.MESSAGE_KEY }}"
echo "::set-output name=chat-token::${{ secrets.CHAT_TOKEN }}"
echo "::set-output name=custom-image-name::$(cat image.txt)"
version_out="Python 3.8 Flask 2.0"
echo "::set-output name=version::${version_out}"
- name: Wait for VM instance
run: sleep 60s
shell: bash
- name: Deploy Jmeter container
run: |
sed -i -e 's/<<CLUSTER_IP>>//g' base-image/k8s.yaml
sed -i -e 's/<<REPO_NAME>>/ballerina-performance-cloud/g' base-image/k8s.yaml
sed -i -e 's/<<SCENARIO_NAME>>/${{ steps.write.outputs.scenario-name }}/g' base-image/k8s.yaml
sed -i -e 's/<<GITHUB_TOKEN>>/${{steps.write.outputs.git-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<PAYLOAD_SIZE>>/${{ matrix.payload }}/g' base-image/k8s.yaml
sed -i -e 's/<<SPACE_ID>>/${{steps.write.outputs.space-id}}/g' base-image/k8s.yaml
sed -i -e 's/<<MESSAGE_KEY>>/${{steps.write.outputs.message-key}}/g' base-image/k8s.yaml
sed -i -e 's/<<CHAT_TOKEN>>/${{steps.write.outputs.chat-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<DISPATCH_TYPE>>//g' base-image/k8s.yaml
sed -i -e 's/<<BRANCH_NAME>>//g' base-image/k8s.yaml
sed -i -e 's/<<CONCURRENT_USERS>>/${{ matrix.users }}/g' base-image/k8s.yaml
sed -i -e 's/<<VERSION>>/${{ steps.write.outputs.version }}/g' base-image/k8s.yaml
sed -i -e 's/<<BASE_BRANCH>>//g' base-image/k8s.yaml
kubectl apply -f base-image/k8s.yaml
echo "Waiting till the Jmeter job to finish"
attempt_num=1
until kubectl wait --for=condition=complete --timeout=2h job/jmeter-job
do
if ((attempt_num==3))
then
echo "Job waiting failed on the $attempt_num attempt and there are no more attempts left! Failing the workflow"
kubectl get jobs
kubectl get pods
kubectl logs job.batch/jmeter-job
exit 1
else
echo "Attempt $attempt_num failed! Trying again in 30 seconds..."
((attempt_num++))
sleep 30
kubectl get jobs
kubectl get pods
fi
done
kubectl logs job.batch/jmeter-job
- name: Pod logs
if: always()
run: |
kubectl logs -l logs=true
- name: Undeploy Kubernetes artifacts
if: always()
run: |
kubectl delete -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
kubectl delete -f base-image/k8s.yaml
node:
needs: python-flask
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
payload: [0]
users: [60, 200]
env:
TEST_NAME: "node_hello"
TEST_ROOT: "load-tests"
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker build
env:
DOCKER_BUILDKIT: 0
run: docker build -t ballerina/${TEST_NAME} ${TEST_ROOT}/${TEST_NAME}/src
- name: Docker push
run: docker push ballerina/${TEST_NAME}
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy artifacts
run: |
kubectl apply -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
- name: Login via Az module
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Write values to outputs
id: write
run: |
echo "::set-output name=scenario-name::${TEST_NAME}"
echo "::set-output name=vm-name::bal-perf-vm-`echo ${TEST_NAME} | tr '_' '-'`-${{ matrix.users }}-${{ matrix.payload }}-${{ GITHUB.RUN_NUMBER }}"
echo "::set-output name=git-token::${{ secrets.BALLERINA_BOT_TOKEN }}"
echo "::set-output name=space-id::${{ secrets.SPACE_ID }}"
echo "::set-output name=message-key::${{ secrets.MESSAGE_KEY }}"
echo "::set-output name=chat-token::${{ secrets.CHAT_TOKEN }}"
echo "::set-output name=custom-image-name::$(cat image.txt)"
version_out="Node 14"
echo "::set-output name=version::${version_out}"
- name: Wait for VM instance
run: sleep 60s
shell: bash
- name: Deploy Jmeter container
run: |
sed -i -e 's/<<CLUSTER_IP>>//g' base-image/k8s.yaml
sed -i -e 's/<<REPO_NAME>>/ballerina-performance-cloud/g' base-image/k8s.yaml
sed -i -e 's/<<SCENARIO_NAME>>/${{ steps.write.outputs.scenario-name }}/g' base-image/k8s.yaml
sed -i -e 's/<<GITHUB_TOKEN>>/${{steps.write.outputs.git-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<PAYLOAD_SIZE>>/${{ matrix.payload }}/g' base-image/k8s.yaml
sed -i -e 's/<<SPACE_ID>>/${{steps.write.outputs.space-id}}/g' base-image/k8s.yaml
sed -i -e 's/<<MESSAGE_KEY>>/${{steps.write.outputs.message-key}}/g' base-image/k8s.yaml
sed -i -e 's/<<CHAT_TOKEN>>/${{steps.write.outputs.chat-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<DISPATCH_TYPE>>//g' base-image/k8s.yaml
sed -i -e 's/<<BRANCH_NAME>>//g' base-image/k8s.yaml
sed -i -e 's/<<CONCURRENT_USERS>>/${{ matrix.users }}/g' base-image/k8s.yaml
sed -i -e 's/<<VERSION>>/${{ steps.write.outputs.version }}/g' base-image/k8s.yaml
sed -i -e 's/<<BASE_BRANCH>>//g' base-image/k8s.yaml
kubectl apply -f base-image/k8s.yaml
echo "Waiting till the Jmeter job to finish"
attempt_num=1
until kubectl wait --for=condition=complete --timeout=2h job/jmeter-job
do
if ((attempt_num==3))
then
echo "Job waiting failed on the $attempt_num attempt and there are no more attempts left! Failing the workflow"
kubectl get jobs
kubectl get pods
kubectl logs job.batch/jmeter-job
exit 1
else
echo "Attempt $attempt_num failed! Trying again in 30 seconds..."
((attempt_num++))
sleep 30
kubectl get jobs
kubectl get pods
fi
done
kubectl logs job.batch/jmeter-job
- name: Pod logs
if: always()
run: |
kubectl logs -l logs=true
- name: Undeploy Kubernetes artifacts
if: always()
run: |
kubectl delete -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
kubectl delete -f base-image/k8s.yaml
node-express:
needs: node
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
payload: [0]
users: [60, 200]
env:
TEST_NAME: "node_express_hello"
TEST_ROOT: "load-tests"
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker build
env:
DOCKER_BUILDKIT: 0
run: docker build -t ballerina/${TEST_NAME} ${TEST_ROOT}/${TEST_NAME}/src
- name: Docker push
run: docker push ballerina/${TEST_NAME}
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy artifacts
run: |
kubectl apply -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
- name: Login via Az module
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Write values to outputs
id: write
run: |
echo "::set-output name=scenario-name::${TEST_NAME}"
echo "::set-output name=vm-name::bal-perf-vm-`echo ${TEST_NAME} | tr '_' '-'`-${{ matrix.users }}-${{ matrix.payload }}-${{ GITHUB.RUN_NUMBER }}"
echo "::set-output name=git-token::${{ secrets.BALLERINA_BOT_TOKEN }}"
echo "::set-output name=space-id::${{ secrets.SPACE_ID }}"
echo "::set-output name=message-key::${{ secrets.MESSAGE_KEY }}"
echo "::set-output name=chat-token::${{ secrets.CHAT_TOKEN }}"
echo "::set-output name=custom-image-name::$(cat image.txt)"
version_out="Node 14 Express 4.17"
echo "::set-output name=version::${version_out}"
- name: Wait for VM instance
run: sleep 60s
shell: bash
- name: Deploy Jmeter container
run: |
sed -i -e 's/<<CLUSTER_IP>>//g' base-image/k8s.yaml
sed -i -e 's/<<REPO_NAME>>/ballerina-performance-cloud/g' base-image/k8s.yaml
sed -i -e 's/<<SCENARIO_NAME>>/${{ steps.write.outputs.scenario-name }}/g' base-image/k8s.yaml
sed -i -e 's/<<GITHUB_TOKEN>>/${{steps.write.outputs.git-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<PAYLOAD_SIZE>>/${{ matrix.payload }}/g' base-image/k8s.yaml
sed -i -e 's/<<SPACE_ID>>/${{steps.write.outputs.space-id}}/g' base-image/k8s.yaml
sed -i -e 's/<<MESSAGE_KEY>>/${{steps.write.outputs.message-key}}/g' base-image/k8s.yaml
sed -i -e 's/<<CHAT_TOKEN>>/${{steps.write.outputs.chat-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<DISPATCH_TYPE>>//g' base-image/k8s.yaml
sed -i -e 's/<<BRANCH_NAME>>//g' base-image/k8s.yaml
sed -i -e 's/<<CONCURRENT_USERS>>/${{ matrix.users }}/g' base-image/k8s.yaml
sed -i -e 's/<<VERSION>>/${{ steps.write.outputs.version }}/g' base-image/k8s.yaml
sed -i -e 's/<<BASE_BRANCH>>//g' base-image/k8s.yaml
kubectl apply -f base-image/k8s.yaml
echo "Waiting till the Jmeter job to finish"
attempt_num=1
until kubectl wait --for=condition=complete --timeout=2h job/jmeter-job
do
if ((attempt_num==3))
then
echo "Job waiting failed on the $attempt_num attempt and there are no more attempts left! Failing the workflow"
kubectl get jobs
kubectl get pods
kubectl logs job.batch/jmeter-job
exit 1
else
echo "Attempt $attempt_num failed! Trying again in 30 seconds..."
((attempt_num++))
sleep 30
kubectl get jobs
kubectl get pods
fi
done
kubectl logs job.batch/jmeter-job
- name: Pod logs
if: always()
run: |
kubectl logs -l logs=true
- name: Undeploy Kubernetes artifacts
if: always()
run: |
kubectl delete -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
kubectl delete -f base-image/k8s.yaml
go-lang:
needs: node-express
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
payload: [0]
users: [60, 200]
env:
TEST_NAME: "go_hello"
TEST_ROOT: "load-tests"
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Docker build
env:
DOCKER_BUILDKIT: 0
run: docker build -t ballerina/${TEST_NAME} ${TEST_ROOT}/${TEST_NAME}/src
- name: Docker push
run: docker push ballerina/${TEST_NAME}
- name: Configure AKS
uses: azure/aks-set-context@v1
with:
creds: '${{ secrets.AZURE_CREDENTIALS }}'
cluster-name: 'bal-perf-cluster-comp'
resource-group: ${{ secrets.CLUSTER_RESOURCE_GROUP }}
- name: Deploy artifacts
run: |
kubectl apply -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
- name: Login via Az module
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Write values to outputs
id: write
run: |
echo "::set-output name=scenario-name::${TEST_NAME}"
echo "::set-output name=vm-name::bal-perf-vm-`echo ${TEST_NAME} | tr '_' '-'`-${{ matrix.users }}-${{ matrix.payload }}-${{ GITHUB.RUN_NUMBER }}"
echo "::set-output name=git-token::${{ secrets.BALLERINA_BOT_TOKEN }}"
echo "::set-output name=space-id::${{ secrets.SPACE_ID }}"
echo "::set-output name=message-key::${{ secrets.MESSAGE_KEY }}"
echo "::set-output name=chat-token::${{ secrets.CHAT_TOKEN }}"
echo "::set-output name=custom-image-name::$(cat image.txt)"
version_out="Go 1.17.6"
echo "::set-output name=version::${version_out}"
- name: Wait for VM instance
run: sleep 60s
shell: bash
- name: Deploy Jmeter container
run: |
sed -i -e 's/<<CLUSTER_IP>>//g' base-image/k8s.yaml
sed -i -e 's/<<REPO_NAME>>/ballerina-performance-cloud/g' base-image/k8s.yaml
sed -i -e 's/<<SCENARIO_NAME>>/${{ steps.write.outputs.scenario-name }}/g' base-image/k8s.yaml
sed -i -e 's/<<GITHUB_TOKEN>>/${{steps.write.outputs.git-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<PAYLOAD_SIZE>>/${{ matrix.payload }}/g' base-image/k8s.yaml
sed -i -e 's/<<SPACE_ID>>/${{steps.write.outputs.space-id}}/g' base-image/k8s.yaml
sed -i -e 's/<<MESSAGE_KEY>>/${{steps.write.outputs.message-key}}/g' base-image/k8s.yaml
sed -i -e 's/<<CHAT_TOKEN>>/${{steps.write.outputs.chat-token}}/g' base-image/k8s.yaml
sed -i -e 's/<<DISPATCH_TYPE>>//g' base-image/k8s.yaml
sed -i -e 's/<<BRANCH_NAME>>//g' base-image/k8s.yaml
sed -i -e 's/<<CONCURRENT_USERS>>/${{ matrix.users }}/g' base-image/k8s.yaml
sed -i -e 's/<<VERSION>>/${{ steps.write.outputs.version }}/g' base-image/k8s.yaml
sed -i -e 's/<<BASE_BRANCH>>//g' base-image/k8s.yaml
kubectl apply -f base-image/k8s.yaml
echo "Waiting till the Jmeter job to finish"
attempt_num=1
until kubectl wait --for=condition=complete --timeout=2h job/jmeter-job
do
if ((attempt_num==3))
then
echo "Job waiting failed on the $attempt_num attempt and there are no more attempts left! Failing the workflow"
kubectl get jobs
kubectl get pods
kubectl logs job.batch/jmeter-job
exit 1
else
echo "Attempt $attempt_num failed! Trying again in 30 seconds..."
((attempt_num++))
sleep 30
kubectl get jobs
kubectl get pods
fi
done
kubectl logs job.batch/jmeter-job
- name: Pod logs
if: always()
run: |
kubectl logs -l logs=true
- name: Undeploy Kubernetes artifacts
if: always()
run: |
kubectl delete -f ${TEST_ROOT}/${TEST_NAME}/k8s.yaml
kubectl delete -f base-image/k8s.yaml
cleanup:
needs: go-lang
if: always()
name: clean up cluster
runs-on: ubuntu-latest
steps:
- name: AZURE LOGIN
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Cleaning up the cluster
if: always()
uses: azure/CLI@v1
with:
azcliversion: "agentazcliversion"
inlineScript: |
az group delete --name mc_${{ secrets.CLUSTER_RESOURCE_GROUP }}_bal-perf-cluster-comp_eastus -y
az aks delete --name bal-perf-cluster-comp --resource-group ${{ secrets.CLUSTER_RESOURCE_GROUP }} -y