Home > Mobile >  Gatling performance test with Scala and Gradle
Gatling performance test with Scala and Gradle

Time:11-08

I am new to Gatling and Scala , I am trying to run the Gatling test example specified in the beginning parts of this video: https://www.youtube.com/watch?v=To7LJiK87Us, but using Gradle wrapper. I created a gradle project in IntelliJ idea and the build.gradle file is below

buildscript {
    repositories {
        maven {
            url '<url>'
            credentials {
                <><>
            }
        }
    }
    dependencies {
        classpath "gradle.plugin.io.gatling.gradle:gatling-gradle-plugin:3.8.4"
    }
}

apply plugin: "io.gatling.gradle"
apply plugin: 'scala'

repositories {
    maven {
        url '<>'
        credentials {
            <><>
        }
    }
    mavenCentral()
}

dependencies {
    implementation 'org.scala-lang:scala-library:2.12.4'
    gatling 'org.scala-lang:scala-library:2.12.4'
    gatling 'au.com.bytecode:opencsv:2.4'
    gatling group: 'org.scalaj', name: 'scalaj-http_2.12', version: '2.3.0'
    gatling group: 'org.json4s', name: 'json4s-native_2.12', version: '3.5.3'
}

compileGatlingScala {
    scalaCompileOptions.additionalParameters = ["-feature"]
}

gatling {
    simulations = {
//  Enable ALL perf testing, regardless of current pass/fail state
        include "**/simulation/*Simulation*.scala"
    }
}

sourceSets.gatling.resources.srcDir('conf')

gatling {
    logLevel = 'WARN' // logback root level
    logHttp = 'ALL' 
}

Note: I have a few extra dependencies here like 'opencsv' that I will be needing later for the actual performance testing.

And my LoadSimulation script is as below

class LoadSimulation extends Simulation {

  val scn = scenario("JSON")
    .exec(
      http("GET")
        .get("http://jsonplaceholder.typicode.com/comments")
    )

  setUp(
    scn.inject(atOnceUsers(1))
  )
}

When I try to run the performance test using gradlew, it says "build successful', but I don't see a result in the reports folder under /build

>gradlew gatlingRun-LoadSimulation

BUILD SUCCESSFUL in 1s
3 actionable tasks: 1 executed, 2 up-to-date

Could anyone please tell me what I am doing wrong? Is this not how I should be running it?

CodePudding user response:

There's something very wrong: you're enforcing Scala 2.12 and Scala 2.12 based libraries while using Gatling 3.8 that requires Scala 2.13.

Please have a look at the official sample project: https://github.com/gatling/gatling-gradle-plugin-demo-scala/blob/main/build.gradle

CodePudding user response:

In scala language the minor versions are actually major versions. You can expect a lot of differences between 2.12 and 2.13. Thats the problem you are facing. Its like comparing Java 7 and Java 8. I had the same confusion back in the days with the way Scala versions work.

  • Related