-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathBasicSimulation.scala
27 lines (21 loc) · 1.07 KB
/
BasicSimulation.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package io.gatling.simulation
import java.util
import io.gatling.core.Predef.Simulation
import io.gatling.core.Predef._
import io.gatling.data.generator.RandomDataGenerator
import io.gatling.kafka.{KafkaProducerBuilder, KafkaProducerProtocol}
import org.apache.kafka.clients.producer.ProducerConfig
import org.apache.kafka.common.serialization.StringSerializer
class BasicSimulation extends Simulation {
val kafkaTopic = "test_topic"
val kafkaBrokers = "localhost:9092"
val props = new util.HashMap[String, Object]()
props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkaBrokers)
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, classOf[StringSerializer])
val dataGenerator = new RandomDataGenerator[String, String]()
val kafkaProducerProtocol = new KafkaProducerProtocol[String, String](props, kafkaTopic,
dataGenerator)
val scn = scenario("Kafka Producer Call").exec(KafkaProducerBuilder[String, String]())
setUp(scn.inject(atOnceUsers(1))).protocols(kafkaProducerProtocol)
}