I’ve been searching the community posts and I can’t seem to find exactly what I’m looking for… I’m hoping something like this is possible, or there is a work-around.
I’m trying to use Gatling/Kotlin/Gradle for end to end performance testing. The systems under test have different domains (baseUrl), but as I mentioned, I want to do build scripts that mimic a workflow over the entire system. The system was build using Domain Driven Design, so there are different “bounded contexts” if you find yourself wondering why they are separate apps.
I’ve written some code(Kotlin DSL) to demonstrate what I’m trying to do. See the comments to describe what I’m after…
class MyNewSimulation : Simulation() {
private val createOrder = scenario("Create New Order and View")
.group("Create Order").on(
//here an order is crated in one system that uses the baseUrl defined in the httpProtocol...
exec(
HttpDsl.http("save order")
.post("/orders")
.header("Content-Type", "application/json")
.basicAuth("username", "password")
.body(StringBody("""{"orderId":"123456"}"""))
.check(HttpDsl.status().`is`(200), jsonPath("$..orderId").find().saveAs("orderId"))
)
)
.group("View Existing Orders").on(
// I observed that the baseUrl is stored in the session, so here I tried to set it to the attribute
// that appeared to have the URL I wanted updated...
exec { session ->
//attempting to set a new baseUrl
val newSession = session.set("gatling.http.cache.baseUrl", "https://www.my-orders-app.com")
newSession
}
// I want this request to look like 'https://www.my-orders-app.com/my-orders?123456' whereas the baseUrl was update with the
// session.set(...) and the orderId came from the session
.exec(
HttpDsl.http("Get Orders")
.get("/my-orders?#{orderId}")
.basicAuth("different-username", "different-password")
.check(
HttpDsl.status().`is`(200)
)
)
)
private val httpProtocol = HttpDsl.http
.baseUrl("https://www.my-order-app.com")
.acceptHeader("application/json, text/plain, */*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.9")
.userAgentHeader("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 GatlingPerformanceTest/43.0")
.disableCaching()
init {
setUp(
createOrder.injectOpen(
atOnceUsers(1)
).protocols(httpProtocol)
)
.assertions(
global().successfulRequests().percent().gt(95.0)
)
}
}
Is what I’m trying to do not possible with Gatling? I’m sure I’m missing something…Any suggestions would be greatly appreciated on how to accomplish this; I already made a significant investment in learning the tool and it would be a shame to have to put it down!
Thanks!