HACKER Q&A
📣 fr_01

Mocking upstream dependencies for load testing?


I am searching for a tool, which allows me to mock my webservice's upstream dependencies and their delays in order to load test my app without having results impacted by temporary test environment issues / issues in upstream.

I am hoping to find a tool that would allow me to do something like the following: 1. Run one test iteration invoking all my service's endpoints. 2. For every network requests made by my application, cache the response. 3. Run my real load tests using the created cache for all network requests and potentially simulate a delay (configurable, eg. run these tests and simulate a 2s delay in upstream dependency X, .5s delay in dependency Y and so on).

Any suggestions? :)


  👤 sargstuff Accepted Answer ✓
If query is just to produce output for use in app, then #1 & #2 could be done using webscraping techniques/methods.[0]

aka hash the query and assign the output of the query to blob in database

(or file with hash query id & just use script & netcat/socat to dump file to connection)

#3 is going to depend on available resources to 'fake' the server.

Using external box as server, can just hash query to get query id. Then dump what's associated with that id from database setup discussed above.

For network delays, ebpf / firewall rate limiting rules for application.connection are one approach. Alternate python/tokio examples.[1][2]

[0] simple webscraping : https://crates.io/crates/websocat

[1] https://stackoverflow.com/questions/52680888/tcp-python-sock...

[2] tokio : https://www.youtube.com/watch?v=DJzgUmH30h8