Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Add number_of_messages_parameter to the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hasithajayasundara committed Jul 11, 2018
1 parent 6fa4096 commit c72f243
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 63 deletions.
40 changes: 13 additions & 27 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,22 @@ This tool allows ballerina message broker developers to get an idea about the pe

## How to use

1.Copy following jars to JMETER_HOME/lib.
1. Copy following jars to JMETER_HOME/lib.

- andes-client-0.13.wso2v8.jar
- geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
- slf4j-1.5.10.wso2v1.jar
- andes-client-0.13.wso2v8.jar
- geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
- slf4j-1.5.10.wso2v1.jar

2.Create jndi.properties file
2. Create a queue named micro_benchmark_queue in broker

```properties
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:<port>'

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.QueueName = <queue_name>
```

3.Download the jmx file in test_plan folder to your local machine

4.Create a properties files including following details.
3. Include the following details in ballerina_message_broker_performance_test.properties file which is located at resources/.
```properties
jmeter_home = <jmeter_home>
jmx_file_location = <jmx_file_location>
jndi_file_location = <jndi_file_location>
thread_count = <number_of_threads>
ramp_time = <ramp_time>
message_size = <size_of_the_message>
duration_of_the_test = <test_time_in_seconds>
number_of_messages = <number_of_messages_need_to_be_published>
throughput= <throughput_need_to_be_maintained>
```
4.Run ```./broker_performance_test.sh <location_of_properties_file>```
Expand All @@ -48,19 +35,18 @@ Upon completion of the test,you'll be directed to a web interface which contains

## Special Notes

- Use 1,10,100,1000 as inputs to the message_size paramter in properties file.
- 1 = 1 KB message
- 10 = 10 KB message
- 100 = 100KB message
- 1000 = 1MB message
- Use 1KB , 10KB , 100KB , 1MB as inputs to the message_size paramter in properties file.
- 1KB = 1 KB message
- 10KB = 10 KB message
- 100KB = 100KB message
- 1MB = 1MB message

- Following values are used as default values for some of the above mentioned parameters.
- jmx_file_location = test_plan/ballerina_message_broker_performance_test.jmx
- jndi_file_location = resources/jndi.properties
- thread_count = 1
- ramp_time = 0
- message_size = 10
- duration_of_the_test = 900 (900 seconds = 15 minutes)
- number_of_messages = 1000000
- throughput = 5000 (5000 messages/seconds)


Expand Down
37 changes: 20 additions & 17 deletions tools/scripts/broker_performance_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
#!/bin/bash

# deleting existing folders
if [ -e logs/ ];
if [ ! -e target/ ];
then
rm -r logs/
fi

if [ -e report/ ];
then
rm -r report/
mkdir target
fi

# get the properties file location
Expand All @@ -36,7 +31,7 @@ if [ "$properties_file_location" == '' ]
fi

# hash-map to store user desired parameters
declare -A user_inputs=(["jmeter_home"]="" ["jndi_file_location"]="resources/jndi.properties" ["jmx_file_location"]="test_plan/ballerina_message_broker_performance_test.jmx" ["thread_count"]="10000" ["loop_count"]="1" ["ramp_time"]="0" ["duration_of_the_test"]="900" ["throughput"]="5000" ["message_size"]="10")
declare -A user_inputs=(["jmeter_home"]="" ["jndi_file_location"]="resources/jndi.properties" ["jmx_file_location"]="test_plan/ballerina_message_broker_performance_test.jmx" ["thread_count"]="1" ["number_of_messages"]="1000000" ["throughput"]="5000" ["message_size"]="10KB")

# Method to extract values from property file
getProperty()
Expand All @@ -56,38 +51,46 @@ do
done

# Summarizing inputs
echo The test plan is set to loop count - ${user_inputs["loop_count"]}, thread count - ${user_inputs["thread_count"]},ramp time - ${user_inputs["ramp_time"]} and throughput - ${user_inputs["throughput"]}
echo JMX file location is set to - ${user_inputs["jmx_file_location"]}
echo JNDI properties file location is set to - ${user_inputs["jndi_file_location"]}
echo Jmeter home is set to - ${user_inputs["jmeter_home"]}
echo Starting test process with ${user_inputs["number_of_messages"]} messages and a and throughput - ${user_inputs["throughput"]}

# calculate loop count
loop_count=$(echo "${user_inputs["number_of_messages"]}/${user_inputs["thread_count"]}+1" | bc)
duration_of_the_test=$(echo "${user_inputs["number_of_messages"]}/${user_inputs["throughput"]}" | bc)

# variable to store message math
text_message_file_location="sample_messages/1kB.json"
case ${user_inputs["message_size"]} in
10)
10KB)
text_message_file_location="sample_messages/10kB.json"
;;
100)
100KB)
text_message_file_location="sample_messages/100kB.json"
;;
1000)
1MB)
text_message_file_location="sample_messages/1MB.json"
;;
esac

# retrieve the message
message=`cat $text_message_file_location`

