Hi guys, I want to check data in the database or Redis, etc., and want to show check results on result reports. so I define a custom checker to meet this requirement. but not usable, and I’m not familiar with scala and Gatling DSL, so I want to ask for your help.
this is what I wanted, to check data accuracy and extra some attributes then store it in session.
but I can not get the attribute in the custom checker or out of the checker, it throws “No attribute named ‘orderNo’ is defined”
my checker extends ExitableAction but if the check failed, exitHereIfFailed does not take effect.
so how can I set the attribute to the session and exit the workflow if the check failed
thanks for your answer. I think the session is like java’s hashmap and can put k&v anywhere before, I will try to find another way to carry the attribute to the next session.
and check failed not to exit the workflow bcs I did not mark the session as succeed or failed
Also, please note that operations performed in Gatling DSL methods must be very fast or you’ll block the event loop. In particular, you shouldn’t perform a database call in each check execution.
I guess you wanted something like code below, but as slandelle said above, it would be better to perform such checks after test end. It can create additional load on your database.
object CheckOrderBehavior {
val checkOrder: ChainBuilder = {
exec { session => //don't know how to write it in scala function
val orderDO = OrderSimulationRepository.findById(session("orderId").as[Int])
//return session copy with orderNo on success or mark as failed if error
if ("ACTIVE" == orderDO.orderState) {
session.set("orderNo", orderDO.orderNo)
} else {
session.markAsFailed
}
}.exitHereIfFailed
.exec(session => {
// get orderNo from session, but can not find 'orderNo' in session
session
})
}
}
it would be better to perform such checks after test end. It can create additional load on your database.
It’s way worse than this.
Gatling uses n EventLoop threads where n = 2 * cores. If you have a 4 core machine, every time you’re blocking an EventLoop thread for 100ms, you’re actually blocking 1/8th of your virtual users for this same time.
Haha, thanks for reminding me. But we use Gatling not for performance testing, but for integration testing to reduce the workload of QA.
Because Gatling is simple and easy to use, and friendly for Java developers, so we chose Gatling and we don’t need to worry about performance
thanks for your reply. I mark the session failed/succeed status at common.checker.actions.CustomSessionCheckBaseAction#execute.
and we use the Gatling not for the performance testing but integration testing. so doesn’t need to care about the performance. thx
it’s very important for the developers who use Gatling to do the loading test. I very like Gatling, so use Gatling to do the integration test. and do your guys consider developing a framework for integration testing