summaryrefslogtreecommitdiff
path: root/openstackclient/tests/functional/network
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2017-04-28 12:41:57 -0500
committerDean Troyer <dtroyer@gmail.com>2017-04-28 14:40:45 -0500
commit190711ecd71af2eff4683e570ef48f041fa8d91b (patch)
tree8aed52cb833e497bee822fb4700759c532414f1d /openstackclient/tests/functional/network
parentefcf3b22ad22152331f7a42f0bfc4cc67205b8da (diff)
downloadpython-openstackclient-190711ecd71af2eff4683e570ef48f041fa8d91b.tar.gz
Nova net functional tests round 3
* network segment * network service * port * router * security group * security group rule * subnet * subnet pool * extension The extension tests were duplicated to have both compute and network extensions tests so the nova-net case will still exercise the extension commands. Also clean up formatting from previous reviews to make the Network functional tests look and act consistently. Change-Id: I286c40572faa31ddcef595cec740da933b2defc1
Diffstat (limited to 'openstackclient/tests/functional/network')
-rw-r--r--openstackclient/tests/functional/network/v2/test_address_scope.py2
-rw-r--r--openstackclient/tests/functional/network/v2/test_ip_availability.py51
-rw-r--r--openstackclient/tests/functional/network/v2/test_network.py14
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_meter_rule.py8
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_qos_policy.py26
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_qos_rule.py111
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_segment.py60
-rw-r--r--openstackclient/tests/functional/network/v2/test_network_service_provider.py10
-rw-r--r--openstackclient/tests/functional/network/v2/test_port.py27
-rw-r--r--openstackclient/tests/functional/network/v2/test_router.py12
-rw-r--r--openstackclient/tests/functional/network/v2/test_security_group.py47
-rw-r--r--openstackclient/tests/functional/network/v2/test_security_group_rule.py65
-rw-r--r--openstackclient/tests/functional/network/v2/test_subnet.py38
-rw-r--r--openstackclient/tests/functional/network/v2/test_subnet_pool.py10
14 files changed, 320 insertions, 161 deletions
diff --git a/openstackclient/tests/functional/network/v2/test_address_scope.py b/openstackclient/tests/functional/network/v2/test_address_scope.py
index e5156d7f..ebd2ba86 100644
--- a/openstackclient/tests/functional/network/v2/test_address_scope.py
+++ b/openstackclient/tests/functional/network/v2/test_address_scope.py
@@ -17,7 +17,7 @@ from openstackclient.tests.functional.network.v2 import common
class AddressScopeTests(common.NetworkTests):
- """Functional tests for address scope. """
+ """Functional tests for address scope"""
# NOTE(dtroyer): Do not normalize the setup and teardown of the resource
# creation and deletion. Little is gained when each test
diff --git a/openstackclient/tests/functional/network/v2/test_ip_availability.py b/openstackclient/tests/functional/network/v2/test_ip_availability.py
index b9cac024..1aa0f64a 100644
--- a/openstackclient/tests/functional/network/v2/test_ip_availability.py
+++ b/openstackclient/tests/functional/network/v2/test_ip_availability.py
@@ -17,31 +17,46 @@ from openstackclient.tests.functional.network.v2 import common
class IPAvailabilityTests(common.NetworkTests):
- """Functional tests for IP availability. """
+ """Functional tests for IP availability"""
@classmethod
def setUpClass(cls):
common.NetworkTests.setUpClass()
- if not cls.haz_network:
- common.NetworkTests.skipTest(cls, "No Network service present")
-
- # Create a network for the subnet.
- cls.NAME = uuid.uuid4().hex
- cls.NETWORK_NAME = uuid.uuid4().hex
- cls.openstack('network create ' + cls.NETWORK_NAME)
- cmd_output = json.loads(cls.openstack(
- 'subnet create -f json --network ' + cls.NETWORK_NAME +
- ' --subnet-range 10.10.10.0/24 ' +
- cls.NAME
- ))
- cls.assertOutput(cls.NAME, cmd_output['name'])
+ if cls.haz_network:
+ # Create a network for the subnet.
+ cls.NAME = uuid.uuid4().hex
+ cls.NETWORK_NAME = uuid.uuid4().hex
+ cls.openstack(
+ 'network create ' +
+ cls.NETWORK_NAME
+ )
+ cmd_output = json.loads(cls.openstack(
+ 'subnet create -f json ' +
+ '--network ' + cls.NETWORK_NAME + ' ' +
+ '--subnet-range 10.10.10.0/24 ' +
+ cls.NAME
+ ))
+ cls.assertOutput(cls.NAME, cmd_output['name'])
@classmethod
def tearDownClass(cls):
- raw_subnet = cls.openstack('subnet delete ' + cls.NAME)
- raw_network = cls.openstack('network delete ' + cls.NETWORK_NAME)
- cls.assertOutput('', raw_subnet)
- cls.assertOutput('', raw_network)
+ if cls.haz_network:
+ raw_subnet = cls.openstack(
+ 'subnet delete ' +
+ cls.NAME
+ )
+ raw_network = cls.openstack(
+ 'network delete ' +
+ cls.NETWORK_NAME
+ )
+ cls.assertOutput('', raw_subnet)
+ cls.assertOutput('', raw_network)
+
+ def setUp(self):
+ super(IPAvailabilityTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_ip_availability_list(self):
"""Test ip availability list"""
diff --git a/openstackclient/tests/functional/network/v2/test_network.py b/openstackclient/tests/functional/network/v2/test_network.py
index 91500e0d..b23323a0 100644
--- a/openstackclient/tests/functional/network/v2/test_network.py
+++ b/openstackclient/tests/functional/network/v2/test_network.py
@@ -13,17 +13,17 @@
import json
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class NetworkTests(base.TestCase):
+class NetworkTests(common.NetworkTests):
"""Functional tests for network"""
- @classmethod
- def setUpClass(cls):
- cls.haz_network = base.is_service_enabled('network')
- cls.PROJECT_NAME =\
- cls.get_openstack_configuration_value('auth.project_name')
+ def setUp(self):
+ super(NetworkTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_network_create_compute(self):
"""Test Nova-net create options, delete"""
diff --git a/openstackclient/tests/functional/network/v2/test_network_meter_rule.py b/openstackclient/tests/functional/network/v2/test_network_meter_rule.py
index f0c1aa2f..b7090707 100644
--- a/openstackclient/tests/functional/network/v2/test_network_meter_rule.py
+++ b/openstackclient/tests/functional/network/v2/test_network_meter_rule.py
@@ -31,7 +31,8 @@ class TestMeterRule(common.NetworkTests):
common.NetworkTests.setUpClass()
if cls.haz_network:
json_output = json.loads(cls.openstack(
- 'network meter create -f json ' + cls.METER_NAME
+ 'network meter create -f json ' +
+ cls.METER_NAME
))
cls.METER_ID = json_output.get('id')
@@ -39,7 +40,10 @@ class TestMeterRule(common.NetworkTests):
def tearDownClass(cls):
common.NetworkTests.tearDownClass()
if cls.haz_network:
- raw_output = cls.openstack('network meter delete ' + cls.METER_ID)
+ raw_output = cls.openstack(
+ 'network meter delete ' +
+ cls.METER_ID
+ )
cls.assertOutput('', raw_output)
def setUp(self):
diff --git a/openstackclient/tests/functional/network/v2/test_network_qos_policy.py b/openstackclient/tests/functional/network/v2/test_network_qos_policy.py
index e5b97573..282efbfa 100644
--- a/openstackclient/tests/functional/network/v2/test_network_qos_policy.py
+++ b/openstackclient/tests/functional/network/v2/test_network_qos_policy.py
@@ -27,10 +27,23 @@ class NetworkQosPolicyTests(common.NetworkTests):
@classmethod
def setUpClass(cls):
common.NetworkTests.setUpClass()
- opts = cls.get_opts(cls.FIELDS)
- raw_output = cls.openstack('network qos policy create ' + cls.NAME +
- opts)
- cls.assertOutput(cls.NAME + "\n", raw_output)
+ if cls.haz_network:
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack(
+ 'network qos policy create ' +
+ cls.NAME +
+ opts
+ )
+ cls.assertOutput(cls.NAME + "\n", raw_output)
+
+ @classmethod
+ def tearDownClass(cls):
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network qos policy delete ' +
+ cls.NAME
+ )
+ cls.assertOutput('', raw_output)
def setUp(self):
super(NetworkQosPolicyTests, self).setUp()
@@ -38,11 +51,6 @@ class NetworkQosPolicyTests(common.NetworkTests):
if not self.haz_network:
self.skipTest("No Network service present")
- @classmethod
- def tearDownClass(cls):
- raw_output = cls.openstack('network qos policy delete ' + cls.NAME)
- cls.assertOutput('', raw_output)
-
def test_qos_policy_list(self):
opts = self.get_opts(self.HEADERS)
raw_output = self.openstack('network qos policy list' + opts)
diff --git a/openstackclient/tests/functional/network/v2/test_network_qos_rule.py b/openstackclient/tests/functional/network/v2/test_network_qos_rule.py
index f0506356..c6437d9c 100644
--- a/openstackclient/tests/functional/network/v2/test_network_qos_rule.py
+++ b/openstackclient/tests/functional/network/v2/test_network_qos_rule.py
@@ -19,7 +19,7 @@ from openstackclient.tests.functional.network.v2 import common
class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests):
- """Functional tests for QoS minimum bandwidth rule."""
+ """Functional tests for QoS minimum bandwidth rule"""
RULE_ID = None
QOS_POLICY_NAME = 'qos_policy_' + uuid.uuid4().hex
MIN_KBPS = 2800
@@ -32,20 +32,35 @@ class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests):
@classmethod
def setUpClass(cls):
common.NetworkTests.setUpClass()
- opts = cls.get_opts(cls.FIELDS)
- cls.openstack('network qos policy create ' + cls.QOS_POLICY_NAME)
- cls.RULE_ID = cls.openstack('network qos rule create --type ' +
- cls.TYPE + ' --min-kbps ' +
- str(cls.MIN_KBPS) + ' ' + cls.DIRECTION +
- ' ' + cls.QOS_POLICY_NAME + opts)
- cls.assertsOutputNotNone(cls.RULE_ID)
+ if cls.haz_network:
+ opts = cls.get_opts(cls.FIELDS)
+ cls.openstack(
+ 'network qos policy create ' +
+ cls.QOS_POLICY_NAME
+ )
+ cls.RULE_ID = cls.openstack(
+ 'network qos rule create ' +
+ '--type ' + cls.TYPE + ' ' +
+ '--min-kbps ' + str(cls.MIN_KBPS) + ' ' +
+ cls.DIRECTION + ' ' +
+ cls.QOS_POLICY_NAME +
+ opts
+ )
+ cls.assertsOutputNotNone(cls.RULE_ID)
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('network qos rule delete ' +
- cls.QOS_POLICY_NAME + ' ' + cls.RULE_ID)
- cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network qos rule delete ' +
+ cls.QOS_POLICY_NAME + ' ' +
+ cls.RULE_ID
+ )
+ cls.openstack(
+ 'network qos policy delete ' +
+ cls.QOS_POLICY_NAME
+ )
+ cls.assertOutput('', raw_output)
def setUp(self):
super(NetworkQosRuleTestsMinimumBandwidth, self).setUp()
@@ -78,7 +93,7 @@ class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests):
class NetworkQosRuleTestsDSCPMarking(common.NetworkTests):
- """Functional tests for QoS DSCP marking rule."""
+ """Functional tests for QoS DSCP marking rule"""
RULE_ID = None
QOS_POLICY_NAME = 'qos_policy_' + uuid.uuid4().hex
DSCP_MARK = 8
@@ -90,20 +105,31 @@ class NetworkQosRuleTestsDSCPMarking(common.NetworkTests):
@classmethod
def setUpClass(cls):
common.NetworkTests.setUpClass()
- opts = cls.get_opts(cls.FIELDS)
- cls.openstack('network qos policy create ' + cls.QOS_POLICY_NAME)
- cls.RULE_ID = cls.openstack('network qos rule create --type ' +
- cls.TYPE + ' --dscp-mark ' +
- str(cls.DSCP_MARK) + ' ' +
- cls.QOS_POLICY_NAME + opts)
- cls.assertsOutputNotNone(cls.RULE_ID)
+ if cls.haz_network:
+ opts = cls.get_opts(cls.FIELDS)
+ cls.openstack(
+ 'network qos policy create ' +
+ cls.QOS_POLICY_NAME
+ )
+ cls.RULE_ID = cls.openstack(
+ 'network qos rule create ' +
+ '--type ' + cls.TYPE + ' ' +
+ '--dscp-mark ' + str(cls.DSCP_MARK) + ' ' +
+ cls.QOS_POLICY_NAME +
+ opts
+ )
+ cls.assertsOutputNotNone(cls.RULE_ID)
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('network qos rule delete ' +
- cls.QOS_POLICY_NAME + ' ' + cls.RULE_ID)
- cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network qos rule delete ' +
+ cls.QOS_POLICY_NAME + ' ' +
+ cls.RULE_ID
+ )
+ cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME)
+ cls.assertOutput('', raw_output)
def setUp(self):
super(NetworkQosRuleTestsDSCPMarking, self).setUp()
@@ -136,7 +162,7 @@ class NetworkQosRuleTestsDSCPMarking(common.NetworkTests):
class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests):
- """Functional tests for QoS bandwidth limit rule."""
+ """Functional tests for QoS bandwidth limit rule"""
RULE_ID = None
QOS_POLICY_NAME = 'qos_policy_' + uuid.uuid4().hex
MAX_KBPS = 10000
@@ -150,21 +176,32 @@ class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests):
@classmethod
def setUpClass(cls):
common.NetworkTests.setUpClass()
- opts = cls.get_opts(cls.FIELDS)
- cls.openstack('network qos policy create ' + cls.QOS_POLICY_NAME)
- cls.RULE_ID = cls.openstack('network qos rule create --type ' +
- cls.TYPE + ' --max-kbps ' +
- str(cls.MAX_KBPS) + ' --max-burst-kbits ' +
- str(cls.MAX_BURST_KBITS) + ' ' +
- cls.QOS_POLICY_NAME + opts)
- cls.assertsOutputNotNone(cls.RULE_ID)
+ if cls.haz_network:
+ opts = cls.get_opts(cls.FIELDS)
+ cls.openstack(
+ 'network qos policy create ' +
+ cls.QOS_POLICY_NAME
+ )
+ cls.RULE_ID = cls.openstack(
+ 'network qos rule create ' +
+ '--type ' + cls.TYPE + ' ' +
+ '--max-kbps ' + str(cls.MAX_KBPS) + ' ' +
+ '--max-burst-kbits ' + str(cls.MAX_BURST_KBITS) + ' ' +
+ cls.QOS_POLICY_NAME +
+ opts
+ )
+ cls.assertsOutputNotNone(cls.RULE_ID)
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('network qos rule delete ' +
- cls.QOS_POLICY_NAME + ' ' + cls.RULE_ID)
- cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network qos rule delete ' +
+ cls.QOS_POLICY_NAME + ' ' +
+ cls.RULE_ID
+ )
+ cls.openstack('network qos policy delete ' + cls.QOS_POLICY_NAME)
+ cls.assertOutput('', raw_output)
def setUp(self):
super(NetworkQosRuleTestsBandwidthLimit, self).setUp()
diff --git a/openstackclient/tests/functional/network/v2/test_network_segment.py b/openstackclient/tests/functional/network/v2/test_network_segment.py
index b6f19ac4..de150d31 100644
--- a/openstackclient/tests/functional/network/v2/test_network_segment.py
+++ b/openstackclient/tests/functional/network/v2/test_network_segment.py
@@ -12,11 +12,11 @@
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class NetworkSegmentTests(base.TestCase):
- """Functional tests for network segment. """
+class NetworkSegmentTests(common.NetworkTests):
+ """Functional tests for network segment"""
NETWORK_NAME = uuid.uuid4().hex
PHYSICAL_NETWORK_NAME = uuid.uuid4().hex
NETWORK_SEGMENT_ID = None
@@ -25,30 +25,46 @@ class NetworkSegmentTests(base.TestCase):
@classmethod
def setUpClass(cls):
- # Create a network for the segment.
- opts = cls.get_opts(['id'])
- raw_output = cls.openstack('network create ' + cls.NETWORK_NAME + opts)
- cls.NETWORK_ID = raw_output.strip('\n')
+ common.NetworkTests.setUpClass()
+ if cls.haz_network:
+ # Create a network for the segment.
+ opts = cls.get_opts(['id'])
+ raw_output = cls.openstack(
+ 'network create ' + cls.NETWORK_NAME + opts
+ )
+ cls.NETWORK_ID = raw_output.strip('\n')
- # NOTE(rtheis): The segment extension is not yet enabled by default.
- # Skip the tests if not enabled.
- extensions = cls.get_openstack_extention_names()
- if 'Segment' in extensions:
- cls.NETWORK_SEGMENT_EXTENSION = 'Segment'
+ # NOTE(rtheis): The segment extension is not yet enabled
+ # by default.
+ # Skip the tests if not enabled.
+ extensions = cls.get_openstack_extention_names()
+ if 'Segment' in extensions:
+ cls.NETWORK_SEGMENT_EXTENSION = 'Segment'
- if cls.NETWORK_SEGMENT_EXTENSION:
- # Get the segment for the network.
- opts = cls.get_opts(['ID', 'Network'])
- raw_output = cls.openstack('network segment list '
- ' --network ' + cls.NETWORK_NAME +
- ' ' + opts)
- raw_output_row = raw_output.split('\n')[0]
- cls.NETWORK_SEGMENT_ID = raw_output_row.split(' ')[0]
+ if cls.NETWORK_SEGMENT_EXTENSION:
+ # Get the segment for the network.
+ opts = cls.get_opts(['ID', 'Network'])
+ raw_output = cls.openstack(
+ 'network segment list '
+ '--network ' + cls.NETWORK_NAME + ' ' +
+ opts
+ )
+ raw_output_row = raw_output.split('\n')[0]
+ cls.NETWORK_SEGMENT_ID = raw_output_row.split(' ')[0]
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network delete ' + cls.NETWORK_NAME
+ )
+ cls.assertOutput('', raw_output)
+
+ def setUp(self):
+ super(NetworkSegmentTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_network_segment_create_delete(self):
if self.NETWORK_SEGMENT_EXTENSION:
diff --git a/openstackclient/tests/functional/network/v2/test_network_service_provider.py b/openstackclient/tests/functional/network/v2/test_network_service_provider.py
index 6fbff6c8..8ed44dd9 100644
--- a/openstackclient/tests/functional/network/v2/test_network_service_provider.py
+++ b/openstackclient/tests/functional/network/v2/test_network_service_provider.py
@@ -13,14 +13,20 @@
# License for the specific language governing permissions and limitations
# under the License.
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class TestNetworkServiceProvider(base.TestCase):
+class TestNetworkServiceProvider(common.NetworkTests):
"""Functional tests for network service provider"""
SERVICE_TYPE = 'L3_ROUTER_NAT'
+ def setUp(self):
+ super(TestNetworkServiceProvider, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
+
def test_network_service_provider_list(self):
raw_output = self.openstack('network service provider list')
self.assertIn(self.SERVICE_TYPE, raw_output)
diff --git a/openstackclient/tests/functional/network/v2/test_port.py b/openstackclient/tests/functional/network/v2/test_port.py
index 62c0cbe5..6659e3e0 100644
--- a/openstackclient/tests/functional/network/v2/test_port.py
+++ b/openstackclient/tests/functional/network/v2/test_port.py
@@ -13,23 +13,36 @@
import json
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class PortTests(base.TestCase):
- """Functional tests for port. """
+class PortTests(common.NetworkTests):
+ """Functional tests for port"""
NAME = uuid.uuid4().hex
NETWORK_NAME = uuid.uuid4().hex
@classmethod
def setUpClass(cls):
- # Create a network for the port
- cls.openstack('network create ' + cls.NETWORK_NAME)
+ common.NetworkTests.setUpClass()
+ if cls.haz_network:
+ # Create a network for the port
+ cls.openstack(
+ 'network create ' + cls.NETWORK_NAME
+ )
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network delete ' + cls.NETWORK_NAME
+ )
+ cls.assertOutput('', raw_output)
+
+ def setUp(self):
+ super(PortTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_port_delete(self):
"""Test create, delete multiple"""
diff --git a/openstackclient/tests/functional/network/v2/test_router.py b/openstackclient/tests/functional/network/v2/test_router.py
index aa708e0a..313feefc 100644
--- a/openstackclient/tests/functional/network/v2/test_router.py
+++ b/openstackclient/tests/functional/network/v2/test_router.py
@@ -13,11 +13,17 @@
import json
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class RouterTests(base.TestCase):
- """Functional tests for router. """
+class RouterTests(common.NetworkTests):
+ """Functional tests for router"""
+
+ def setUp(self):
+ super(RouterTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_router_create_and_delete(self):
"""Test create options, delete multiple"""
diff --git a/openstackclient/tests/functional/network/v2/test_security_group.py b/openstackclient/tests/functional/network/v2/test_security_group.py
index debd81df..2a9c0b0a 100644
--- a/openstackclient/tests/functional/network/v2/test_security_group.py
+++ b/openstackclient/tests/functional/network/v2/test_security_group.py
@@ -12,11 +12,11 @@
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class SecurityGroupTests(base.TestCase):
- """Functional tests for security group. """
+class SecurityGroupTests(common.NetworkTests):
+ """Functional tests for security group"""
NAME = uuid.uuid4().hex
OTHER_NAME = uuid.uuid4().hex
HEADERS = ['Name']
@@ -24,20 +24,39 @@ class SecurityGroupTests(base.TestCase):
@classmethod
def setUpClass(cls):
- opts = cls.get_opts(cls.FIELDS)
- raw_output = cls.openstack('security group create ' + cls.NAME + opts)
- expected = cls.NAME + '\n'
- cls.assertOutput(expected, raw_output)
+ common.NetworkTests.setUpClass()
+ if cls.haz_network:
+ opts = cls.get_opts(cls.FIELDS)
+ raw_output = cls.openstack(
+ 'security group create ' +
+ cls.NAME +
+ opts
+ )
+ expected = cls.NAME + '\n'
+ cls.assertOutput(expected, raw_output)
@classmethod
def tearDownClass(cls):
- # Rename test
- raw_output = cls.openstack('security group set --name ' +
- cls.OTHER_NAME + ' ' + cls.NAME)
- cls.assertOutput('', raw_output)
- # Delete test
- raw_output = cls.openstack('security group delete ' + cls.OTHER_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ # Rename test
+ raw_output = cls.openstack(
+ 'security group set --name ' +
+ cls.OTHER_NAME + ' ' +
+ cls.NAME
+ )
+ cls.assertOutput('', raw_output)
+ # Delete test
+ raw_output = cls.openstack(
+ 'security group delete ' +
+ cls.OTHER_NAME
+ )
+ cls.assertOutput('', raw_output)
+
+ def setUp(self):
+ super(SecurityGroupTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_security_group_list(self):
opts = self.get_opts(self.HEADERS)
diff --git a/openstackclient/tests/functional/network/v2/test_security_group_rule.py b/openstackclient/tests/functional/network/v2/test_security_group_rule.py
index c91de1a5..93f98642 100644
--- a/openstackclient/tests/functional/network/v2/test_security_group_rule.py
+++ b/openstackclient/tests/functional/network/v2/test_security_group_rule.py
@@ -12,11 +12,11 @@
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class SecurityGroupRuleTests(base.TestCase):
- """Functional tests for security group rule. """
+class SecurityGroupRuleTests(common.NetworkTests):
+ """Functional tests for security group rule"""
SECURITY_GROUP_NAME = uuid.uuid4().hex
SECURITY_GROUP_RULE_ID = None
NAME_FIELD = ['name']
@@ -25,32 +25,49 @@ class SecurityGroupRuleTests(base.TestCase):
@classmethod
def setUpClass(cls):
- # Create the security group to hold the rule.
- opts = cls.get_opts(cls.NAME_FIELD)
- raw_output = cls.openstack('security group create ' +
- cls.SECURITY_GROUP_NAME +
- opts)
- expected = cls.SECURITY_GROUP_NAME + '\n'
- cls.assertOutput(expected, raw_output)
+ common.NetworkTests.setUpClass()
+ if cls.haz_network:
+ # Create the security group to hold the rule.
+ opts = cls.get_opts(cls.NAME_FIELD)
+ raw_output = cls.openstack(
+ 'security group create ' +
+ cls.SECURITY_GROUP_NAME +
+ opts
+ )
+ expected = cls.SECURITY_GROUP_NAME + '\n'
+ cls.assertOutput(expected, raw_output)
- # Create the security group rule.
- opts = cls.get_opts(cls.ID_FIELD)
- raw_output = cls.openstack('security group rule create ' +
- cls.SECURITY_GROUP_NAME +
- ' --protocol tcp --dst-port 80:80' +
- ' --ingress --ethertype IPv4' +
- opts)
- cls.SECURITY_GROUP_RULE_ID = raw_output.strip('\n')
+ # Create the security group rule.
+ opts = cls.get_opts(cls.ID_FIELD)
+ raw_output = cls.openstack(
+ 'security group rule create ' +
+ cls.SECURITY_GROUP_NAME + ' ' +
+ '--protocol tcp --dst-port 80:80 ' +
+ '--ingress --ethertype IPv4 ' +
+ opts
+ )
+ cls.SECURITY_GROUP_RULE_ID = raw_output.strip('\n')
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('security group rule delete ' +
- cls.SECURITY_GROUP_RULE_ID)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'security group rule delete ' +
+ cls.SECURITY_GROUP_RULE_ID
+ )
+ cls.assertOutput('', raw_output)
- raw_output = cls.openstack('security group delete ' +
- cls.SECURITY_GROUP_NAME)
- cls.assertOutput('', raw_output)
+ raw_output = cls.openstack(
+ 'security group delete ' +
+ cls.SECURITY_GROUP_NAME
+ )
+ cls.assertOutput('', raw_output)
+
+ def setUp(self):
+ super(SecurityGroupRuleTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_security_group_rule_list(self):
opts = self.get_opts(self.ID_HEADER)
diff --git a/openstackclient/tests/functional/network/v2/test_subnet.py b/openstackclient/tests/functional/network/v2/test_subnet.py
index 61cffcde..5160042c 100644
--- a/openstackclient/tests/functional/network/v2/test_subnet.py
+++ b/openstackclient/tests/functional/network/v2/test_subnet.py
@@ -14,27 +14,39 @@ import json
import random
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class SubnetTests(base.TestCase):
- """Functional tests for subnet. """
+class SubnetTests(common.NetworkTests):
+ """Functional tests for subnet"""
@classmethod
def setUpClass(cls):
- # Create a network for the all subnet tests.
- cls.NETWORK_NAME = uuid.uuid4().hex
- cmd_output = json.loads(cls.openstack(
- 'network create -f json ' +
- cls.NETWORK_NAME
- ))
- # Get network_id for assertEqual
- cls.NETWORK_ID = cmd_output["id"]
+ common.NetworkTests.setUpClass()
+ if cls.haz_network:
+ # Create a network for the all subnet tests
+ cls.NETWORK_NAME = uuid.uuid4().hex
+ cmd_output = json.loads(cls.openstack(
+ 'network create -f json ' +
+ cls.NETWORK_NAME
+ ))
+ # Get network_id for assertEqual
+ cls.NETWORK_ID = cmd_output["id"]
@classmethod
def tearDownClass(cls):
- raw_output = cls.openstack('network delete ' + cls.NETWORK_NAME)
- cls.assertOutput('', raw_output)
+ if cls.haz_network:
+ raw_output = cls.openstack(
+ 'network delete ' +
+ cls.NETWORK_NAME
+ )
+ cls.assertOutput('', raw_output)
+
+ def setUp(self):
+ super(SubnetTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
def test_subnet_create_and_delete(self):
"""Test create, delete multiple"""
diff --git a/openstackclient/tests/functional/network/v2/test_subnet_pool.py b/openstackclient/tests/functional/network/v2/test_subnet_pool.py
index d68ca01c..640f68b7 100644
--- a/openstackclient/tests/functional/network/v2/test_subnet_pool.py
+++ b/openstackclient/tests/functional/network/v2/test_subnet_pool.py
@@ -14,12 +14,18 @@ import json
import random
import uuid
-from openstackclient.tests.functional import base
+from openstackclient.tests.functional.network.v2 import common
-class SubnetPoolTests(base.TestCase):
+class SubnetPoolTests(common.NetworkTests):
"""Functional tests for subnet pool"""
+ def setUp(self):
+ super(SubnetPoolTests, self).setUp()
+ # Nothing in this class works with Nova Network
+ if not self.haz_network:
+ self.skipTest("No Network service present")
+
def test_subnet_pool_create_delete(self):
"""Test create, delete"""
name1 = uuid.uuid4().hex