Web proxy to simulate network problems

I need a way to model connectivity problems in an automated test suite, on Linux, and preferably from Python. Some kind of proxy server that I can put in front of a web server that can hang or remove connections after one trigger or another (after sending X bytes, etc.) would be ideal.

It's not too difficult to build, but I'd rather take something that already existed if anyone has good recommendations.

+4
source share
1 answer

when I need it, I found that its creation is the best. start by creating a streaming server in python http://docs.python.org/dev/library/socketserver.html (you don't need to use the class itself). and it is very simple: in a new connection thread, you create a new socket and connect it to a real server. then you put both of them in a list and send it to select.select (import select). then when socket x receives data - sends it to y. when socket y receives data, it sends it to x. (don't forget to close the socket when you get an empty string).

Now you can do whatever you want ..

If you need anything, I'm here.

+2
source

All Articles