Skip to content

Commit

Permalink
Merge pull request #96 from kaneeldias/load-test
Browse files Browse the repository at this point in the history
Add load test for query operation
  • Loading branch information
kaneeldias committed Nov 17, 2021
2 parents ae503a4 + e1b705f commit 9ecbe0d
Show file tree
Hide file tree
Showing 14 changed files with 394 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-timestamped-master.yml
Expand Up @@ -8,6 +8,7 @@ on:
paths-ignore:
- '*.md'
- 'docs/**'
- 'load-tests/**'

jobs:
build:
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/create-summary-pr.yml
@@ -0,0 +1,17 @@
name: Create Automated Summary PR for Load Tests
on:
push:
branches:
- 'nightly-**'
paths:
- 'load-tests/**/results/summary.csv'
jobs:
createPullRequest:
name: Create Summary Update PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create pull request for new summary
run: gh pr create --title "[Automated] Update summary csv files" --body "Update summary csv files"
env:
GITHUB_TOKEN: ${{ secrets.BALLERINA_BOT_TOKEN }}
52 changes: 52 additions & 0 deletions .github/workflows/trigger-load-tests.yml
@@ -0,0 +1,52 @@
name: Trigger Load Tests

on:
workflow_dispatch:
inputs:
tests:
description: >
List of test names. This needs to be filled only if you want to run a specific set of tests. Example: foo,bar
required: false
clusterName:
description: 'Cluster name'
default: 'mssql-perf-cluster-test'
required: false

