模拟主机无法访问 - 如何实现/实现
这是我的场景:
A 是配置服务器,B 是客户端。每当 B 的设置发生任何更改时,它都会将适当的配置文件上传到 A。
我正在作为自动化工程师来实现它的自动化。其中一种场景是断开 A 与网络的连接或停止服务器 A。对 B 进行一些更改,并确保 B 无法将文件上传到配置服务器 A。
要实现自动化,可以停止服务器 A 并执行以下操作:适当的行动。
由于 A 和 B 也被其他方用于其他目的,所以我无法断开 A 或 B 与网络的连接或停止 A 处的服务器。
因此,我期待任何解决方案,以便我可以模拟主机(配置服务器) ) 无法到达的场景。因此,当 B 向 A 发送更新时,它将失败,但实际上 A 照常运行。
请建议我一些方法来实现它。
我使用 Perl 作为编程语言,但如果有其他语言的解决方案,我也很好。
Here is my scenario:
A is a provisioning server and B is an client. Whenever there is any change in B's setup, it uploads the appropriate config file to A.
I am working as an automation engineer to automate it. One of the scenario says to disconnect A from network or stop the server A. perform some changes to B and make sure that B failed to upload the files to provisioning server A.
To automate it, the simple way to stop the server A and do the appropriate actions.
Since A and B are also used for other purposes by other parties so I can not either disconnect A or B from network OR stop the server at A.
So, I am looking forward for any solution so that I can simulate the host (provisioning server) unreachable scenario. So when B will send an update to A it will fail but in actual A is running as usual.
Please suggest me some way to achieve it.
I am using Perl as a programming language but I am fine if solution is available in other language.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在使用空路由之前已经完成了此操作。最好使用 ip 命令从 shell 完成此操作。
根据您的使用案例,无法访问的路由可能会工作得更好,因为它返回 ICMP 无法访问而不是丢弃数据包,尽管它们往往具有相同的效果。
为了彻底起见,如果您确实想模拟主机无法访问的情况(相对于网络无法访问的情况),则必须在防火墙级别执行此操作。
I've done this before using a null route. This is something that best done from the shell with the ip command.
Depending on your use case, an unreachable route may work better, as it returns ICMP-unreachable instead of discarding the packets, although they tend to have the same effect.
And for thoroughness, if you really wanted to simulate a host-unreachable situation (vs a network-unreachable), you would have to do that at the firewall level.
另一个可能更简单的选择是在执行测试时更改 B 上的配置,使 A 具有虚假的 IP 地址(例如 192.0.2.0)。
Another, perhaps easier option is to change the configuration on B to have a bogus IP address for A (e.g. 192.0.2.0) when performing the test.
Test::MockObject::Extends - 非常适合修改模块的小部分以创建特定的测试场景。对于您无法很好测试的事情非常有效,因为它们会影响生产中的事情或您无法控制的地方。
Test::MockObject::Extends - great for modifying small parts of modules to create specific testing scenarios. Works great for things that you can't test well because they affect things in production or in places that you don't control.