Is it possible to mock a database call or an Api call in a stress test with Gatling?

Viewed 277

I have two microservices written with Spring boot and Java working in a system. The second microservice calls a database and returns a response to the first microservice. I am writing a stress test for this system with Gatling. This stress test will call the first microservice, and the second microservice will be called by the first microservice. I need to avoid the database call at this moment. Is there any way I can mock the database call in this stress test? If mocking database of second microservice is not possible, mocking the whole second microservice call will work too. Thanks in advance.

1 Answers

I know its an old post but if you didn't find an answer

Spring conditional expressions and profiles could help you.

In your microservice app you could make a new spring profile for your gatling tests that initiate a database mock service instead of a real one when a certain property is true (eg: test.data.mock=true).

Check this documentation for Conditionnal properties

This for profiles

Related