Last active
April 2, 2023 10:14
-
-
Save dacr/6ff028f79f2343e31ade88f3f21a283a to your computer and use it in GitHub Desktop.
drools interactions performance test script / published by https://github.com/dacr/code-examples-manager #a998403a-5903-4a61-916f-95529b17c4c8/f5d8a8789a083091894fc9a2e493159768435afa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// summary : drools interactions performance test script | |
// keywords : scala, drools, gatling, ammonite, scala, load-test, performance | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : a998403a-5903-4a61-916f-95529b17c4c8 | |
// execution : scala 2.12 ammonite script (http://ammonite.io/) - run as follow 'amm scriptname.sc' | |
// created-on : 2018-09-22T09:41:07+02:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
/* | |
This script is a simple test performance, single user loop without any pause. It requires to | |
first start the drools-interactions script and then this script : | |
- amm drools-interactions.sc | |
- amm-2.12 drools-interactions-gatling.sc | |
*/ | |
import $ivy.`io.gatling:gatling-http:3.4.1` | |
import $ivy.`io.gatling:gatling-app:3.4.1` | |
import $ivy.`io.gatling.highcharts:gatling-charts-highcharts:3.4.1` | |
import $ivy.`ch.qos.logback:logback-classic:1.2.3` | |
import io.gatling.app.Gatling | |
import io.gatling.core.config.GatlingPropertiesBuilder | |
import io.gatling.core.Predef._ | |
import io.gatling.http.Predef._ | |
import scala.concurrent.duration._ | |
import org.slf4j.{LoggerFactory, Logger} | |
val rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).asInstanceOf[ch.qos.logback.classic.Logger] | |
rootLogger.setLevel(ch.qos.logback.classic.Level.ERROR) | |
class GatlingSimple extends Simulation { | |
def config = { | |
http | |
.baseUrl("http://127.0.0.1:6080") | |
.userAgentHeader("curl/7.58.0") | |
} | |
def assertions = List( | |
global.responseTime.mean.lt(90), | |
global.successfulRequests.percent.gt(90) | |
) | |
def scn = | |
scenario("Simple scenario").during(30 seconds) { | |
exec( | |
http("first question") | |
.get("/") | |
.check(status.is(200)) ) | |
//.pause(500 milliseconds, 1000 milliseconds) | |
.exec( | |
http("get2") // Do you encounter a performance problem ? | |
.get("/response/perf-issue/yes") | |
.check(status.is(200)) ) | |
//.pause(500 milliseconds, 1000 milliseconds) | |
.exec( | |
http("get3") //What is the nature of your performance issue ? | |
.get("/response/perf-context/slow%20response%20time") | |
.check(status.is(200)) ) | |
//.pause(500 milliseconds, 1000 milliseconds) | |
.exec( | |
http("get4") //What is your operating system ? | |
.get("/response/os-context/Linux") | |
.check(status.is(200)) ) | |
//.pause(500 milliseconds, 1000 milliseconds) | |
.exec( | |
http("get5") // What is your technical context ? | |
.get("/response/app-context/php") | |
.check(status.is(200)) ) | |
//.pause(500 milliseconds, 1000 milliseconds) | |
.exec( | |
http("reset") // What is your technical context ? | |
.get("/reset") | |
.check(status.is(200)) ) | |
//.pause(500 milliseconds, 1000 milliseconds) | |
} | |
setUp(scn.inject(rampUsers(1) during (10 seconds))) | |
.protocols(config) | |
.assertions(assertions) | |
} | |
val props = | |
new GatlingPropertiesBuilder() | |
.simulationClass(classOf[GatlingSimple].getName) | |
.resultsDirectory("/tmp") | |
//.noReports() | |
.build | |
Gatling.fromMap(props) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment