-
Notifications
You must be signed in to change notification settings - Fork 9
Generating Feed Data
Gatling Feeders can be either from a file such as a csv or generated in code. This page explains how to generate your own feeder values. If you want to learn more about Gatling's built-in feeders visit the Gatling Docs page at https://gatling.io/docs/2.3/session/feeder/.
A simple feed looks like the following:
def write = Iterator.continually(getRowData)
def getRowData = {
Map(
"order_no" -> UUID.randomUUID(),
"numbers" -> Set(1, 2, 3)
)
}
The Iterator.continually()
method will call the getRowData every time the feeder is called as part of the
When creating values in the Map it not necessary to convert to Java type or most CQL types. The Gatling DSE Plugin can auto-convert many types such as a Scala Set to a Java Set. To see all of the auto conversions supported visit: CQL Auto Type Conversion
Faker is a Java version of Ruby library that allows for easy functional faked data to be inserted into DSE. To read all of the methods available visit the java-faker project on Github.
Example
faker.bothify("???###???") -> "ase342dfs"
Create a Weighted Random list and get an item on each usage. This is used to create a random generator with the ability to set a percentage of time each value should be returned.
This class should be created at the Feeder class level and use .getItem
in the Feeder map. To create a value in the list use a tuple with the (value, percentage) format example: ("orca", 60.0)
. The value can be any Scala type allowing for chaining of WeightedRandomGenerator and getRandom
function.
Example
val randomAnimal = new WeightedRandomGenerator(List(("orca", 60.0), ("cat", 40.0)))
randomAnimal.getItem -> "orca"
Select a random value from a Sequence, List or Array.
Example
getRandom(Seq(1, 2, 3)) -> 2
Converts a Scala Case class or Object into a JSON string.
Example
case class Example(test: String, value: Int)
getJsonString(Example("key", 2)) -> {"test": "key", "value": 2}
Strip char from string.
Example
stripChar("2d6a0d3c-a416-40bd-afe8-3bab77da3f63", "-", "") -> 2d6a0d3ca41640bdafe83bab77da3f63
Get current timestamp
Example
getCurrentTimestamp -> 2016-11-16 06:43:19.769
Get a random timestamp between dates provided
Example
getRandomTimestamp(2012-01-01 00:00:00, 2017-01-01 00:00:00) -> 2016-11-12 03:34:22
Alias for faker.commerce.price.toFloat
Example
getPrice -> 10.0
Get a random epoch value between 2012-01-01 00:00:00 and 2017-01-01 00:00:00
Example
getRandomEpoch -> 1454284800
Alias for UUIDs.random()
Example
getTimeUuid() -> 2d6a0d3c-a416-40bd-afe8-3bab77da3f63
Get a timeuuid using the current timestamp. Alias for DataStax Drivers UUIDs.timeBased()
Example
getTimeUuid() -> ff2b3e52-cd9c-11e7-abc4-cec278b6b50a
Generate random JSON string of preset size (1k, 10k, 55k) or a custom size using generate()
. This is useful for simulating large text strings with structure into DSE.
Example
jsonDataGenerator.generate(15) -> "[{"_id":"57bdd47be9fea34733fbfc49","index":0,"guid":"645bb20a-26c3-41c3-b50a-61123dbc6404"..."
Getting Started
Feeds
Fetching Base Data
Load Generators
Simulations
- CQL Executors
- Simulation Writing Shortcuts
- Using Custom ClusterBuilder Settings
- Using Client to Node SSL
Advanced Topics
- Dependent Queries
- Using Graphite and Grafana
- Debugging Simulations
- Adjusting input from Feed Before Executing a Query
Archived (v1.0) Topics