0

I am trying to capture the record which has been created on running of gatling simulation test.

My scenario is that

  • read json data from csv and publish to kafka which is consumed by microservice and store data into couchbase,

since kafka publishing message in asyn mode so there is no way we can get to know that how many record got created in data base.

is there any way in gatling to get data from couchabse and assert so that if record in couchbase not equal to the request then simulation should fail ?

val scn = scenario("Order test sceanrio")
        .feed(csv("TestOrder.csv").circular)
        .exec(ProducerBuilder[Array[Byte], Array[Byte]]())
         setUp(scn.inject(atOnceUsers(count))).protocols(kafkaProtocol)
         //.assertion(getCouchbaseOrderCount == count) // not supported by

gatling

Smit K
  • 121
  • 1
  • 7

1 Answers1

0

I Have resolved this issue by using tearDown in the simulation. Below is the tearDown code for gatling,

after {
println("**************** Asserting scenario *****************")

 assert(orderCount() == count)

}


def orderCount(): Int = {
val cluster = openConnection
val bucket: Bucket = cluster.openBucket("Order", "password");
println(bucket)
val query = "SELECT meta().id FROM `Order`"
Thread.sleep(1000)
val orderCount: Int = bucket.query(N1qlQuery.simple(query)).allRows().size();
println("  Order Count :: " + orderCount)
orderCount

}

Smit K
  • 121
  • 1
  • 7