Clean up the changes of os.environ in functional tests
Use fixtures to restore the API version changes of os.environ in each functional tests, aims to avoid the following test cases failing in unexpected context. And make sure setUpClass/tearDownClass call super class's corresponding methods first. Change-Id: Ie248fe9d3a9e25f1b076c9f2c363200f29a83817 Closes-Bug: #1696080
This commit is contained in:
parent
ac8cac4b63
commit
f1d32dbe9b
@ -25,6 +25,7 @@ class ExtensionTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(ExtensionTests, cls).setUpClass()
|
||||
cls.haz_network = base.is_service_enabled('network')
|
||||
|
||||
def test_extension_list_compute(self):
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
import os
|
||||
|
||||
import fixtures
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
|
||||
|
||||
@ -76,10 +78,11 @@ class HelpTests(base.TestCase):
|
||||
|
||||
def test_commands_help_no_auth(self):
|
||||
"""Check help commands without auth info."""
|
||||
# Pop all auth info
|
||||
auth_info = {key: os.environ.pop(key)
|
||||
for key in os.environ.keys()
|
||||
if key.startswith('OS_')}
|
||||
# Pop all auth info. os.environ will be changed in loop, so do not
|
||||
# replace os.environ.keys() to os.environ
|
||||
for key in os.environ.keys():
|
||||
if key.startswith('OS_'):
|
||||
self.useFixture(fixtures.EnvironmentVariable(key, None))
|
||||
|
||||
raw_output = self.openstack('help')
|
||||
self.assertIn('usage: openstack', raw_output)
|
||||
@ -115,6 +118,3 @@ class HelpTests(base.TestCase):
|
||||
self.assertIn('List containers', raw_output)
|
||||
raw_output = self.openstack('container list --help')
|
||||
self.assertIn('List containers', raw_output)
|
||||
|
||||
# Restore auth info
|
||||
os.environ.update(auth_info)
|
||||
|
@ -26,6 +26,7 @@ class QuotaTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(QuotaTests, cls).setUpClass()
|
||||
cls.haz_network = base.is_service_enabled('network')
|
||||
cls.PROJECT_NAME =\
|
||||
cls.get_openstack_configuration_value('auth.project_name')
|
||||
|
@ -23,6 +23,7 @@ class FlavorTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(FlavorTests, cls).setUpClass()
|
||||
# Make a project
|
||||
cmd_output = json.loads(cls.openstack(
|
||||
"project create -f json --enable " + cls.PROJECT_NAME
|
||||
@ -31,8 +32,11 @@ class FlavorTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
raw_output = cls.openstack("project delete " + cls.PROJECT_NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
raw_output = cls.openstack("project delete " + cls.PROJECT_NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(FlavorTests, cls).tearDownClass()
|
||||
|
||||
def test_flavor_delete(self):
|
||||
"""Test create w/project, delete multiple"""
|
||||
|
@ -25,6 +25,7 @@ class ServerTests(common.ComputeTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(ServerTests, cls).setUpClass()
|
||||
cls.haz_network = base.is_service_enabled('network')
|
||||
|
||||
def test_server_list(self):
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import os
|
||||
|
||||
import fixtures
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib import exceptions as tempest_exceptions
|
||||
|
||||
@ -41,17 +42,13 @@ class IdentityTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# prepare v2 env
|
||||
os.environ['OS_IDENTITY_API_VERSION'] = '2.0'
|
||||
auth_url = os.environ.get('OS_AUTH_URL')
|
||||
if auth_url:
|
||||
os.environ['OS_AUTH_URL'] = auth_url.replace('v3', 'v2.0')
|
||||
|
||||
super(IdentityTests, cls).setUpClass()
|
||||
# create dummy project
|
||||
cls.project_name = data_utils.rand_name('TestProject')
|
||||
cls.project_description = data_utils.rand_name('description')
|
||||
try:
|
||||
cls.openstack(
|
||||
'--os-identity-api-version 2 '
|
||||
'project create '
|
||||
'--description %(description)s '
|
||||
'--enable '
|
||||
@ -69,7 +66,25 @@ class IdentityTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.openstack('project delete %s' % cls.project_name)
|
||||
try:
|
||||
cls.openstack(
|
||||
'--os-identity-api-version 2 '
|
||||
'project delete %s' % cls.project_name)
|
||||
finally:
|
||||
super(IdentityTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(IdentityTests, self).setUp()
|
||||
# prepare v2 env
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_IDENTITY_API_VERSION', '2.0')
|
||||
self.useFixture(ver_fixture)
|
||||
auth_url = os.environ.get('OS_AUTH_URL')
|
||||
if auth_url:
|
||||
auth_url_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_AUTH_URL', auth_url.replace('v3', 'v2.0')
|
||||
)
|
||||
self.useFixture(auth_url_fixture)
|
||||
|
||||
def _create_dummy_project(self, add_clean_up=True):
|
||||
project_name = data_utils.rand_name('TestProject')
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import os
|
||||
|
||||
import fixtures
|
||||
from tempest.lib.common.utils import data_utils
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
@ -53,16 +54,12 @@ class IdentityTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# prepare v3 env
|
||||
os.environ['OS_IDENTITY_API_VERSION'] = '3'
|
||||
auth_url = os.environ.get('OS_AUTH_URL')
|
||||
if auth_url:
|
||||
os.environ['OS_AUTH_URL'] = auth_url.replace('v2.0', 'v3')
|
||||
|
||||
super(IdentityTests, cls).setUpClass()
|
||||
# create dummy domain
|
||||
cls.domain_name = data_utils.rand_name('TestDomain')
|
||||
cls.domain_description = data_utils.rand_name('description')
|
||||
cls.openstack(
|
||||
'--os-identity-api-version 3 '
|
||||
'domain create '
|
||||
'--description %(description)s '
|
||||
'--enable '
|
||||
@ -73,6 +70,7 @@ class IdentityTests(base.TestCase):
|
||||
cls.project_name = data_utils.rand_name('TestProject')
|
||||
cls.project_description = data_utils.rand_name('description')
|
||||
cls.openstack(
|
||||
'--os-identity-api-version 3 '
|
||||
'project create '
|
||||
'--domain %(domain)s '
|
||||
'--description %(description)s '
|
||||
@ -83,11 +81,30 @@ class IdentityTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
# delete dummy project
|
||||
cls.openstack('project delete %s' % cls.project_name)
|
||||
# disable and delete dummy domain
|
||||
cls.openstack('domain set --disable %s' % cls.domain_name)
|
||||
cls.openstack('domain delete %s' % cls.domain_name)
|
||||
try:
|
||||
# delete dummy project
|
||||
cls.openstack('--os-identity-api-version 3 '
|
||||
'project delete %s' % cls.project_name)
|
||||
# disable and delete dummy domain
|
||||
cls.openstack('--os-identity-api-version 3 '
|
||||
'domain set --disable %s' % cls.domain_name)
|
||||
cls.openstack('--os-identity-api-version 3 '
|
||||
'domain delete %s' % cls.domain_name)
|
||||
finally:
|
||||
super(IdentityTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(IdentityTests, self).setUp()
|
||||
# prepare v3 env
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_IDENTITY_API_VERSION', '3')
|
||||
self.useFixture(ver_fixture)
|
||||
auth_url = os.environ.get('OS_AUTH_URL')
|
||||
if auth_url:
|
||||
auth_url_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_AUTH_URL', auth_url.replace('v2.0', 'v3')
|
||||
)
|
||||
self.useFixture(auth_url_fixture)
|
||||
|
||||
def _create_dummy_user(self, add_clean_up=True):
|
||||
username = data_utils.rand_name('TestUser')
|
||||
|
@ -11,9 +11,10 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
|
||||
|
||||
@ -25,8 +26,9 @@ class ImageTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.environ['OS_IMAGE_API_VERSION'] = '1'
|
||||
super(ImageTests, cls).setUpClass()
|
||||
json_output = json.loads(cls.openstack(
|
||||
'--os-image-api-version 1 '
|
||||
'image create -f json ' +
|
||||
cls.NAME
|
||||
))
|
||||
@ -35,10 +37,21 @@ class ImageTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.openstack(
|
||||
'image delete ' +
|
||||
cls.image_id
|
||||
try:
|
||||
cls.openstack(
|
||||
'--os-image-api-version 1 '
|
||||
'image delete ' +
|
||||
cls.image_id
|
||||
)
|
||||
finally:
|
||||
super(ImageTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(ImageTests, self).setUp()
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_IMAGE_API_VERSION', '1'
|
||||
)
|
||||
self.useFixture(ver_fixture)
|
||||
|
||||
def test_image_list(self):
|
||||
json_output = json.loads(self.openstack(
|
||||
|
@ -11,9 +11,9 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
# from glanceclient import exc as image_exceptions
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
@ -27,8 +27,9 @@ class ImageTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.environ['OS_IMAGE_API_VERSION'] = '2'
|
||||
super(ImageTests, cls).setUpClass()
|
||||
json_output = json.loads(cls.openstack(
|
||||
'--os-image-api-version 2 '
|
||||
'image create -f json ' +
|
||||
cls.NAME
|
||||
))
|
||||
@ -37,10 +38,21 @@ class ImageTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.openstack(
|
||||
'image delete ' +
|
||||
cls.image_id
|
||||
try:
|
||||
cls.openstack(
|
||||
'--os-image-api-version 2 '
|
||||
'image delete ' +
|
||||
cls.image_id
|
||||
)
|
||||
finally:
|
||||
super(ImageTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(ImageTests, self).setUp()
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_IMAGE_API_VERSION', '2'
|
||||
)
|
||||
self.useFixture(ver_fixture)
|
||||
|
||||
def test_image_list(self):
|
||||
json_output = json.loads(self.openstack(
|
||||
|
@ -18,5 +18,5 @@ class NetworkTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# super(NetworkTests, cls).setUp()
|
||||
super(NetworkTests, cls).setUpClass()
|
||||
cls.haz_network = base.is_service_enabled('network')
|
||||
|
@ -88,19 +88,22 @@ class FloatingIpTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.haz_network:
|
||||
del_output = cls.openstack(
|
||||
'subnet delete ' +
|
||||
cls.EXTERNAL_SUBNET_NAME + ' ' +
|
||||
cls.PRIVATE_SUBNET_NAME
|
||||
)
|
||||
cls.assertOutput('', del_output)
|
||||
del_output = cls.openstack(
|
||||
'network delete ' +
|
||||
cls.EXTERNAL_NETWORK_NAME + ' ' +
|
||||
cls.PRIVATE_NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', del_output)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
del_output = cls.openstack(
|
||||
'subnet delete ' +
|
||||
cls.EXTERNAL_SUBNET_NAME + ' ' +
|
||||
cls.PRIVATE_SUBNET_NAME
|
||||
)
|
||||
cls.assertOutput('', del_output)
|
||||
del_output = cls.openstack(
|
||||
'network delete ' +
|
||||
cls.EXTERNAL_NETWORK_NAME + ' ' +
|
||||
cls.PRIVATE_NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', del_output)
|
||||
finally:
|
||||
super(FloatingIpTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(FloatingIpTests, self).setUp()
|
||||
|
@ -41,17 +41,20 @@ class IPAvailabilityTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
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)
|
||||
try:
|
||||
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)
|
||||
finally:
|
||||
super(IPAvailabilityTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(IPAvailabilityTests, self).setUp()
|
||||
|
@ -361,7 +361,7 @@ class NetworkTests(common.NetworkTests):
|
||||
self.assertNotIn(name2, col_name)
|
||||
|
||||
def test_network_dhcp_agent(self):
|
||||
if self.haz_network:
|
||||
if not self.haz_network:
|
||||
self.skipTest("No Network service present")
|
||||
|
||||
name1 = uuid.uuid4().hex
|
||||
@ -408,7 +408,7 @@ class NetworkTests(common.NetworkTests):
|
||||
|
||||
def test_network_set(self):
|
||||
"""Tests create options, set, show, delete"""
|
||||
if self.haz_network:
|
||||
if not self.haz_network:
|
||||
self.skipTest("No Network service present")
|
||||
|
||||
name = uuid.uuid4().hex
|
||||
|
@ -39,13 +39,15 @@ class TestMeterRule(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
common.NetworkTests.tearDownClass()
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network meter delete ' +
|
||||
cls.METER_ID
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network meter delete ' +
|
||||
cls.METER_ID
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
common.NetworkTests.tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(TestMeterRule, self).setUp()
|
||||
|
@ -39,12 +39,15 @@ class NetworkQosPolicyTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network qos policy delete ' +
|
||||
cls.NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network qos policy delete ' +
|
||||
cls.NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(NetworkQosPolicyTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkQosPolicyTests, self).setUp()
|
||||
|
@ -51,17 +51,20 @@ class NetworkQosRuleTestsMinimumBandwidth(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
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)
|
||||
try:
|
||||
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)
|
||||
finally:
|
||||
super(NetworkQosRuleTestsMinimumBandwidth, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkQosRuleTestsMinimumBandwidth, self).setUp()
|
||||
@ -123,14 +126,18 @@ class NetworkQosRuleTestsDSCPMarking(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
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)
|
||||
try:
|
||||
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)
|
||||
finally:
|
||||
super(NetworkQosRuleTestsDSCPMarking, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkQosRuleTestsDSCPMarking, self).setUp()
|
||||
@ -198,14 +205,18 @@ class NetworkQosRuleTestsBandwidthLimit(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
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)
|
||||
try:
|
||||
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)
|
||||
finally:
|
||||
super(NetworkQosRuleTestsBandwidthLimit, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkQosRuleTestsBandwidthLimit, self).setUp()
|
||||
|
@ -47,15 +47,18 @@ class NetworkRBACTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.haz_network:
|
||||
raw_output_rbac = cls.openstack(
|
||||
'network rbac delete ' + cls.ID
|
||||
)
|
||||
raw_output_network = cls.openstack(
|
||||
'network delete ' + cls.OBJECT_ID
|
||||
)
|
||||
cls.assertOutput('', raw_output_rbac)
|
||||
cls.assertOutput('', raw_output_network)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
raw_output_rbac = cls.openstack(
|
||||
'network rbac delete ' + cls.ID
|
||||
)
|
||||
raw_output_network = cls.openstack(
|
||||
'network delete ' + cls.OBJECT_ID
|
||||
)
|
||||
cls.assertOutput('', raw_output_rbac)
|
||||
cls.assertOutput('', raw_output_network)
|
||||
finally:
|
||||
super(NetworkRBACTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkRBACTests, self).setUp()
|
||||
|
@ -55,11 +55,14 @@ class NetworkSegmentTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network delete ' + cls.NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network delete ' + cls.NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(NetworkSegmentTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkSegmentTests, self).setUp()
|
||||
|
@ -33,11 +33,14 @@ class PortTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network delete ' + cls.NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network delete ' + cls.NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(PortTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(PortTests, self).setUp()
|
||||
|
@ -38,20 +38,23 @@ class SecurityGroupTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
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)
|
||||
try:
|
||||
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)
|
||||
finally:
|
||||
super(SecurityGroupTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(SecurityGroupTests, self).setUp()
|
||||
|
@ -51,18 +51,20 @@ class SecurityGroupRuleTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
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)
|
||||
try:
|
||||
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)
|
||||
finally:
|
||||
super(SecurityGroupRuleTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(SecurityGroupRuleTests, self).setUp()
|
||||
|
@ -36,12 +36,15 @@ class SubnetTests(common.NetworkTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network delete ' +
|
||||
cls.NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
if cls.haz_network:
|
||||
raw_output = cls.openstack(
|
||||
'network delete ' +
|
||||
cls.NETWORK_NAME
|
||||
)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(SubnetTests, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
super(SubnetTests, self).setUp()
|
||||
|
@ -21,14 +21,18 @@ class ContainerTests(base.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(ContainerTests, cls).setUpClass()
|
||||
opts = cls.get_opts(['container'])
|
||||
raw_output = cls.openstack('container create ' + cls.NAME + opts)
|
||||
cls.assertOutput(cls.NAME + '\n', raw_output)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
raw_output = cls.openstack('container delete ' + cls.NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
raw_output = cls.openstack('container delete ' + cls.NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(ContainerTests, cls).tearDownClass()
|
||||
|
||||
def test_container_list(self):
|
||||
opts = self.get_opts(['Name'])
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import fixtures
|
||||
|
||||
from openstackclient.tests.functional.volume import base
|
||||
|
||||
@ -18,6 +18,9 @@ from openstackclient.tests.functional.volume import base
|
||||
class BaseVolumeTests(base.BaseVolumeTests):
|
||||
"""Base class for Volume functional tests. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '1'
|
||||
def setUp(self):
|
||||
super(BaseVolumeTests, self).setUp()
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_VOLUME_API_VERSION', '1'
|
||||
)
|
||||
self.useFixture(ver_fixture)
|
||||
|
@ -35,9 +35,12 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
raw_output = cls.openstack('volume delete --force ' + cls.VOLLY)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
raw_output = cls.openstack('volume delete --force ' + cls.VOLLY)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(VolumeSnapshotTests, cls).tearDownClass()
|
||||
|
||||
def test_volume_snapshot__delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
|
@ -37,12 +37,15 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
raw_output_transfer = cls.openstack(
|
||||
'volume transfer request delete ' + cls.NAME)
|
||||
raw_output_volume = cls.openstack(
|
||||
'volume delete ' + cls.VOLUME_NAME)
|
||||
cls.assertOutput('', raw_output_transfer)
|
||||
cls.assertOutput('', raw_output_volume)
|
||||
try:
|
||||
raw_output_transfer = cls.openstack(
|
||||
'volume transfer request delete ' + cls.NAME)
|
||||
raw_output_volume = cls.openstack(
|
||||
'volume delete ' + cls.VOLUME_NAME)
|
||||
cls.assertOutput('', raw_output_transfer)
|
||||
cls.assertOutput('', raw_output_volume)
|
||||
finally:
|
||||
super(TransferRequestTests, cls).tearDownClass()
|
||||
|
||||
def test_volume_transfer_request_accept(self):
|
||||
volume_name = uuid.uuid4().hex
|
||||
|
@ -31,8 +31,11 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
raw_output = cls.openstack('volume type delete ' + cls.NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
raw_output = cls.openstack('volume type delete ' + cls.NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(VolumeTypeTests, cls).tearDownClass()
|
||||
|
||||
def test_volume_type_list(self):
|
||||
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import fixtures
|
||||
|
||||
from openstackclient.tests.functional.volume import base
|
||||
|
||||
@ -18,6 +18,9 @@ from openstackclient.tests.functional.volume import base
|
||||
class BaseVolumeTests(base.BaseVolumeTests):
|
||||
"""Base class for Volume functional tests. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '2'
|
||||
def setUp(self):
|
||||
super(BaseVolumeTests, self).setUp()
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_VOLUME_API_VERSION', '2'
|
||||
)
|
||||
self.useFixture(ver_fixture)
|
||||
|
@ -35,10 +35,13 @@ class VolumeSnapshotTests(common.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
raw_output = cls.openstack(
|
||||
'volume delete --force ' + cls.VOLLY)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
cls.wait_for_status('volume', cls.VOLLY, 'available')
|
||||
raw_output = cls.openstack(
|
||||
'volume delete --force ' + cls.VOLLY)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(VolumeSnapshotTests, cls).tearDownClass()
|
||||
|
||||
def test_volume_snapshot__delete(self):
|
||||
"""Test create, delete multiple"""
|
||||
|
@ -38,12 +38,15 @@ class TransferRequestTests(common.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
raw_output_transfer = cls.openstack(
|
||||
'volume transfer request delete ' + cls.NAME)
|
||||
raw_output_volume = cls.openstack(
|
||||
'volume delete ' + cls.VOLUME_NAME)
|
||||
cls.assertOutput('', raw_output_transfer)
|
||||
cls.assertOutput('', raw_output_volume)
|
||||
try:
|
||||
raw_output_transfer = cls.openstack(
|
||||
'volume transfer request delete ' + cls.NAME)
|
||||
raw_output_volume = cls.openstack(
|
||||
'volume delete ' + cls.VOLUME_NAME)
|
||||
cls.assertOutput('', raw_output_transfer)
|
||||
cls.assertOutput('', raw_output_volume)
|
||||
finally:
|
||||
super(TransferRequestTests, cls).tearDownClass()
|
||||
|
||||
def test_volume_transfer_request_accept(self):
|
||||
volume_name = uuid.uuid4().hex
|
||||
|
@ -31,8 +31,11 @@ class VolumeTypeTests(common.BaseVolumeTests):
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
raw_output = cls.openstack('volume type delete ' + cls.NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
try:
|
||||
raw_output = cls.openstack('volume type delete ' + cls.NAME)
|
||||
cls.assertOutput('', raw_output)
|
||||
finally:
|
||||
super(VolumeTypeTests, cls).tearDownClass()
|
||||
|
||||
def test_volume_type_list(self):
|
||||
cmd_output = json.loads(self.openstack('volume type list -f json'))
|
||||
|
@ -10,7 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
import fixtures
|
||||
|
||||
from openstackclient.tests.functional.volume import base
|
||||
|
||||
@ -18,6 +18,9 @@ from openstackclient.tests.functional.volume import base
|
||||
class BaseVolumeTests(base.BaseVolumeTests):
|
||||
"""Base class for Volume functional tests. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '3'
|
||||
def setUp(self):
|
||||
super(BaseVolumeTests, self).setUp()
|
||||
ver_fixture = fixtures.EnvironmentVariable(
|
||||
'OS_VOLUME_API_VERSION', '3'
|
||||
)
|
||||
self.useFixture(ver_fixture)
|
||||
|
@ -10,15 +10,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import test_qos as v2
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
|
||||
|
||||
class QosTests(v2.QosTests):
|
||||
class QosTests(common.BaseVolumeTests, v2.QosTests):
|
||||
"""Functional tests for volume qos. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(QosTests, cls).setUpClass()
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '3'
|
||||
|
@ -11,13 +11,8 @@
|
||||
# under the License.
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import test_snapshot as v2
|
||||
import os
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
|
||||
|
||||
class VolumeSnapshotTests(v2.VolumeSnapshotTests):
|
||||
class VolumeSnapshotTests(common.BaseVolumeTests, v2.VolumeSnapshotTests):
|
||||
"""Functional tests for volume snapshot. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(VolumeSnapshotTests, cls).setUpClass()
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '3'
|
||||
|
@ -12,13 +12,8 @@
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import test_transfer_request \
|
||||
as v2
|
||||
import os
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
|
||||
|
||||
class TransferRequestTests(v2.TransferRequestTests):
|
||||
class TransferRequestTests(common.BaseVolumeTests, v2.TransferRequestTests):
|
||||
"""Functional tests for transfer request. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TransferRequestTests, cls).setUpClass()
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '3'
|
||||
|
@ -11,13 +11,8 @@
|
||||
# under the License.
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import test_volume as v2
|
||||
import os
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
|
||||
|
||||
class VolumeTests(v2.VolumeTests):
|
||||
class VolumeTests(common.BaseVolumeTests, v2.VolumeTests):
|
||||
"""Functional tests for volume. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(VolumeTests, cls).setUpClass()
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '3'
|
||||
|
@ -11,13 +11,8 @@
|
||||
# under the License.
|
||||
|
||||
from openstackclient.tests.functional.volume.v2 import test_volume_type as v2
|
||||
import os
|
||||
from openstackclient.tests.functional.volume.v3 import common
|
||||
|
||||
|
||||
class VolumeTypeTests(v2.VolumeTypeTests):
|
||||
class VolumeTypeTests(common.BaseVolumeTests, v2.VolumeTypeTests):
|
||||
"""Functional tests for volume type. """
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(VolumeTypeTests, cls).setUpClass()
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '3'
|
||||
|
Loading…
x
Reference in New Issue
Block a user