Gatling and a HTML5 app running against SAP

I have been given the great task of trying generate a Gatling script against a HTML5 app that queries SAP.
Using Gatling recorder I have achieved the following script:

`

package no.STORE

import scala.concurrent.duration._

import io.gatling.core.Predef._

import io.gatling.http.Predef._

import io.gatling.jdbc.Predef._

class RecordedSimulation
extends Simulation {

val httpProtocol = http

.baseURL(http://STOREq30.sds.STORE.no:8300)

.inferHtmlResources()

.acceptHeader("application/json,
text/javascript, /; q=0.01")

.acceptEncodingHeader(“gzip, deflate”)

.acceptLanguageHeader(“en-US,en;q=0.5”)

.authorizationHeader(“Basic ZXh0bWFmdTpDb29wNzg=”)

.connection(“keep-alive”)

.contentTypeHeader(“application/x-www-form-urlencoded; charset=UTF-8”)

.userAgentHeader("Mozilla/5.0
(Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")

val headers_0 = Map(“Accept”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”)

val headers_2 = Map(“Accept”/)

val headers_3 = Map(“Accept”“text/css,/;q=0.1”)

val headers_6 = Map(

"Access-Control-Allow-Origin"
“*”,

"NeptuneServer"
http://STOREq30.sds.STORE.no:8300,

"Pragma"
“no-cache”,

"X-Requested-With"
“XMLHttpRequest”,

"X-SUP-APPCID"
“5befbe04-146f-46c7-b052-30a7034b98b5”,

"sap-client"
“300”)

val headers_10 = Map(

"Accept"
"text/plain, /;
q=0.01",

"Access-Control-Allow-Origin"
“*”,

"NeptuneServer"
http://STOREq30.sds.STORE.no:8300,

"X-Requested-With"
“XMLHttpRequest”,

"X-SUP-APPCID"
“5befbe04-146f-46c7-b052-30a7034b98b5”,

"sap-client"
“300”)

val uri1 = "http://STOREq30.sds.STORE.no:8300"

val scn = scenario(“RecordedSimulation”)

.exec(http(“baseURL”)

.get("/neptune/UI5_RETAIL_APPCACHE?sap-client=300&appcache=STORE_Q30_DIREKTE")

.headers(headers_0)

.check(status.is(401)))

.pause(3)

.exec(http(“request_1”)

.get("/neptune/UI5_RETAIL_APPCACHE?sap-client=300&appcache=STORE_Q30_DIREKTE")

.headers(headers_0)

.basicAuth(“username”,“Password”)

.resources(http(“request_2”)

.get(uri1 +
"/neptune/server/openui5/resources/sap-ui-core.js?v=1.26.3")

.headers(headers_2)

.basicAuth(“username”,“Password”)

.check(status.is(304)),

http(“request_3”)

.get(uri1 +
"/neptune/public/application/ui5_retail_appcache/css/app.css")

.headers(headers_3)

.basicAuth(“username”,“Password”)

.check(status.is(304)),

http(“request_4”)

.get(uri1 +
"/favicon.ico")

.headers(headers_0)

.check(status.is(404)),

http(“request_5”)

.get(uri1 +
"/favicon.ico")

.headers(headers_0)

.check(status.is(404))))

.pause(7)

.exec(http(“request_6”)

.post("/neptune/neptune_ajax?ajax_id=GET_APP_DATA&ajax_applid=UI5_RETAIL_APPCACHE&field_id=00006&ajax_value=STORE_Q30_DIREKTE")

.headers(headers_6)

.formParam("""[{“APPLID”:“UI5_RETAIL_APPCACHE_PASSCODE”,“LANGUAGE”:“E”,“UPDDAT”:“20150508”,“UPDTIM”:“124703”,“INVALID”:false,“DESCR”:“STORE”},{“APPLID”:“UI5_RETAIL_APPCACHE_MENU”,“LANGUAGE”:“E”,“UPDDAT”:“20150518”,“UPDTIM”:“160452”,“INVALID”:false,“DESCR”:“STORE”},{“APPLID”:“UI5_RETAIL_CREATE_PO”,“LANGUAGE”:“E”,“UPDDAT”:“20150522”,“UPDTIM”:“165356”,“INVALID”:false,“DESCR”:“STORE”},{“APPLID”:“UI5_RETAIL_TRANSACTIONS”,“LANGUAGE”:“E”,“UPDDAT”:“20150522”,“UPDTIM”:“154137”,“INVALID”:false,“DESCR”:“STORE”}]""",
"")

.basicAuth(“username”,“Password”)

.resources(http(“request_7”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=GET_MENU_LIST&ajax_applid=UI5_RETAIL_APPCACHE_MENU&field_id=00044&ajax_value=STORE_Q30_DIREKTE")

.headers(headers_6)

.formParam("""{“TXT_HEADER”:"STORE
ONE BYGG TROMSØ, NORD (2371)",“TXT_LIST”:“Transaksjoner”,“ENABLE_LIST”:true,“PARENT”:“000C291EE8241EE4B8D030DED8CA03EC”,“PREVIOUS”:“00000000000000000000000000000000”}""",
"")

.basicAuth(“username”,“Password”),

http(“request_8”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=&ajax_applid=UI5_RETAIL_APPCACHE_MENU&field_id=00085&ajax_value=undefined")

.headers(headers_6)

.basicAuth(“username”,“Password”),

http(“request_9”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=GET_STORE_DETAILS&ajax_applid=UI5_RETAIL_APPCACHE_MENU&field_id=00075&ajax_value=undefined")

.headers(headers_6)

.formParam("""{“TXT_HEADER”:"STORE
ONE BYGG TROMSØ, NORD
(2371)",“TXT_LIST”:“Transaksjoner”,“ENABLE_LIST”:true,“PARENT”:“000C291EE8241EE4B8D030DED8CA03EC”,“PREVIOUS”:“00000000000000000000000000000000”}||{“WERKS”:“2371”,“NAME1”:"STORE
ONE BYGG TROMSØ,
NORD",“LIST_ID”:“1432318827898”,“MATNR”:"",“MATNR_TIMEOUT”:"",“TILE_TITLE”:“Reklamasjon”,“TRANSACTION_TYPE”:“ReturnDefectItem”,“WERKS_TIMEOUT”:“1432318822715”,“FORCE_OFFLINE”:false,“DISABLE_HAPTIC”:false,“REASON_TIMEOUT”:“1432318822715”}""",
"")

.basicAuth(“username”,“Password”)))

.pause(7)

.exec(http(“request_10”)

.get("/neptune/server/openui5/resources/sap/suite/ui/commons/messagebundle_no.properties")

.headers(headers_10)

.basicAuth(“username”,“Password”)

.resources(http(“request_11”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=DUMMY_NETWORK_CHECK&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00505&ajax_value=undefined")

.headers(headers_6)

.basicAuth(“username”,“Password”),

http(“request_12”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=GET_CARTS_TOTAL&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00309&ajax_value=undefined")

.headers(headers_6)

.formParam("""{“WERKS”:“2371”,“NAME1”:"STORE
ONE BYGG TROMSØ, NORD"}""", “”)

.basicAuth(“username”,“Password”),

http(“request_13”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=INITIALIZE_PALLET_MASTER&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00525&ajax_value=undefined")

.headers(headers_6)

.basicAuth(“username”,“Password”),

http(“request_14”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=INITIALIZE_MATERIAL_MASTER&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00311&ajax_value=undefined")

.headers(headers_6)

.formParam("{}",
"")

.basicAuth(“username”,“Password”)))

.pause(57)

.exec(http(“request_15”)

.post("/neptune/native/neptune_ajax?ajax_id=DUMMY_NETWORK_CHECK&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00505&ajax_value=undefined")

.headers(headers_6)

.basicAuth(“username”,“Password”)

.resources(http(“request_16”)

.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=GET_ARTICLE_DETAILS&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00055&ajax_value=123456789")

.headers(headers_6)

.formParam("""{“WERKS”:“2371”,“NAME1”:"STORE
ONE BYGG TROMSØ, NORD",“LIST_ID”:1432643830663,“TOTAL_LISTS”:“14”,“DEVICE_ID”:“usernamewin8ff38”}||{}||{}||{}""",
"")

.basicAuth(“username”,“Password”)))

setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)

}

`

My question is would gatling work with this technology? a HTML5 app using ajax-calls? Looking at the script it seams like this should work and replaying it does not gives me any errors.
Just to generate load, maybe this would work? Or do I need to use a tool that actually uses the entire DOM to test HTML5.
BTW: The HTML5 app runs through Soti Mobicontrol.

Cheers

Hi,

You can’t perform a load test on a javascript application with Gatling. You can however reproduce it’s ajax calls and do a load test on it’s backend, which is what your script is doing and what you recorded.

If this was your intention, sure, it will work!

Cheers,
Guillaume.

Ok, thanx Guillaume!
I want to crate traffic on the backend (using the frontend)
Just a control question:

given a part of my script:

`
.post(uri1 +
"/neptune/native/neptune_ajax?ajax_id=GET_CARTS_TOTAL&ajax_applid=UI5_RETAIL_CREATE_PO&field_id=00309&ajax_value=undefined")

`

This http-post will actually create load by executing some ajax-call that will hit the backend, which is my intention.

//Magnus