2

I have been searching on google for a while whether is their any plugin in loadrunner to test Kafka cluster but found nothing. I realized lately that we can a send message through a java program with help of packages like apache.kafka.clients

I have created a new Java Virtual user.

This is the simple code that i have used producing messaging:

import lrapi.lr;
import java.util.*;
import org.apache.kafka.clients.producer.*;

public class Actions
{

    public int init() throws Throwable {
        return 0;
    }//end of init


    public int action() throws Throwable {
        String topicName = "loadrunnertest";
      String key = "Key1";
      String value = "hello Vishal";


      Properties props = new Properties();
      props.put("bootstrap.servers", "localhost:9092");
      props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");         
      props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");

      Producer<String, String> producer = new KafkaProducer <String,String>(props);

      ProducerRecord<String, String> record = new ProducerRecord<String,String>(topicName,key,value);
      producer.send(record);           
      producer.close();

      System.out.println("SimpleProducer Completed.");
      return 0;
    }//end of action


    public int end() throws Throwable {
        return 0;
    }//end of end
}

Add all required jars in classpath under runtime settings.
By this i am able to connect to Kafka cluster.
As i have used java to send request will it impact on end results?

Vishal Chepuri
  • 306
  • 5
  • 26

1 Answers1

7

Kafka already comes with load testing tools such as bin/kafka-producer-perf-test.sh and bin/kafka-consumer-perf-test.sh

If you look at these shell scripts you will see that they are just simple wrappers on the undertaking performance testing classes shipped with Kafka which can be called directly from Loadrunner or any Java app as in the example below from Jay Kreps' Kafka benchmarking blog post (see https://engineering.linkedin.com/kafka/benchmarking-apache-kafka-2-million-writes-second-three-cheap-machines)

bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100
-1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
Hans Jespersen
  • 8,024
  • 1
  • 24
  • 31