How to generate and use dynamic parameters for each request in Gatling scala?
Hello every one
I have one problem. Please help me
I generate 2 dynamic parameters (order and time). Again I generate the third dynamic parameter and use the above 2 dynamic parameters.
Commonly I have 5 parameter
I post 5 parameter
When I do load the test first request is ok but the next request is a duplicate.
How do generate dynamic parameters in each request?
For example :
I want
order = “20220830084116213653”
time = “20220830084116”
name = “Test”
surname = “Testov”
def req_param = “20220830084116213653” + “20220830084116” + “Test” + “Testov”
and next request is
order = “20220830084116213654”
time = “20220830084117”
name = “Test”
surname = “Testov”
req_param = “20220830084116213654” + “20220830084117” + “Test” + “Testov”
Real request and response is there
class TestRequest extends Simulation {
val format = new SimpleDateFormat(“yyyyMMddHHmmss”)
format.setTimeZone(TimeZone.getTimeZone(“UTC”))
val order = format.format(Calendar.getInstance.getTime).toString() + Random().nextInt(999999).toString()
val time = format.format(Calendar.getInstance.getTime).toString()
val name = “Test”
val surname = “Testov”
val req_param = order + time + name + surname
val httpProtocol = http
.baseUrl(“https://some url”)
private val headers_0 = Map(
“sec-ch-ua-mobile” → “some parameter”,
)
private val scn = scenario(“RecordedSimulation”)
.exec (
http(“request_0”)
.post("/)
.headers(headers_0)
.formParam(“order”, _ => order)
.formParam(“time”, _ => time)
.formParam(“name”, _ => name)
.formParam(“surname”, _ => surname)
.formParam(“req_param”, _ => req_param)
)
setUp(scn.inject(rampUsers(5).during(1)).protocols(httpProtocol))
}
RESPONSE IS
<?xml version="1.0" encoding="utf-8" ?> Approved 20220830084116213653 20220830084116 Test TestOV 2022083008411621365320220830084116TestTestOV <?xml version="1.0" encoding="utf-8" ?> Repeated 20220830084116213653 20220830084116 Test TestOV 2022083008411621365320220830084116TestTestOV <?xml version="1.0" encoding="utf-8" ?> Repeated 20220830084116213653 20220830084116 Test TestOV 2022083008411621365320220830084116TestTestOV <?xml version="1.0" encoding="utf-8" ?> Repeated 20220830084116213653 20220830084116 Test TestOV 2022083008411621365320220830084116TestTestOV <?xml version="1.0" encoding="utf-8" ?> Repeated 20220830084116213653 20220830084116 Test TestOV 2022083008411621365320220830084116TestTestOVBut must be every request Approved
how do I do it?