Passing arguments between Gatling scenarios and simulation

SemBY

I'm current creating some Gatling simulation to test a REST API. I don't really understand Scala.

I've created a scenario with several exec and pause;

object MyScenario { 

  val ccData = ssv("cardcode_fr.csv").random
  val nameData = ssv("name.csv").random
  val mobileData = ssv("mobile.csv").random
  val emailData = ssv("email.csv").random
  val itemData = ssv("item_fr.csv").random  

  val scn = scenario("My use case")
    .feed(ccData)
    .feed(nameData)
    .feed(mobileData)
    .feed(emailData)
    .feed(itemData)
    .exec(
      http("GetCustomer")
        .get("/rest/customers/${CardCode}")
        .headers(Headers.headers)
        .check(
          status.is(200)
        )
     )
     .pause(3, 5)
     .exec(
      http("GetOffers")
        .get("/rest/offers")
        .queryParam("customercode", "${CardCode}")
        .headers(Headers.headers)
        .check(
          status.is(200)
        )
      )
}

And I've a simple Simulation :

class MySimulation extends Simulation {
  setUp(MyScenario.scn
    .inject(
        constantUsersPerSec (1 ) during (1)))
    .protocols(EsbHttpProtocol.httpProtocol)
    .assertions(
      global.successfulRequests.percent.is(100))

}

The application I'm trying to simulate is a multilocation mobile App, so I've prepared a set of samples data for each Locale (US, FR, IT...)

My REST API handles all the locales, therefore I want to make the simulation concurrently execute several instances of MyScenario, each with a different locale sample, to simulate the global load.

Is it possible to execute my simulation without having to create/duplicate the scenario and change the val ccData = ssv("cardcode_fr.csv").random for each one?

Also, each locale has its own load, how can I create a simulation that takes a single scenario and executes it several times concurrently with a different load and feeders?

Thanks in advance.

childofsoong

From what you've said, I think this may be a good approach:

Start by grouping your data in such a way that you can look up each item you want to send based on the current locale. For this, I would recommend using a Map that matches a locale string (such as "FR") to the item that matches that locale for the field you're looking to fill in. Then, at the start of each iteration of the scenario, you just pick which locale you want to use for the current iteration from a list. It would look something like this:

val locales = List("US", "FR", "IT")
val names = Map( "US" -> "John", "FR" -> "Pierre", "IT" -> "Guillame")

object MyScenario {
    //These two lines pick a random locale from your list
    val random_index = rand.nextInt(locales.length);
    val currentLocale = locales(random_index);
    //This line gets the name
    val name = names(currentLocale)
    //Do the rest of your logic here
}

This is a very simplified example - you'll have to figure out how you actually want to retrieve the data from files and put it into a Map structure, as I assume you don't want to hard code every item for every field into your code.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Passing arguments between Gatling scenarios and simulation

From Dev

passing arguments between files

From Dev

Passing arguments between procedures

From Dev

Conditionals based on Gatling scenarios

From Java

Gatling load testing and running scenarios

From Dev

passing arguments between c and inline assembly

From Dev

Difference between "$@" and "$*" when passing arguments to bash function

From Java

Passing arguments with spaces between (bash) script

From Dev

passing arguments between c and inline assembly

From Dev

Passing arguments back and forth between PHP and shell

From Dev

Passing In Config In Gatling Tests

From Dev

Is there a way to configure Gatling from within a Simulation?

From Dev

Difference between passing arguments to define_method and to the following block?

From Dev

How can i share an auth token over multiple gatling scenarios?

From Dev

Gatling: Can ramping up of individual scenarios be done just like the users?

From Dev

Passing arguments by reference in curried arguments

From Dev

Templates: Passing the arguments in a template as arguments

From Dev

Passing arguments by reference in curried arguments

From Dev

Gatling: meaning of all fields in simulation.log file

From Dev

Sharing example tables between scenarios

From Dev

Difference between these two OOP scenarios?

From Dev

Passing Arguments to Shell Script

From Java

Passing arguments to selector in Swift

From Dev

Passing arguments into partials automatically

From Dev

Passing a function and arguments to a thread

From Dev

Powershell with Robocopy and Arguments Passing

From Dev

Passing variable arguments to a delegate

From Dev

passing arguments to nosetest

From Dev

Passing arguments to decontext decorator

Related Related

  1. 1

    Passing arguments between Gatling scenarios and simulation

  2. 2

    passing arguments between files

  3. 3

    Passing arguments between procedures

  4. 4

    Conditionals based on Gatling scenarios

  5. 5

    Gatling load testing and running scenarios

  6. 6

    passing arguments between c and inline assembly

  7. 7

    Difference between "$@" and "$*" when passing arguments to bash function

  8. 8

    Passing arguments with spaces between (bash) script

  9. 9

    passing arguments between c and inline assembly

  10. 10

    Passing arguments back and forth between PHP and shell

  11. 11

    Passing In Config In Gatling Tests

  12. 12

    Is there a way to configure Gatling from within a Simulation?

  13. 13

    Difference between passing arguments to define_method and to the following block?

  14. 14

    How can i share an auth token over multiple gatling scenarios?

  15. 15

    Gatling: Can ramping up of individual scenarios be done just like the users?

  16. 16

    Passing arguments by reference in curried arguments

  17. 17

    Templates: Passing the arguments in a template as arguments

  18. 18

    Passing arguments by reference in curried arguments

  19. 19

    Gatling: meaning of all fields in simulation.log file

  20. 20

    Sharing example tables between scenarios

  21. 21

    Difference between these two OOP scenarios?

  22. 22

    Passing Arguments to Shell Script

  23. 23

    Passing arguments to selector in Swift

  24. 24

    Passing arguments into partials automatically

  25. 25

    Passing a function and arguments to a thread

  26. 26

    Powershell with Robocopy and Arguments Passing

  27. 27

    Passing variable arguments to a delegate

  28. 28

    passing arguments to nosetest

  29. 29

    Passing arguments to decontext decorator

HotTag

Archive