阻止外部 Web 服务以模拟“宕机”的策略在测试场景期间?
我正在努力将来自外部 Web 服务的数据集成到我的应用程序的客户端中。有人让我测试服务不可用或宕机时的情况。在我们运行测试以查看服务如何降级时,有人对如何暂时阻止该网站有任何建议吗?
对于那些好奇的人,我们正在针对虚拟地球进行测试,但谷歌地图但这适用于任何同样复杂的外部服务。
欢迎任何想法和建议
I am working to integrate data from an external web service in the client side of my appliction. Someone asked me to test the condition when the service is unavailable or down. Anyone have any tips on how to block this site temporarily while we run the test to see how the service degrades?
For those curious we are testing against Virtual Earth, but Google Maps but this would apply to any equally complicated external service.
any thoughts and suggestions are welcome
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建一些 Mock-Webservice 类或接口(以及注入 它)。在那里,您可以测试系统对 Web 服务故障的响应,以及如果 Web 服务请求花费的时间超过预期或实际超时时会发生什么情况。
关于模拟测试的 DeveloperWorks 文章:http://www.ibm.com/developerworks/库/j-mocktest.html
Create some Mock-Webservice class or interface (and inject it). In there, you could test the response of your system to webservice failures and also what happens, if a web-service request take longer than expected or actually time-out.
DeveloperWorks article on mock testing: http://www.ibm.com/developerworks/library/j-mocktest.html
您需要确保测试最常见的故障模式:
这些只是我能想到的一些常见的故障模式都会以不同的行为表现出来,您可能希望让您的应用程序显式处理这些行为。
如果您在调用者和服务之间设置一台计算机来在它们之间进行路由,则可以清楚地模拟每种故障模式并修改您的应用程序来处理它们。
You need to be sure to test the most common failure modes for this:
Those are just a few common failure modes I could think of that will all manifest themselves with different behaviors that you may wish to have your application handle explicitly.
If you set up a computer between the caller and service that routes between them, you can simulate each of these failure modes distinctly and modify your application to handle them.
通过在
hosts
文件中添加无意义的条目来阻止相关域名怎么样?How about blocking the domain name(s) in question by putting a nonsense entry into the
hosts
file?