Skip to content

Commit

Permalink
Add load tests implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
SasinduDilshara committed Jul 17, 2024
1 parent 463c3a8 commit 5744ce9
Show file tree
Hide file tree
Showing 24 changed files with 20,371 additions and 742 deletions.
13 changes: 13 additions & 0 deletions load-tests/parse-stream/deployment/deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: "apps/v1"
kind: Deployment
metadata:
name: no-name
spec:
template:
metadata:
labels:
logs: "true"
spec:
containers:
- name: "csv-parse-stream-deployment"
imagePullPolicy: Always
10 changes: 10 additions & 0 deletions load-tests/parse-stream/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resources:
- csv_parse_stream.yaml
- ingress.yaml
patches:
- path: deployment-patch.yaml
target:
group: apps
version: v1
kind: Deployment
name: csv-parse-stream-deployment
41 changes: 41 additions & 0 deletions load-tests/parse-stream/scripts/http_parse_stream.jmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.3">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="http_get_parse_stream">
<boolProp name="TestPlan.serialize_threadgroups">true</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group">
<boolProp name="ThreadGroup.delayedStart">true</boolProp>
<intProp name="ThreadGroup.num_threads">1</intProp>
<intProp name="ThreadGroup.ramp_time">5</intProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller">
<stringProp name="LoopController.loops">100</stringProp>
<boolProp name="LoopController.continue_forever">false</boolProp>
</elementProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
<stringProp name="HTTPSampler.domain">${__P(host,localhost)}</stringProp>
<stringProp name="HTTPSampler.port">${__P(port,9091)}</stringProp>
<stringProp name="HTTPSampler.protocol">${__P(protocol,http)}</stringProp>
<stringProp name="HTTPSampler.path">BalPerformance/parse</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<stringProp name="HTTPSampler.method">GET</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">false</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
<collectionProp name="Arguments.arguments"/>
</elementProp>
</HTTPSamplerProxy>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
23 changes: 23 additions & 0 deletions load-tests/parse-stream/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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.
#
# ----------------------------------------------------------------------------
# Execusion script for ballerina performance tests
# ----------------------------------------------------------------------------
set -e
source base-scenario.sh

jmeter -n -t "$scriptsDir/"http_parse_stream.jmx -l "$resultsDir/"summary.csv -Jusers=2 -Jduration=3600 -Jhost= -Jport=9091 -Jprotocol=http -Jpath=BalPerformance/parse $payload_flags
jmeter -n -t "$scriptsDir/"http-post-request.jmx -l "$resultsDir/"original.jtl -Jusers="$concurrent_users" -Jduration=1200 -Jhost=csv-parse-strea-svc.default.svc.cluster.local -Jport=9090 -Jprotocol=http -Jpath=csv-parse-strea $payload_flags
14 changes: 14 additions & 0 deletions load-tests/parse-stream/src/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
org = "wso2"
name = "csv_parse_stream"
version = "0.0.1"

[build-options]
observabilityIncluded = false
cloud = "k8s"

[[dependency]]
org = "ballerina"
name = "data.csv"
version = "0.1.0"
repository="local"
20 changes: 20 additions & 0 deletions load-tests/parse-stream/src/Cloud.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[container.image]
repository= "ballerina"
name="csv_parse_stream"

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

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

[[container.copy.files]]
sourceFile="./resources/input.csv"
target="/home/ballerina/resources/input.csv"

[settings]
buildImage=false
28 changes: 28 additions & 0 deletions load-tests/parse-stream/src/app.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2021 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you 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.

import ballerina/io;
import ballerina/http;
import ballerina/data.csv as csv;

final stream<byte[], io:Error?> csvByteStream = check io:fileReadBlocksAsStream("resources/input.csv");

service http:Service /BalPerformance on new http:Listener(9091) {
resource function get parse(http:Caller caller, http:Request req) returns error? {
anydata[][] result = check csv:parseStreamToList(csvByteStream);
check caller->respond(result);
}
}
Loading

0 comments on commit 5744ce9

Please sign in to comment.