We've been using protractor
for end-to-end testing for a while.
Now we are trying to cover several corner cases, which involve modifying the response from the API endpoint requests - for this we are using protractor-http-mock
which provides an easy-to-use way to replace HTTP responses with pre-defined mocks.
But, what if we want to test a situation when a sudden connection loss happens? What are our options in this case?
In other words, we want to achieve a case when requests to specific endpoints would produce a network connection error and see how our application would react.
I'm open to any suggestions, I am currently thinking of the following strategies:
protractor-http-mock
$http
angularjs servicegrunt-connect-proxy
looks pretty mature though I'm not sure if it is possible to dynamically change the behavior of the proxy from spec to spec)selenium
cannot control, Network throttling with chrome and selenium) (browser addon/extension?)Simulating a hard-down or node failure is fairly easy. All you have to do is turn off the node itself to verify how the system responds (system reconvergence). If high availability is enabled, a secondary/standby node will immediately take over and become the active node, servicing user requests.
Simulate Poor Network on iPhoneOpen the Settings app and navigate to the Developer option. Select the Network Link Conditioner under NETWORKING option. Now enable the Network Link Conditioner & choose the network profile you want, and start testing how your app works in different conditions.
Seems like the Comcast tool would provide the majority of the functionality you need:
Comcast is a tool designed to simulate common network problems like latency, bandwidth restrictions, and dropped/reordered/corrupted packets.
It works by wrapping up some system tools in a portable(ish) way. On BSD-derived systems such as OSX, we use tools like ipfw and pfctl to inject failure. On Linux, we use iptables and tc. Comcast is merely a thin wrapper around these controls.
https://github.com/tylertreat/Comcast
Example on Linux:
comcast --device=eth0 --latency=250 --target-bw=1000 --default-bw=1000000 --packet-loss=10% --target-addr=8.8.8.8,10.0.0.0/24 --target-proto=tcp,udp,icmp --target-port=80,22,1000:2000
You can change the settings on the fly and put packet loss up to 100% as needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With