How can I performance test using shell scripts - tools and techniques?

bash curl load testing
automated testing using unix shell scripting
unit testing shell scripts
how to test files in a shell script
shell script generator
shell test
jenkins unit test shell script
shell script formatter

I have a system to which I must apply load for the purpose of performance testing. Some of the load can be created via LoadRunner over HTTP.

However in order to generate realistic load for the system I also need to simulate users using a command line tool which uses a non HTTP protocol* to talk to the server.

* edit: actually it is HTTP but we've been advised by the vendor that it's not something easy to record/script and replay. So we're limited to having to invoke it using the CLI tool.

I have the constraint of not having the licences for LoadRunner to do this and not having the time to put the case to get the license.

Therefore I was wondering if there was a tool that I could use to control the concurrent execution of a collection of shell scripts (it needs to run on Solaris) which will be my transactions. Ideally it would be able to ramp up in accordance with a predetermined scehdule.

I've had a look around and can't tell if JMeter will do the trick. It seems very web oriented.

If all you need is starting a bunch of shell scripts in parallel, you can quickly create something of your own in perl with fork, exec and sleep.

#!/usr/bin/perl

for $i (1..1000)
{   
    if (fork == 0)
    {
        exec ("script.sh");
        exit;
    }

    sleep 1;
}

Testing Your Shell Scripts, with Bats | by Tim Perry, Many of the tools and techniques you might be used to aren't nearly as effective In shell scripts though, testing is typically an afterthought. 'file' — this is a Bats command to let you easily load files, here the load.sh scripts� Enterprise-class load testing tools: They usually come with capture/playback facility. They support a large number of protocols. They can simulate an exceptionally large number of users. How to do Load Testing. The load testing process can be briefly described as below - Create a dedicated Test Environment for load testing; Determine the following

For anyone interested I have written a Java tool to manage this for me. It references a few files to control how it runs:

1) Schedules File - defines various named lists of timings which controls the length of sequential phases.

e.g. MAIN,120,120,120,120,120

This will result in a schedule named MAIN which has 5 phases each 120 seconds long.

2) Transactions File - defines transactions that need to run. Each transaction has a name, a command that should be called, boolean controlling repetition, integer controlling pause between repetitions in seconds, data file reference,schedule to use and increments.

e.g. Trans1,/path/to/trans1.ksh,true,10,trans1.data.csv,MAIN,0,10,0,10,0

This will result in a transaction running trans1.ksh, repeatedly with a pause of 10 seconds between repetitions. It will reference the data in trans1.data.csv. During phase 1 it will increment the number of parallel invocations by 0, phase 2 will add 10 parallel invocations, phase 3 none added and so on. Phase times are taken from the schedule named MAIN.

3) Data Files - as referenced in the transaction file, this will be a CSV with a header. Each line of data will be passed to subsequent invocations of the transaction.

e.g.

HOSTNAME,USERNAME,PASSWORD
server1,jimmy,password123
server1,rodney,ILoveHorses

These get passed to the transaction scripts via environment variables (e.g. PASSWORD=ILoveHorses), a bit klunky, but workable.

My Java simply parses the config files, sets up a manager thread per transaction which itself takes care of setting up and starting executor threads in accordance with the configuration. Managers take care of adding executors linearly so as not to totally overload it.

When it runs, it just reports every second on how many workers each transaction has running and which phase it's in.

It was a fun little weekend project, it's certainly no load runner and I'm sure there are some massive flaws in it that I'm currently blissfully unaware of, but it seems to do ok.

So in summary the answer here was to "roll ya own".

Shell Tools and Scripting � the missing semester of your cs education, As with most programming languages, bash supports control flow techniques many comparisons of this sort - you can find a detailed list in the manpage for test . This makes functions slightly faster to load, but whenever you change them� Provides expertise with performance testing procedures, guidelines and industry best practices. Develops effective performance test performance automation scripts using performance tools and techniques to simulate large enterprise environments, such Jmeter, Gatling, or similar tools.

You can use bellow script to trigger load test for HTTP/S requests,

#!/bin/bash

#define variables

set -x # run in debug mode
DURATION=60 # how long should load be applied ? - in seconds
TPS=20 # number of requests per second
end=$((SECONDS+$DURATION))
#start load
while [ $SECONDS -lt $end ];
do
        for ((i=1;i<=$TPS;i++)); do
                curl -X POST <url> -H 'Accept: application/json' -H 'Authorization: Bearer xxxxxxxxxxxxx' -H 'Content-Type: application/json' -d '{}' --cacert /path/to/cert/cert.crt -o /dev/null -s -w '%{time_starttransfer}\n' >> response-times.log &
        done
        sleep 1
done
wait
#end load
echo "Load test has been completed"

You may refer this for more information

Getting started with shell scripting, Learn how to create, test, and debug scripts with our getting started tutorial. users to leverage existing utilities to create complex and customized tools. In the for this everyday POSIX programming method is the shell script. On windows, testing on JMeter can be initiated using the jmeter.bat file, and on Unix/Linux, by clicking on Jmeter Shell Scripts. Robust Reporting: JMeter can generate the effective reporting. The test result can be visualized by using Graph, Chart, and Tree View. JMeter supports different formats for reporting like text, XML, HTML, and JSON.

Automating with Shell Scripting, The commands in a shell script are the same as you would use on the command line. NOTE: All of the tools that we will be using in this workflow have been reference sequence, method of alignment, etc., this will change depending on the Start IGV; Load the genome file into IGV using the "Load Genomes from File. MySQL Performance Tuning: Tips, Scripts and Tools July 18, 2017 by Hayden James, in Blog Linux. With MySQL, common configuration mistakes can cause serious performance problems. In fact, if you mis-configure just one of the many config parameters, it can cripple performance!

ShellCheck – shell script analysis tool, ShellCheck is an open source static analysis tool that automatically finds bugs in your shell scripts. Luckily, testers don’t need to pick just one. Test scenarios, test cases, and test scripts can be used in tandem so that testers can tune test management to the varying skill levels and domain knowledge across a group. Have some tasks that need to be repeated regularly and a pair of hands available? Try using a test script.

Optimizations, Most shell scripts are quick 'n dirty solutions to non-complex problems. Use builtin commands in preference to system commands. Math tests math via $(( )) real 0m0.294s user 0m0.288s sys 0m0.008s math When overwriting values in a numeric array, there is a significant performance penalty vs. associative arrays. Tools and techniques used to test coreutils. Detailed here are some of the tools and techniques we use to test the GNU coreutils project, which should present some useful ways to automate the use of tools like gdb, strace, valgrind, sed, grep, or the coreutils themselves etc., either for testing or for other applications.

Comments
  • What's the non-HTTP protocol you need to use - is it a standard protocol or something home grown ? This will help narrow down the list of available tools.
  • I know that I could fall back on this kind of arrangement, but ideally I'd like to be able to get configure it to ramp up according to a predefined schedule. For example: start with 50 instances of script.sh running for 5 minutes, then after that time execute a further 50, and so on. I can code that in perl too but I'm kinda hoping that there's something that can do this for me :)