Skip to content

Commit

Permalink
Update gatling to support JDK11
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdan committed Oct 21, 2019
1 parent 12cb891 commit 576ba0d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
9 changes: 8 additions & 1 deletion tests/performance/gatling_tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

plugins {
id "com.github.lkishalmi.gatling" version "0.7.2"
id "com.github.lkishalmi.gatling" version "3.2.9"
}

apply plugin: 'eclipse'
Expand All @@ -26,6 +26,13 @@ repositories {
mavenCentral()
}

sourceSets {
gatling {
scala.srcDirs = ["src/gatling/scala/"]
resources.srcDirs = ["src/gatling/resoruces/"]
}
}

dependencies {
gatling "io.spray:spray-json_2.12:1.3.4"
gatling "commons-io:commons-io:2.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import org.apache.openwhisk.extension.whisk.OpenWhiskProtocolBuilder
import org.apache.openwhisk.extension.whisk.Predef._
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.core.util.Resource
import org.apache.commons.io.FileUtils
import io.gatling.core.util.ClasspathPackagedResource

import scala.concurrent.duration._

Expand Down Expand Up @@ -56,12 +55,10 @@ class BlockingInvokeOneActionSimulation extends Simulation {
// Define scenario
val test: ScenarioBuilder = scenario(s"Invoke one ${if (async) "async" else "sync"} action blocking")
.doIf(_.userId == 1) {
exec(
openWhisk("Create action")
.authenticate(uuid, key)
.action(actionName)
.create(FileUtils
.readFileToString(Resource.body(actionfile).get.file, StandardCharsets.UTF_8)))
exec(openWhisk("Create action")
.authenticate(uuid, key)
.action(actionName)
.create(ClasspathPackagedResource(actionfile, getClass.getResource(actionfile)).string(StandardCharsets.UTF_8)))
}
.rendezVous(connections)
.during(5.seconds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import org.apache.openwhisk.extension.whisk.Predef._
import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.core.util.Resource
import org.apache.commons.io.FileUtils
import io.gatling.core.util.ClasspathPackagedResource

import scala.concurrent.duration._

Expand Down Expand Up @@ -84,8 +83,8 @@ class ColdBlockingInvokeSimulation extends Simulation {
}

private def actionCode = {
val code = FileUtils
.readFileToString(Resource.body("nodeJSAction.js").get.file, StandardCharsets.UTF_8)
val code = ClasspathPackagedResource("nodeJSAction.js", getClass.getResource("nodeJSAction.js"))
.string(StandardCharsets.UTF_8)
//Pad the code with empty space to increase the stored code size
if (codeSize > 0) code + " " * codeSize else code
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import java.util.Base64
import org.apache.openwhisk.extension.whisk.Predef._
import io.gatling.core.Predef._
import io.gatling.core.session.Expression
import io.gatling.core.util.Resource
import org.apache.commons.io.FileUtils
import io.gatling.core.util.ClasspathPackagedResource

import scala.concurrent.duration._

Expand Down Expand Up @@ -65,14 +64,15 @@ class LatencySimulation extends Simulation {
* `main` is only needed for java. This is the name of the class where the main method is located.
*/
val actions: Seq[(String, String, String, String)] = Map(
"nodejs:default" -> (FileUtils
.readFileToString(Resource.body("nodeJSAction.js").get.file, StandardCharsets.UTF_8), "latencyTest_node", ""),
"python:default" -> (FileUtils
.readFileToString(Resource.body("pythonAction.py").get.file, StandardCharsets.UTF_8), "latencyTest_python", ""),
"swift:default" -> (FileUtils
.readFileToString(Resource.body("swiftAction.swift").get.file, StandardCharsets.UTF_8), "latencyTest_swift", ""),
"java:default" -> (Base64.getEncoder.encodeToString(
FileUtils.readFileToByteArray(Resource.body("javaAction.jar").get.file)), "latencyTest_java", "JavaAction"))
"nodejs:default" -> (ClasspathPackagedResource("nodeJSAction.js", getClass.getResource("nodeJSAction.js")).string(
StandardCharsets.UTF_8), "latencyTest_node", ""),
"python:default" -> (ClasspathPackagedResource("pythonAction.py", getClass.getResource("pythonAction.py")).string(
StandardCharsets.UTF_8), "latencyTest_python", ""),
"swift:default" -> (ClasspathPackagedResource("swiftAction.swift", getClass.getResource("swiftAction.swift"))
.string(StandardCharsets.UTF_8), "latencyTest_swift", ""),
"java:default" -> (Base64.getEncoder.encodeToString(ClasspathPackagedResource(
"javaAction.jar",
getClass.getResource("javaAction.jar")).bytes), "latencyTest_java", "JavaAction"))
.filterNot(e => excludedKinds.contains(e._1))
.map {
case (kind, (code, name, main)) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ package org.apache.openwhisk.extension.whisk
import java.net.URL

import com.softwaremill.quicklens._
import io.gatling.core.Predef._
import io.gatling.core.config.GatlingConfiguration
import io.gatling.http.Predef._
import io.gatling.core.Predef._
import io.gatling.http.protocol.HttpProtocol

import scala.language.implicitConversions
Expand Down Expand Up @@ -72,7 +72,7 @@ case class OpenWhiskProtocolBuilder(private val protocol: OpenWhiskProtocol) {
/** build the http protocol with the parameters provided by the openwhisk-protocol. */
def build(implicit configuration: GatlingConfiguration) = {
http
.baseURL(s"${protocol.protocol}://${protocol.apiHost}:${protocol.port}")
.baseUrl(s"${protocol.protocol}://${protocol.apiHost}:${protocol.port}")
.contentTypeHeader("application/json")
.userAgentHeader("gatlingLoadTest")
.warmUp("http://google.com")
Expand Down

0 comments on commit 576ba0d

Please sign in to comment.