I am creating a JMeter Script to add products into the cart for the Magento2 website. Post request is executing without any error but the product isn’t displaying into cart after that request.
I am creating a JMeter Script to add products into the cart for the Magento2 website. Post request is executing without any error but the product isn’t displaying into cart after that request.
2
Answers
JMeter automatically treats HTTP responses with status codes below 400 as successful, it doesn’t know anything about Magento or product adding to cart. If you need to introduce an extra check that the product is there – you need to add Response Assertion
In the absolute majority of cases the main reason for “failing” requests is missing or not properly implemented correlation of the dynamic parameters:
${form_key}
JMeter Variable has anticipated value using Debug SamplerAlso be aware that there is a Magento performance-toolkit containing
benchmark.jmx
script which you can use as the reference/basis for your own testsYou likely need to handle the dynamic values associated with cart identifier with the session. I will save you some time however, architecturally when Magento issues the cart is a known antipattern – every time I see Magento it is a default cart model.
What does this mean, the “default cart…?” This is a pattern of too early allocation of a resource. Twenty percent or fewer of visitors will ever use the cart, yet 100% of the population are allocated carts. You now have cart objects and cart resources which are dead resource allocations in the system that have to be managed, which includes clean up after a period of time/time out.
The performant design pattern is a just-in-time cart which is only created when the use either adds something to the cart or selects the cart icon to view the contents of a stored cart. Going along with this, the number of items in a perpetual cart should be persisted in a local cookie value rather than require a “pull” of the cart every time the user visits the site.