# create folder to store report files
folder_name=$(date '+%d-%m-%Y-%H-%M-%S')
mkdir target/"$folder_name"

# execute jmeter command
if [ ${user_inputs["jmeter_home"]} != '' ]
then
# if user specified jmeter home
${user_inputs["jmeter_home"]}/jmeter -n -t ${user_inputs["jmx_file_location"]} -DTHREAD_COUNT=${user_inputs["thread_count"]} -DRAMP_TIME=${user_inputs["ramp_time"]} -DDURATION_OF_THE_TEST=${user_inputs["duration_of_the_test"]} -DJNDI_URL=${user_inputs["jndi_file_location"]} -DTHROUGHPUT=${user_inputs["throughput"]} -DMESSAGE="$message" -l logs/test_results.jtl -e -o report/
${user_inputs["jmeter_home"]}/jmeter -n -t ${user_inputs["jmx_file_location"]} -DTHREAD_COUNT=${user_inputs["thread_count"]} -DDURATION_OF_THE_TEST=$duration_of_the_test -DLOOP_COUNT=$loop_count -DJNDI_URL=${user_inputs["jndi_file_location"]} -DTHROUGHPUT=${user_inputs["throughput"]} -DMESSAGE="$message" -l target/"$folder_name"/log/test_results.jtl -e -o target/"$folder_name"/report/
else
# if jmeter_home is already configured
jmeter -n -t ${user_inputs["jmx_file_location"]} -DTHREAD_COUNT=${user_inputs["thread_count"]} -DRAMP_TIME=${user_inputs["ramp_time"]} -DDURATION_OF_THE_TEST=${user_inputs["duration_of_the_test"]} -DJNDI_URL=${user_inputs["jndi_file_location"]} -DTHROUGHPUT=${user_inputs["throughput"]} -DMESSAGE="$message" -l logs/test_results.jtl -e -o report/
jmeter -n -t ${user_inputs["jmx_file_location"]} -DTHREAD_COUNT=${user_inputs["thread_count"]} -DLOOP_COUNT=$loop_count -DDURATION_OF_THE_TEST=$duration_of_the_test -DJNDI_URL=${user_inputs["jndi_file_location"]} -DTHROUGHPUT=${user_inputs["throughput"]} -DMESSAGE="$message" -l target/"$folder_name"/log/test_results.jtl -e -o target/"$folder_name"/report/
fi

# execute jmeter command

# open report
xdg-open report/index.html
xdg-open target/"$folder_name"/report/index.html
exit
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
jndi_file_location=<jndi_file_location>
loop_count=<loop_count>
thread_count=<thread_count>
ramp_time=<ramp_time>
jmx_file_location=<jmx_file_location>
# this is not needed if jmeter_home is already configured
jmeter_home=<jmeter_home>
message_size=<message_size>
duration_of_the_test=<duration_of_the_test>
throughput=<throughput>
jmx_file_location=test_plan/ballerina_message_broker_performance_test.jmx
jndi_file_location=resources/jndi.properties
thread_count=1
number_of_messages=10000
throughput=5000
message_size=10KB
4 changes: 2 additions & 2 deletions tools/scripts/resources/jndi.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# register some connection factories
# connectionfactory.[jndiname] = [ConnectionURL]
connectionfactory.QueueConnectionFactory = <connection_url>
connectionfactory.QueueConnectionFactory =amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672'

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.QueueName = <queue_name>
queue.QueueName = micro_benchmark_queue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<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>
<stringProp name="LoopController.loops">${__P(LOOP_COUNT,1)}</stringProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">${__P(THREAD_COUNT,1)}</stringProp>
<stringProp name="ThreadGroup.ramp_time">${__P(RAMP_TIME,0)}</stringProp>
<stringProp name="ThreadGroup.ramp_time">0</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
Expand Down Expand Up @@ -50,15 +50,10 @@
<hashTree/>
<kg.apc.jmeter.timers.VariableThroughputTimer guiclass="kg.apc.jmeter.timers.VariableThroughputTimerGui" testclass="kg.apc.jmeter.timers.VariableThroughputTimer" testname="jp@gc - Throughput Shaping Timer" enabled="true">
<collectionProp name="load_profile">
<collectionProp name="308127476">
<stringProp name="49">1</stringProp>
<stringProp name="216161393">${__P(THROUGHPUT,1;)}</stringProp>
<stringProp name="53">5</stringProp>
</collectionProp>
<collectionProp name="2008970322">
<collectionProp name="-1265899165">
<stringProp name="216161393">${__P(THROUGHPUT,1;)}</stringProp>
<stringProp name="216161393">${__P(THROUGHPUT,1;)}</stringProp>
<stringProp name="-1405926517">${__P(DURATION_OF_THE_TEST,900;)}</stringProp>
<stringProp name="1056992630">${__P(DURATION_OF_THE_TEST,900;)}</stringProp>
</collectionProp>
</collectionProp>
</kg.apc.jmeter.timers.VariableThroughputTimer>
Expand Down

0 comments on commit c72f243

Please sign in to comment.