Custom Feeder based on data being dynamically populated

1,446 views
Skip to first unread message

Shawn Clark

unread,
Nov 13, 2014, 1:32:08 PM11/13/14
to gat...@googlegroups.com
Hi,

I have two scenarios being run at the same time. I need the data from one scenario to be fed into another scenario. The logic is that the one scenario is generating new random data and the service under test is returning unique identifiers for that data. The second scenario is to then modify that data. The information needed to run the scenario is the unique identifiers that were returned on the call in the first scenario. The feeder for the second scenario should randomly pick an identifier from the list of identifiers. I have the second scenario being delayed by a period of time so that there is time for enough unique identifiers to be added. Unfortunately I don't know how to do this with Gatling .feed() call. Anyone able to offer an example that I could work off?

Thanks

John Arrowwood

unread,
Nov 14, 2014, 11:07:03 AM11/14/14
to gat...@googlegroups.com
I'm curious: do you need two scenarios?  Or two steps in a single scenario?  that is, can you have a single scenario that first creates the random data, and then waits a short time, and then modifies it?

Really, what is the business process you are trying to model?

Shawn Clark

unread,
Nov 14, 2014, 1:14:01 PM11/14/14
to gat...@googlegroups.com
The model is whereby a user submits a piece of data for another user. That scenario has a high throughput. Occasionally the other user will mark something as being read. This happens at a lower throughput and at some random time after the data shows up. So with the two scenario model I can push through data at the required TPS and then another scenario can mark things as read at that required TPS. I have been doing this in the past by first pulling out a random list of identifiers and putting them into a csv file and using that as a feeder. That setup isn't the most convenient so I was looking for a way for the result of an http request in one scenario being the data for another scenario.

Excilys

unread,
Nov 14, 2014, 1:24:11 PM11/14/14
to gat...@googlegroups.com
I'd use something like a concurrent queue.


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shawn Clark

unread,
Nov 14, 2014, 1:30:49 PM11/14/14
to gat...@googlegroups.com
Do you have an example of how to set this up? I am guessing I would need to build my own custom feeder class and have the queue within there being fed from the one scenario. I am just not as familiar with how to do this with Gatling / Scala.

Stéphane Landelle

unread,
Nov 17, 2014, 6:29:23 AM11/17/14
to gat...@googlegroups.com
import java.util.concurrent.ConcurrentLinkedDeque
val queue = new ConcurrentLinkedDeque[Map[String, Any]]

def offer(record : Map[String, Any]) = exec { session =>
  queue.offer(record)
  session
}

import io.gatling.core.structure.ChainBuilder
def withPolledRecord(chain: ChainBuilder) = exec { session =>
  queue.poll() match {
    case null => session.set("emptyQueueFlag", true)
    case record => session.setAll(record).remove("emptyQueueFlag")
  }
}.asLongAs("emptyQueueFlag.exists()")(chain)

praveen sinha

unread,
Jun 5, 2016, 12:46:22 PM6/5/16
to Gatling User Group
Thanks, this answered my need as well with minor modifications. If someone is interested, the code is published here https://github.com/meetpraveen/gatling-custom-dsls/blob/master/README.md#producer-consumer-contract-prallel-scenarios-- .
Reply all
Reply to author
Forward
0 new messages