Click here to Skip to main content
15,120,937 members
Articles / DevOps / Load Testing
Tip/Trick
Posted 21 Oct 2019

Stats

1.6K views

Chalba - Open Source Load Testing Tool

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
21 Oct 2019CPOL2 min read
Chalba is an open source hackable load testing tool. Chalab is inspired from jmeter, gatling, grinder like tool.

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.

Introduction

Chalba is an open source hackable load testing tool. Chalab is inspired from jmeter, gatling, grinder like tool.
Unlike jmeter, it doesn’t have GUI, you have to write the load code and the code is written in Java and thus enables you to leverage the full power of Java.

The best part is you don’t need any build tool. Just pass the Java file to it for execution. With the help of these, I can easily tweak my scripts in the linux box from where I am generating load.

I have been using chalba for creating complex load scenario that can't be created using jmeter.

Installing

  • Chalba support java 8 and JAVA_HOME must be set to the java JDK it won’t work with JRE
  • Visit https://buglens.com/ download package for your environment. It is written in Java so it will work in any platform which supports Java.
  • Extract the archive
  • Add bin directory to the path of your system
    • In Linux, add the full path of bin folder to path of ~/.profile
    • In Windows, add bin directory to the environment variable
  • Type chalba in terminal or command prompt.
  • chalba should get execute.

First Script

Now let's write our first load script in chalba. Chalba provides features to generate the boilerplate script.

chalba -newFile

It will generate the file name Task1.java in the current directory.

Java
package chalba;
import skd.chalba.common.*;
import skd.chalba.requests.*;
import skd.chalba.runner.*;
import skd.chalba.interfaces.*;

/**
 * This is the template File for writing the load script
 * Please follow the structure as described in this file
 *
 * @author sapan.dang
 */
@ThreadCount(1)
@ThreadSpawnDelay(100)
public class Task1 extends Task {

    // this constructor is required
    public Task1(TaskParams taskParams) {
    }

    //This method is executed after constructor
    //script must implement this method
    @Override
    public void run() {
        super.run();
        //executable method
        //it is good practice to write your code in other method
        mainLoop();
        _testCompleted(); //call when the test is complete
    }

    //Main Loop write your logic here
    public void mainLoop() {

        //Write your code in the try-catch block
        //to avoid any unexpected closure of the script
        try {
            //create GET request
            System.out.println("send get request");
            ResponseData googleResponse = requests.get("https://www.google.com/");
            System.out.println("response code " + googleResponse.code);

            //create async request
            requests.get("https://www.google.com/", new AsyncResponseCallback() {
                @Override
                public void onResponse(ResponseData arg0) {
                    System.out.println(" "+arg0.body);
                }
            });
        } catch (Exception e) {
            LOG(e);
        }
    }
}

The script is java class file. So you can code using any IDE, just add chalba.jar found inside the lib directory of chalba in the classpath of the IDE.

Here, @ThreadCount(1) specifies how many threads you want to start. @ThreadSpawnDelay(100) specifies the delay after each thread specified in ms.
If you are familiar with Java, it can be observed that the first constructor public Task1(TaskParams taskParams) is called after that public void run() is executed.

The script logic can be written in public void mainLoop() method.
_testCompleted(); is called after completion of the test.

Requests

chalba provides an easy to use API to generate the requests.
For get request requests.get(), it accepts the url, headers, query parameters as from the document.
For async request AsyncResponseCallback() to the same get method.

Currently, chalab supports only GET and POST methods.

Running the Script

To run the script, just pass the file name to chalba and it will execute the script.

chalba -f Task1.java

It will execute the Task1.java. chalba writes logs in chalba.log and reponses are logged in response.ctl. This is the csv file.

Analytics

Currently, chalba does not support out of the HTML reporting. However, you can use your own analytics tool to analyse the response.ctl file.

Chalaba documentation https://buglens.com/guide/guide/

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

hexgear
India India
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --