1

I want to write a gatling load test simulation class. I have three requests req1, req2 and req3. I want to be able to be able to perform a load test with 300 users ramped up over 5 seconds. i also need the test to run for 20 minutes totally.

Now i need the three requests to run simultaneously but with req1 90% throughput, 5% req2 and 5% req3. ex: if there are 100 requests, 90 must be of req1 and 5 of req2 and 5 of req3.

Here is my simulation class so far:

package simulations;

import io.gatling.core.Predef._ 
import io.gatling.http.Predef._
import scala.concurrent.duration._

class LoadSimulation extends Simulation{

    val httpConfig = http
        .baseURL("http://url.com")
        .acceptHeader("text/html,application/xhtml+xml,application/xml")

    val update = scenario("Update").exec(Api.update)
    val read= scenario("Read").exec(Api.read)
    val age= scenario("Age").exec(Api.age)

    setUp(
        postToChannel.inject(rampUsers(300) over (5 seconds))
        ).protocols(httpConf)
        .maxDuration(20 minutes)
}

object Api{
    val channelFeeder = csv(test.csv).random

    val update = feed(channelFeeder)
        .exec(http("Update")
        .get("/update?key=${key}&${url}")

    val read= feed(channelFeeder)
        .exec(http("Read")
        .get("/app/${id}/data/1/1.json?key=${key}")

    val age= feed(channelFeeder)
        .exec(http("Age")
        .get(/app/${id}/data/1/age?key=${key})
}

I'm not sure how to put these three apis in one scenario and run them with update(90), read(5) and age(5) throughputs respectively.

Any leads on this will be helpful.

Thanks

2 Answers 2

2

load-testing with Maven will require you to create something called a "pom" (Project Object Model) file. In the initial segment of the pom.xml file, you will have to define the dependencies you will be using as:

<dependencies>
   <dependency>
      ...
      <scope>test</scope>
   </dependency>
</dependencies>

In addition to declaring other plugins that would be used to assist the execution of the file:

<plugin>
   <groupId>io.gatling</groupId>
   <artifactId>gatling-maven-plugin</artifactId>
   <version>X.Y.Z</version>
</plugin>

You can define multiple plugin segments just like above as many as you need to justify the usage needed for the testing.

Now with this assumption, (i assume) you will be using Jenkins to utilize both Maven and Gatling plugins. Here is the Gatling documentation to creating pom.xml files: Link

Additional way as user666 has mentioned, you can 'Maven-ize' the process by splitting it up during pom file as includes or excludes respectively:

<configuration>
   <!--   ...  -->
   <runMultipleSimulations>true</runMultipleSimulations>
   <includes>
      <param>my.package.MySimu1</param>
      <param>my.package.MySimu2</param>
    </includes>
    <excludes>
      <param>my.package.MySimuNotToRun</param>
    </excludes>
 </configuration>

Edit: I guess i did misunderstood! I believe what you are looking for is having variety of scenarios as described:

setUp(scenario1.inject(rampUsers(300)over (5)). protocols(...),
      scenario2.inject(rampUsers(95) over (ramp seconds))
      .protocols(...)

You can check out more here: https://gatling.io/docs/current/general/simulation_setup/

Sign up to request clarification or add additional context in comments.

2 Comments

I have already done the pom changes. I was wondering how we distribute the requests into 90,5,5 respectively.
Edited, i believe what you are looking for is injection with scenario's during setup.
0

Think you have one thread only ..how will three sequential steps be separated ..one bad way to do that is to maintain a global variable and share it among all your threads .. now u can have short circuit logic that 90 request go to step 1 and so on .. however from performance testing point of view you should be running three different simulations and provide them the load you want rather than doing all together..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.