gradlew gatlingRun doesn't run any test
Asked Answered
S

5

9

I am trying to perform a load testing with gradle-gattling, below are my build.gradle and my BasicSimulation.scala

plugins {
    id "com.github.lkishalmi.gatling" version "3.0.2"
}
repositories {
    mavenCentral()
}
apply plugin: 'scala'
dependencies {
    testCompile 'junit:junit:4.12'
    compile 'org.scala-lang:scala-library:2.11.8'
}

gatling {
    simulations = {
        include "**/predictors/*.scala"
    }
}

gatlingRun {
    systemProperties 'endpoint': "${endpoint}"
}

I put the BasicSimulation.scala in the src/gatling/predictors folder.

package predictors

import io.gatling.http.Predef._
import io.gatling.core.Predef._
class BasicSimulation extends Simulation {
  val httpConf = http.baseURL("http://localhost:8000/")
  val scn = scenario("Basic Simulation")
    .exec(http("request_1")
      .get("api/chemocare/gatling/"))
    .pause(5)
  setUp(
    scn.inject(atOnceUsers(80))
  ).protocols(httpConf)
}

I set up my rest-api and test it with postman. It works fine. However, when I run gradlew gatlingRun, it seems like none of the test is executed and no report is generated. I got this message instead:

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

How do I execute and register the test?

Saith answered 30/8, 2019 at 11:16 Comment(5)
Did you try to put your file into src/gatling/simulations with a closure that includes every file with extension .scala?Ridglea
yes, I added my file to several folders, I've also tried to include those folder in my build.gradle. But no luck so far.Saith
The setup from your current example cannot work, because the src/gatling/simulations is the base path and every include is evaluated starting from this base path.Ridglea
Yep, it is now detect the simulation, though I got an error Caused by: java.lang.RuntimeException: Some simulations failed : BasicSimulation. I can work from that. ThanksSaith
The gardle plugin is now officially part of Gatling: gatling.io/docs/current/extensions/gradle_plugin. The new default location for simulations is now src/gatling/scala and src/gatling/resourcesUkrainian
U
1

I had the same problem and wanted to share my solution, as it deviates a bit from the comments.

In general it is true, that a BUILD SUCCESSFUL without running a test, might indicate that Gatling wasn't able to find the simulations.

In my case I've been running:

gradle gatlingRun-MySimulation

What I've missed is that xyz in gatlingRun-xyz has to be a fully qualified name. So the command should be

gradle gatlingRun-org.corp.pkge.MySimulation
Ukrainian answered 1/10, 2020 at 11:45 Comment(0)
P
1

In local, I tried with below approach working fine for me ->

gradle clean build -> to clean build the project

 ./gradlew gatlingRun-com.project.sample.performance.simulations.sample.SampleBaseSimulation-> to run the single file

gradle gatlingRun-com.project.sample.performance.simulations.sample.SampleBaseSimulation-> to run the single file

gradle gatlingRun -> to run all simulations

Perl answered 13/9, 2021 at 7:34 Comment(0)
P
0

I had the same problem, I was getting BUILD SUCCESSFUL but test was not running.

I gave correct command (below command) to run gatling test, in fact which was working earlier, suddenly stopped working. After a bit of investigation I have got to know that build files have been replaced with old files.

I deleted content in build folder in gatling module and rebuilt the module, then the source files have been build into build folder, then the below command starts working again

./gradlew myproject-service-gatling:gatlingRun-com.org.myproject.StoreMyQueriesToSolrGatlingTest

My project structure

  Root_Proj

   |__ myproject-service
   
          |__ src

               |__ gatling [myproject-service-gatling]
                   
                    |__ build

                         |__ resources

                         |__ scala

               |__ main
          
                    |__ java

                    |__ resources

               |__ test

                    |__ java

                    |__ resources
Pellitory answered 5/5, 2021 at 15:13 Comment(0)
A
0

Somebody may place simulations in the wrong package (by default IntelliJ IDEA creates main/scala or main/java source set when you are creating an empty Gradle project)

Check does your files are placed in gatling/scala package

And then run all simulations using ./gradlew clean gatlingRun command

Acknowledge answered 7/12, 2022 at 16:37 Comment(1)
Or you might add a custom source in your grade file.Acknowledge
L
0

I almost went crazy with this problem, even though this does not answer the OP (who named the test correctly) I'm going to post it here for others. gatlingRun will only execute Simulations whose name end in Simulation. The exact syntax is documented under the plugin configuration.

Liechtenstein answered 12/3 at 8:41 Comment(1)
Disclaimer: Gatling creator here. Indeed, the existing behavior of our gradle plugin is pretty unexpected. The reason is that it was originally a popular community component that was ultimately contributed. As a result, it's behavior is not aligned with our other build plugins such as the maven one. We've decided to completely break the existing behavior in Gatling 3.11.0 (ETA mid April 2024) and implement one that makes more sense to us.Brehm

© 2022 - 2024 — McMap. All rights reserved.