Reputation: 1639
I have a microservice architecture setup and I am looking to stress test it. I have quite a complex setup with some synchronous http requests and a message queue system (RabbitMQ).
As I am making use of the API server of another company, I do not want to run the risk of stressing their server. This request is a synchronous call which asks the API provider and returns quite a sizable response. Instead, I want to have some stub/mock which will return a similar response and with similar latency. Say, for example, a response from this server is 5s and returns 2kb of data, then I want to introduce a 5s delay and return more or less some comparatively sized data (in other words I want some customization) in that format which I have prepared.
To get to this point, I require (a) to capture a sizable response and edit it. Particularly, I want to edit it to filter out some sensitive data and also to increase its size and to make it larger so that I can stress the bandwidth aspect of the system. (b) I require to stay as close as possible to the native solution to get a good grasp of response times from this end and also I want as minimal overhead as possible when stress testing. I have been looking at some solutions like WireMock which, if my understanding is correct, set up a fake server to test against. This won't work for me as I require to use my own servers (which are TomCat based) instead to stay as close as possible to my architecture.
Upvotes: 1
Views: 1550
Reputation: 7400
Yes, Wiremock sounds like a good suggestion. For my team wiremock worked great.
I would suggest the following approach: Install Docker Spin up Wiremock in a docker container with docker-compose up. docker-compose.yaml sample:
version: "3"
services:
wiremock:
image: rodolpheche/wiremock:latest
ports:
- "8181:8080"
volumes:
- ./__files/:/./home/wiremock/__files/
- ./mappings/:/./home/wiremock/mappings/
command:
- -verbose
- -global-response-templating
docker-compose up (in the directory you saved the yaml, and accept the requests for filesystem access) then you should be ready to go.
Yor url for the Api should point to http://localhost:8181
After that do a recording with real data (http://localhost:8181/__admin/recorder)
And enter your http for the external api while recording.
Split the body to a separate file and place it in the __files folder. Point to the file with ""bodyFileName" in the request file (mappings)
After separating the wiremock datafile (__files) from the request file (mappings), you could use templating logic to enable things like date calculations (now + 1 days) in the response and other great things that make the testdata durable and reusable.
I have some suggestions here. mobileera_wiremock_kb
Also after you have capture some external api scenarios, you could set up a shared wiremock for access by other devs as well.
Upvotes: 1
Reputation: 4149
You can run WireMock inside a servlet container (including Tomcat). You lose access to some configuration properties, but that might not matter in the case you've described.
See here for details: http://wiremock.org/docs/getting-started/#Deploying-into-a-servlet-container
Alternatively you could use MockLab, which is a fully hosted service based on WireMock.
Upvotes: 1