diff --git a/tools/README.md b/tools/README.md index 8c8d8dbc2cd..8d5aa13e937 100644 --- a/tools/README.md +++ b/tools/README.md @@ -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:' - -# register some queues in JNDI using the form -# queue.[jndiName] = [physicalName] -queue.QueueName = -``` - -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 = jmx_file_location = jndi_file_location = thread_count = -ramp_time = message_size = -duration_of_the_test = +number_of_messages = throughput= ``` 4.Run ```./broker_performance_test.sh ``` @@ -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) diff --git a/tools/scripts/broker_performance_test.sh b/tools/scripts/broker_performance_test.sh index b81f3a1b5bc..19323b8d12e 100755 --- a/tools/scripts/broker_performance_test.sh +++ b/tools/scripts/broker_performance_test.sh @@ -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 @@ -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() @@ -56,21 +51,25 @@ 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 @@ -78,16 +77,20 @@ case ${user_inputs["message_size"]} in # 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 diff --git a/tools/scripts/resources/ballerina_message_broker_performance_test.properties b/tools/scripts/resources/ballerina_message_broker_performance_test.properties index 6355ed69671..0bf00745ca8 100644 --- a/tools/scripts/resources/ballerina_message_broker_performance_test.properties +++ b/tools/scripts/resources/ballerina_message_broker_performance_test.properties @@ -1,9 +1,8 @@ -jndi_file_location= -loop_count= -thread_count= -ramp_time= -jmx_file_location= +# this is not needed if jmeter_home is already configured jmeter_home= -message_size= -duration_of_the_test= -throughput= \ No newline at end of file +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 \ No newline at end of file diff --git a/tools/scripts/resources/jndi.properties b/tools/scripts/resources/jndi.properties index dd6dae8bce9..34dabdc33cf 100644 --- a/tools/scripts/resources/jndi.properties +++ b/tools/scripts/resources/jndi.properties @@ -1,7 +1,7 @@ # register some connection factories # connectionfactory.[jndiname] = [ConnectionURL] -connectionfactory.QueueConnectionFactory = +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.QueueName = micro_benchmark_queue diff --git a/tools/scripts/test_plan/ballerina_message_broker_performance_test.jmx b/tools/scripts/test_plan/ballerina_message_broker_performance_test.jmx index 6017f8b98c8..8dabcd8b1e0 100644 --- a/tools/scripts/test_plan/ballerina_message_broker_performance_test.jmx +++ b/tools/scripts/test_plan/ballerina_message_broker_performance_test.jmx @@ -16,10 +16,10 @@ continue false - -1 + ${__P(LOOP_COUNT,1)} ${__P(THREAD_COUNT,1)} - ${__P(RAMP_TIME,0)} + 0 false @@ -50,15 +50,10 @@ - - 1 - ${__P(THROUGHPUT,1;)} - 5 - - + ${__P(THROUGHPUT,1;)} ${__P(THROUGHPUT,1;)} - ${__P(DURATION_OF_THE_TEST,900;)} + ${__P(DURATION_OF_THE_TEST,900;)}