Running Gatling as a dependency using Gradle

1,404 views
Skip to first unread message

Mark Taylor

unread,
Jan 15, 2020, 1:23:02 AM1/15/20
to Gatling User Group
Using Gatling 3.3.1, I am struggling to find any model project in GitHub or elsewhere that demonstrates running Gatling as a dependency in a Gradle project.
I just want to run my simulations in Jenkins by executing a Gradle task and no matter what I try, Gatling is not able to find my simulations.  Running a Gatling project from IntelliJ using Maven is fine but using JavaExec with my build.gradle cannot find my simulations.
Finding a single simulation by full package name is also fine, my issue is just conveying to Gatling via Gradle the folder containing all my simulations.

Using the code below with my simulation in my project at the spot shown in the screenshot, Gatling finds nothing reporting as shown below.
I am new to Gradle and Gatling. I am sure a simple example project would clear this up.  I have tried so many variations with sourceSets, configurations, Groovy methods and on but I cannot get this to work.

BUILD.GRADLE
plugins {
    id 'scala'
}

repositories {
    jcenter()
}

configurations {
    gatling
}

dependencies {
    // Use Scala 2.12 in our library project
    implementation 'org.scala-lang:scala-library:2.12.9'

    // Use Scalatest for testing our library
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.scalatest:scalatest_2.12:3.0.8'

    // Need scala-xml at test runtime
    testRuntimeOnly 'org.scala-lang.modules:scala-xml_2.12:1.2.0'

    compile group: 'io.gatling', name: 'gatling-app', version: '3.3.1'

    compile group: 'io.gatling', name: 'gatling-recorder', version: '3.3.1'

    compile group: 'io.gatling', name: 'gatling-charts', version: '3.3.1'

    compile group: 'io.gatling.highcharts', name: 'gatling-charts-highcharts', version: '3.3.1'
}

task gatlingRun(type: JavaExec) {
    sourceSets.test.allSource.each {println(it)}
    println("Simulations path:  ${projectDir}/src/test/scala")
    description = 'Run gatling tests'
    new File("${buildDir}/reports/gatling").mkdirs()
    classpath = sourceSets.test.runtimeClasspath
    main = "io.gatling.app.Gatling"
    args = [
            '-sf', "${projectDir}/src/test/scala",
            '-rf', "${buildDir}/reports/gatling"
    ]
}

// '-s', 'io.monster.tests.load.simulations.feeders.JsonFeederSimulation',

===================================================================================================
OUTPUT
4:24:48 pm: Executing task 'gatlingRun'...


> Configure project :
/Users/mataylor/data/demos/adserver-load-tests/src/test/resources/logback.xml
/Users/mataylor/data/demos/adserver-load-tests/src/test/resources/bodies/campaign.json
/Users/mataylor/data/demos/adserver-load-tests/src/test/resources/bodies/advertiser.json
/Users/mataylor/data/demos/adserver-load-tests/src/test/resources/gatling.conf
/Users/mataylor/data/demos/adserver-load-tests/src/test/resources/recorder.conf
/Users/mataylor/data/demos/adserver-load-tests/src/test/scala/Recorder.scala
/Users/mataylor/data/demos/adserver-load-tests/src/test/scala/Engine.scala
/Users/mataylor/data/demos/adserver-load-tests/src/test/scala/JsonFeederSimulation.scala
/Users/mataylor/data/demos/adserver-load-tests/src/test/scala/io/monster/tests/load/simulations/BaseSimulation.scala
/Users/mataylor/data/demos/adserver-load-tests/src/test/scala/io/monster/tests/load/simulations/feeders/JsonFeederSimulation.scala
/Users/mataylor/data/demos/adserver-load-tests/src/test/scala/IDEPathHelper.scala
Simulations path:  /Users/mataylor/data/demos/adserver-load-tests/src/test/scala

> Task :compileJava NO-SOURCE
> Task :compileScala NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :compileTestJava NO-SOURCE
> Task :compileTestScala UP-TO-DATE
> Task :processTestResources UP-TO-DATE
> Task :testClasses UP-TO-DATE

> Task :gatlingRun
There is no simulation script. Please check that your scripts are in user-files/simulations

BUILD SUCCESSFUL in 1s
3 actionable tasks: 1 executed, 2 up-to-date
4:24:49 pm: Task execution finished 'gatlingRun'.



  

This email was sent to you because you are a candidate that has registered your details with Randstad and/or as a client, referee or supplier you have provided your contact details to us and have consented to receiving communications from Randstad in accordance with our Privacy Collection Statement. If you no longer wish to receive these emails you may unsubscribe at any time.  Please allow 48 hours for your request to be activated.
Screen Shot 2020-01-15 at 4.23.01 pm.png

Stéphane LANDELLE

unread,
Jan 15, 2020, 1:42:34 AM1/15/20
to gat...@googlegroups.com
https://gatling.io/docs/current/extensions/#third-parties

Logo Stéphane Landelle
Chief Technical Officer
twitter: @slandelle
site:
gatling.io




--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/gatling/84800bd8-81ac-4ecd-86fa-7b2c0d7b985d%40googlegroups.com.

Mark Taylor

unread,
Jan 16, 2020, 1:22:15 AM1/16/20
to Gatling User Group
Thanks Stéphane,

Yes I should have mentioned that I tried using the plugin com.github.lkishalmi.gatling and I did not think it was working since, being new to Gradle as well as Gatling, I misunderstood what the plugin does.
I thought the generated tasks would be visible in Gradle after running the plugin.
I finally found a working example of a project which used the plugin and once I had seen how the plugin is used I had another go at using the plugin in a new project.  At last that worked correctly for me.

I will create a simple project in GitHub with the plugin, Gradle and Gatling.
The project that helped me was this one:  https://github.com/nalinikanth/gattling-gradle-demo

Thanks

Mark
    

Stéphane LANDELLE

unread,
Jan 16, 2020, 2:41:44 AM1/16/20
to gat...@googlegroups.com
If you're new with gradle, maybe going with maven that we officially support, would have been a wiser choice.


Logo Stéphane Landelle
Chief Technical Officer
twitter: @slandelle
site:
gatling.io



--
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.
Reply all
Reply to author
Forward
0 new messages