jobs:
invokeLoadTests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get latest ballerina runtime artifact
id: setRuntimeUrl
shell: bash
run: |
printf "::set-output name=runtimeUrl::%s" $(curl -H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/ballerina-platform/module-ballerinax-mssql/actions/artifacts | \
jq '[.artifacts[] | select(.name=="ballerina-runtime" and .expired==false)]|max|.archive_download_url')
- name: Format test names
id: formatTestNames
shell: bash
run: |
tests="${{github.event.inputs.tests}}"
if [ ! "$tests" = "" ]; then
testsInput=(${tests//,/ })
testsCount=${#testsInput[@]}
testsOutput=""
for (( i=0; i<$testsCount; i++ ));
do
testsOutput+=\\'"'${testsInput[$i]}\\'"',
done
printf "::set-output name=testNames::%s" [${testsOutput:0:-1}]
else
printf "::set-output name=testNames::%s" $tests
fi
- name: Invoke standard library load test workflow
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Stdlib Workflow
repo: ballerina-platform/ballerina-performance-cloud
ref: refs/heads/main
token: ${{ secrets.BALLERINA_BOT_TOKEN }}
inputs: '{ "repo-name": "module-ballerinax-mssql", "tests": "${{ steps.formatTestNames.outputs.testNames }}", "zipURL": ${{ steps.setRuntimeUrl.outputs.runtimeUrl}}, "clusterName": "${{ github.event.inputs.clusterName }}" }'
13 changes: 13 additions & 0 deletions load-tests/query-operation/deployment/deployment-patch.yaml
@@ -0,0 +1,13 @@
apiVersion: "apps/v1"
kind: Deployment
metadata:
name: no-name
spec:
template:
metadata:
labels:
logs: "true"
spec:
containers:
- name: "query-operation-deployment"
imagePullPolicy: Always
19 changes: 19 additions & 0 deletions load-tests/query-operation/deployment/ingress.yaml
@@ -0,0 +1,19 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: query-operation
annotations:
kubernetes.io/ingress.class: nginx
spec:
rules:
- host: bal.perf.test
http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: query-operation-sv
port:
number: 9092
11 changes: 11 additions & 0 deletions load-tests/query-operation/deployment/kustomization.yaml
@@ -0,0 +1,11 @@
resources:
- query_operation.yaml
- ingress.yaml
- mssql_deployment.yml
patches:
- path: deployment-patch.yaml
target:
group: apps
version: v1
kind: Deployment
name: query-operation-deployment
80 changes: 80 additions & 0 deletions load-tests/query-operation/deployment/mssql_deployment.yml
@@ -0,0 +1,80 @@
## MSSQL data storage
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data-pvc
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mssql-deployment
spec:
selector:
matchLabels:
app: mssql
strategy:
type: Recreate
template:
metadata:
labels:
app: mssql
logs: "true"
spec:
containers:
- name: mssql-server
image: mcr.microsoft.com/mssql/server:2019-latest
lifecycle:
postStart:
exec:
command: [ "/bin/sh", "-c", "sleep 30; /opt/mssql-tools/bin/sqlcmd -l 30 -S localhost -U sa -P Test123# -e -Q 'CREATE DATABASE EXAMPLE_DB';"]
env:
- name: SA_PASSWORD
value: Test123#
- name: ACCEPT_EULA
value: "Y"
ports:
- containerPort: 1433
volumeMounts:
- name: data
mountPath: /var/lib/mssql
volumes:
- name: data
persistentVolumeClaim:
claimName: mssql-data-pvc
---
## Service
apiVersion: v1
kind: Service
metadata:
name: mssql-service
labels:
app: mssql-server
spec:
type: NodePort
ports:
- port: 1433
targetPort: 1433
protocol: TCP
selector:
app: mssql
---
apiVersion: v1
kind: Service
metadata:
name: mssql-deployment
spec:
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
type: LoadBalancer
---
Empty file.
70 changes: 70 additions & 0 deletions load-tests/query-operation/scripts/http-get-request.jmx
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="4.0" jmeter="4.0 r1823414">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Users" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">${__P(users)}</stringProp>
<stringProp name="ThreadGroup.ramp_time">${__P(rampUpPeriod,60)}</stringProp>
<boolProp name="ThreadGroup.scheduler">true</boolProp>
<stringProp name="ThreadGroup.duration">${__P(duration)}</stringProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="HTTPSampler.domain">${__P(host,localhost)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,9092)}</stringProp>
<stringProp name="HTTPSampler.protocol">${__P(protocol,http)}</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">customer?id=${random}</stringProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
<stringProp name="HTTPSampler.implementation">HttpClient4</stringProp>
<stringProp name="HTTPSampler.connect_timeout">10000</stringProp>
<stringProp name="HTTPSampler.response_timeout">30000</stringProp>
</HTTPSamplerProxy>
<hashTree>
<ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
<collectionProp name="Asserion.test_strings">
<stringProp name="49586">200</stringProp>
</collectionProp>
<stringProp name="Assertion.custom_message"></stringProp>
<stringProp name="Assertion.test_field">Assertion.response_code</stringProp>
<boolProp name="Assertion.assume_success">false</boolProp>
<intProp name="Assertion.test_type">16</intProp>
</ResponseAssertion>
<hashTree/>
</hashTree>
<RandomVariableConfig guiclass="TestBeanGUI" testclass="RandomVariableConfig" testname="Random Variable" enabled="true">
<stringProp name="maximumValue">8</stringProp>
<stringProp name="minimumValue">1</stringProp>
<stringProp name="outputFormat">0</stringProp>
<boolProp name="perThread">true</boolProp>
<stringProp name="randomSeed">1</stringProp>
<stringProp name="variableName">random</stringProp>
</RandomVariableConfig>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
21 changes: 21 additions & 0 deletions load-tests/query-operation/scripts/run.sh
@@ -0,0 +1,21 @@
#!/bin/bash -e
# Copyright 2021 WSO2 Inc. (http://wso2.org)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ----------------------------------------------------------------------------
# Execution script for ballerina performance tests
# ----------------------------------------------------------------------------
set -e
source base-scenario.sh
jmeter -n -t "$scriptsDir/"http-get-request.jmx -l "$resultsDir/"original.jtl -Jusers="$concurrent_users" -Jduration=600 -Jhost=bal.perf.test -Jport=9092
7 changes: 7 additions & 0 deletions load-tests/query-operation/src/Ballerina.toml
@@ -0,0 +1,7 @@
[package]
org = "wso2"
name = "query_operation"
version = "0.0.1"

[build-options]
cloud = "k8s"
16 changes: 16 additions & 0 deletions load-tests/query-operation/src/Cloud.toml
@@ -0,0 +1,16 @@
[container.image]
repository = "ballerina"
name = "query_operation"

[cloud.deployment]
min_memory = "256Mi"
max_memory = "512Mi"
min_cpu = "200m"
max_cpu="1000m"

[cloud.deployment.autoscaling]
min_replicas = 1
max_replicas = 1

[[cloud.config.files]]
file="Config.toml"
5 changes: 5 additions & 0 deletions load-tests/query-operation/src/Config.toml
@@ -0,0 +1,5 @@
dbHost = "mssql-service"
dbUsername = "sa"
dbPassword = "Test123#"
dbName = "EXAMPLE_DB"
dbPort = 1433

0 comments on commit 9ecbe0d

Please sign in to comment.