Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions test/integration/component/test_security_groups.py
100644 → 100755
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,7 @@
import time
import subprocess
import socket
import platform


class TestDefaultSecurityGroup(cloudstackTestCase):
Expand DownExpand Up@@ -1338,9 +1339,13 @@ def test_01_authorizeIngressRule_AfterDeployVM(self):
# User should be able to ping VM
try:
self.debug("Trying to ping VM %s" % self.virtual_machine.ssh_ip)
result = subprocess.call(
['ping', '-c 1', self.virtual_machine.ssh_ip])

platform_type = platform.system().lower()
if platform_type == 'windows':
result = subprocess.call(
['ping', '-n', '1', self.virtual_machine.ssh_ip])
else:
result = subprocess.call(
['ping', '-c 1', self.virtual_machine.ssh_ip])
self.debug("Ping result: %s" % result)
# if ping successful, then result should be 0
self.assertEqual(
Expand DownExpand Up@@ -1462,40 +1467,44 @@ def test_02_revokeIngressRule_AfterDeployVM(self):
# User should be able to ping VM
try:
self.debug("Trying to ping VM %s" % self.virtual_machine.ssh_ip)
result = subprocess.call(
['ping', '-c 1', self.virtual_machine.ssh_ip])

platform_type = platform.system().lower()
if platform_type == 'windows':
result = subprocess.call(
['ping', '-n', '1', self.virtual_machine.ssh_ip])
else:
result = subprocess.call(
['ping', '-c 1', self.virtual_machine.ssh_ip])
self.debug("Ping result: %s" % result)
# if ping successful, then result should be 0
self.assertEqual(
result,
0,
"Check if ping is successful or not"
)

except Exception as e:
self.fail("Ping failed for ingress rule ID: %s, %s"
% (icmp_rule["ruleid"], e))

self.debug(
"Revoke Ingress Rule for Security Group %s for account: %s"
% (
security_group.id,
self.account.name
))

result = security_group.revoke(
self.apiclient,
id=icmp_rule["ruleid"]
)
self.debug("Revoke ingress rule result: %s" % result)

time.sleep(self.testdata["sleep"])
# User should not be able to ping VM
try:
self.debug("Trying to ping VM %s" % self.virtual_machine.ssh_ip)
result = subprocess.call(
['ping', '-c 1', self.virtual_machine.ssh_ip])
if platform_type == 'windows':
result = subprocess.call(
['ping', '-n', '1', self.virtual_machine.ssh_ip])
else:
result = subprocess.call(
['ping', '-c 1', self.virtual_machine.ssh_ip])

self.debug("Ping result: %s" % result)
# if ping successful, then result should be 0
Expand All@@ -1504,7 +1513,6 @@ def test_02_revokeIngressRule_AfterDeployVM(self):
0,
"Check if ping is successful or not"
)

except Exception as e:
self.fail("Ping failed for ingress rule ID: %s, %s"
% (icmp_rule["ruleid"], e))
Expand DownExpand Up@@ -1816,7 +1824,7 @@ def test_ingress_rules_specific_IP_set(self):
)
except Exception as e:
self.fail("SSH Access failed for %s: %s" %
(self.virtual_machine.ipaddress, e)
(virtual_machine_1.ipaddress, e)
)

try:
Expand All@@ -1828,7 +1836,7 @@ def test_ingress_rules_specific_IP_set(self):
)
except Exception as e:
self.fail("SSH Access failed for %s: %s" %
(self.virtual_machine.ipaddress, e)
(virtual_machine_2.ipaddress, e)
)

sshClient = SshClient(
Expand DownExpand Up@@ -1991,7 +1999,7 @@ def test_ingress_rules_specific_IP_set_non_def_sec_group(self):
)
except Exception as e:
self.fail("SSH Access failed for %s: %s" %
(self.virtual_machine.ipaddress, e)
(virtual_machine_1.ipaddress, e)
)

try:
Expand All@@ -2003,7 +2011,7 @@ def test_ingress_rules_specific_IP_set_non_def_sec_group(self):
)
except Exception as e:
self.fail("SSH Access failed for %s: %s" %
(self.virtual_machine.ipaddress, e)
(virtual_machine_2.ipaddress, e)
)

sshClient = SshClient(
Expand Down