Simulating variable network conditions in tests
I'm writing an app on GAE/J with GWT. On my dev machines, things work perfectly - and RPCs always return successfully, and in the same order. When I deploy to appengine, some RPCs fail, and they often re开发者_JAVA百科turn in a different order.
How can a testing environment incorporate this kind of variability? Are there any good tools that can handle this for appengine?
NIST Net is a mature network emulator.
Quiting from their site:
The NIST Net network emulator is a general-purpose tool for emulating performance dynamics in IP networks. The tool is designed to allow controlled, reproducible experiments with network performance sensitive/adaptive applications and control protocols in a simple laboratory setting. By operating at the IP level, NIST Net can emulate the critical end-to-end performance characteristics imposed by various wide area network situations (e.g., congestion loss) or by various underlying subnetwork technologies (e.g., asymmetric bandwidth situations of xDSL and cable modems).
Take a look at WANem:
WANem is a Wide Area Network Emulator, meant to provide a real experience of a Wide Area Network/Internet, during application development / testing over a LAN environment. Typically application developers develop applications on a LAN while the intended purpose for the same could be, clients accessing the same over the WAN or even the Internet. WANem thus allows the application development team to setup a transparent application gateway which can be used to simulate WAN characteristics like Network delay, Packet loss, Packet corruption, Disconnections, Packet re-ordering, Jitter, etc. WANem can be used to simulate Wide Area Network conditions for Data/Voice traffic and is released under the widely acceptable GPL v2 license.
http://wanem.sourceforge.net/
netem is part of the major Linux distris. You can discard, duplicate, reorder, and delay IP packets with some probability. The error model is not that realistic, but should be sufficient to test applications. Sloppy seems to be useful as well, but I haven't tried it.
I think JMockit is a good utility for you to simulate the variable network conditions. But I'm not sure it fits your development environment.
The variable network conditions, of course, need to be collected from the reality.
精彩评论