Skip to content

Commit

Permalink
Merge pull request #2069 from AzeemMuzammil/fb-access-log-load-test
Browse files Browse the repository at this point in the history
Add load-test for Http AccessLog
  • Loading branch information
TharmiganK authored Jul 16, 2024
2 parents dc39a03 + 76b80c9 commit 6245acb
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 0 deletions.
14 changes: 14 additions & 0 deletions load-tests/accesslog_enabled/deployment/deployment-patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: "apps/v1"
kind: Deployment
metadata:
name: no-name
spec:
template:
metadata:
labels:
logs: "true"
spec:
containers:
- name: "accesslog_e-deployment"
imagePullPolicy: Always

24 changes: 24 additions & 0 deletions load-tests/accesslog_enabled/deployment/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: accesslog_enabled
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-passthrough: "true"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
rules:
- host: bal.perf.test
http:
paths:
- path: "/"
pathType: Prefix
backend:
service:
name: accesslog_e
port:
number: 9090
tls:
- hosts:
- "bal.perf.test"
11 changes: 11 additions & 0 deletions load-tests/accesslog_enabled/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resources:
- accesslog_enabled.yaml
- ingress.yaml
- netty-backend.yaml
patches:
- path: deployment-patch.yaml
target:
group: apps
version: v1
kind: Deployment
name: accesslog_e-deployment
35 changes: 35 additions & 0 deletions load-tests/accesslog_enabled/deployment/netty-backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: netty-backend
spec:
replicas: 1
selector:
matchLabels:
app: netty-backend
template:
metadata:
labels:
app: netty-backend
logs: "true"
spec:
containers:
- name: netty-container
image: ldclakmal/netty-echo-backend:latest
ports:
- containerPort: 8688
env:
- name: "SSL"
value: "true"

---
apiVersion: v1
kind: Service
metadata:
name: netty
spec:
type: ClusterIP
ports:
- port: 8688
selector:
app: netty-backend
1 change: 1 addition & 0 deletions load-tests/accesslog_enabled/results/summary.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Label,# Samples,Average,Median,90% Line,95% Line,99% Line,Min,Max,Error %,Throughput,Received KB/sec,Std. Dev.,Date,Payload,Users
80 changes: 80 additions & 0 deletions load-tests/accesslog_enabled/scripts/http-post-request.jmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?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>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request" enabled="true">
<elementProp name="HTTPsampler.Files" elementType="HTTPFileArgs">
<collectionProp name="HTTPFileArgs.files">
<elementProp name="${__P(payload)}" elementType="HTTPFileArg">
<stringProp name="File.path">${__P(payload, /home/anjana/repos/ballerina-performance/scripts/payloads/1024B.json)}</stringProp>
<stringProp name="File.paramname"></stringProp>
<stringProp name="File.mimetype"></stringProp>
</elementProp>
</collectionProp>
</elementProp>
<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,9090)}</stringProp>
<stringProp name="HTTPSampler.protocol">${__P(protocol,http)}</stringProp>
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
<stringProp name="HTTPSampler.path">${__P(path)}</stringProp>
<stringProp name="HTTPSampler.method">POST</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>
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager" enabled="true">
<collectionProp name="HeaderManager.headers">
<elementProp name="" elementType="Header">
<stringProp name="Header.name">Content-Type</stringProp>
<stringProp name="Header.value">application/json</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>
<hashTree/>
<ResponseAssertion guiclass="AssertionGui" testclass="ResponseAssertion" testname="Response Assertion" enabled="true">
<collectionProp name="Asserion.test_strings">
<stringProp name="-196708348">${__P(response_size)}</stringProp>
</collectionProp>
<stringProp name="Assertion.custom_message"></stringProp>
<stringProp name="Assertion.test_field">Assertion.response_data</stringProp>
<boolProp name="Assertion.assume_success">false</boolProp>
<intProp name="Assertion.test_type">16</intProp>
</ResponseAssertion>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>
22 changes: 22 additions & 0 deletions load-tests/accesslog_enabled/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/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-post-request.jmx -l "$resultsDir/"original.jtl -Jusers="$concurrent_users" -Jduration=3600 -Jhost=bal.perf.test -Jport=443 -Jprotocol=https -Jpath=passthrough $payload_flags
7 changes: 7 additions & 0 deletions load-tests/accesslog_enabled/src/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
org = "wso2"
name = "accesslog_enabled"
version = "0.0.1"

[build-options]
cloud = "k8s"
20 changes: 20 additions & 0 deletions load-tests/accesslog_enabled/src/Cloud.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[container.image]
repository= "ballerina"
name="h1_h1_passthrough"

[cloud.deployment]
min_memory="256Mi"
max_memory="1024Mi"
min_cpu="200m"
max_cpu="2000m"

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

[[cloud.secret.files]]
mount_dir="./security"
file="./security"

[[cloud.config.files]]
file="./Config.toml"
3 changes: 3 additions & 0 deletions load-tests/accesslog_enabled/src/Config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ballerina.http.accessLogConfig]
console = true
format = "json"
45 changes: 45 additions & 0 deletions load-tests/accesslog_enabled/src/accesslog_enabled.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org).
//
// WSO2 LLC. 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/http;

listener http:Listener securedEP = new (9090,
secureSocket = {
key: {
path: "./security/ballerinaKeystore.p12",
password: "ballerina"
}
},
httpVersion = "1.1"
);

final http:Client nettyEP = check new("https://netty:8688",
secureSocket = {
cert: {
path: "./security/ballerinaTruststore.p12",
password: "ballerina"
},
verifyHostName: false
},
httpVersion = "1.1"
);

service /passthrough on securedEP {
resource function post .(http:Request clientRequest) returns http:Response|error {
http:Response response = check nettyEP->forward("/service/EchoService", clientRequest);
return response;
}
}
Binary file not shown.
Binary file not shown.

0 comments on commit 6245acb

Please sign in to comment.