CLOUDSTACK-5169: Egress rules - Improved assertion code

related to SSH to avoid assertion error
This commit is contained in:
Ashutosh K 2013-11-15 11:28:07 +05:30 committed by Girish Shilamkar
parent 1106116b48
commit 6ac099e44c
1 changed files with 9 additions and 6 deletions

View File

@ -1439,8 +1439,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
try:
self.debug("SSHing into VM type B from VM A")
self.debug("VM IP: %s" % self.virtual_machineB.ssh_ip)
res = ssh.execute("ssh %s@%s" % (
self.services["virtual_machine"]["username"],
res = ssh.execute("ssh -o 'BatchMode=yes' %s" % (
self.virtual_machineB.ssh_ip
))
self.debug("SSH result: %s" % str(res))
@ -1450,10 +1449,14 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
(self.virtual_machineA.ipaddress, e)
)
result = str(res)
self.assertEqual(
result.count("Connection timed out"),
1,
"SSH into management server from VM should not be successful"
# SSH failure may result in one of the following three error messages
ssh_failure_result_set = ["ssh: connect to host %s port 22: No route to host" % self.virtual_machineB.ssh_ip,
"ssh: connect to host %s port 22: Connection timed out" % self.virtual_machineB.ssh_ip,
"Host key verification failed."]
self.assertFalse(set(res).isdisjoint(ssh_failure_result_set),
"SSH into VM of other account should not be successful"
)
return