Merge "remove code duplication in tempest/config.py"
diff --git a/tempest/api/compute/admin/test_flavors_access.py b/tempest/api/compute/admin/test_flavors_access.py
index 107b23d..8213839 100644
--- a/tempest/api/compute/admin/test_flavors_access.py
+++ b/tempest/api/compute/admin/test_flavors_access.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
from tempest.api import compute
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_int_id
@@ -123,6 +125,48 @@
new_flavor['id'],
self.tenant_id)
+ @attr(type=['negative', 'gate'])
+ def test_add_flavor_access_duplicate(self):
+ # Create a new flavor.
+ flavor_name = rand_name(self.flavor_name_prefix)
+ new_flavor_id = rand_int_id(start=1000)
+ resp, new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
+ self.addCleanup(self.client.delete_flavor, new_flavor['id'])
+
+ # Add flavor access to a tenant.
+ self.client.add_flavor_access(new_flavor['id'], self.tenant_id)
+ self.addCleanup(self.client.remove_flavor_access,
+ new_flavor['id'], self.tenant_id)
+
+ # An exception should be raised when adding flavor access to the same
+ # tenant
+ self.assertRaises(exceptions.Duplicate,
+ self.client.add_flavor_access,
+ new_flavor['id'],
+ self.tenant_id)
+
+ @attr(type=['negative', 'gate'])
+ def test_remove_flavor_access_not_found(self):
+ # Create a new flavor.
+ flavor_name = rand_name(self.flavor_name_prefix)
+ new_flavor_id = rand_int_id(start=1000)
+ resp, new_flavor = self.client.create_flavor(flavor_name,
+ self.ram, self.vcpus,
+ self.disk,
+ new_flavor_id,
+ is_public='False')
+ self.addCleanup(self.client.delete_flavor, new_flavor['id'])
+
+ # An exception should be raised when flavor access is not found
+ self.assertRaises(exceptions.NotFound,
+ self.client.remove_flavor_access,
+ new_flavor['id'],
+ str(uuid.uuid4()))
+
class FlavorsAdminTestXML(FlavorsAccessTestJSON):
_interface = 'xml'
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index c469827..8e95671 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -57,32 +57,26 @@
raise RuntimeError("Image %s (image_ref_alt) was not found!" %
cls.image_ref_alt)
- cls.s1_name = rand_name('server')
- resp, cls.s1 = cls.client.create_server(cls.s1_name, cls.image_ref,
- cls.flavor_ref)
- cls.s2_name = rand_name('server')
- resp, cls.s2 = cls.client.create_server(cls.s2_name, cls.image_ref_alt,
- cls.flavor_ref)
- cls.s3_name = rand_name('server')
- resp, cls.s3 = cls.client.create_server(cls.s3_name, cls.image_ref,
- cls.flavor_ref_alt)
+ cls.s1_name = rand_name(cls.__name__ + '-instance')
+ resp, cls.s1 = cls.create_server(name=cls.s1_name,
+ image_id=cls.image_ref,
+ flavor=cls.flavor_ref,
+ wait_until='ACTIVE')
- cls.client.wait_for_server_status(cls.s1['id'], 'ACTIVE')
- resp, cls.s1 = cls.client.get_server(cls.s1['id'])
- cls.client.wait_for_server_status(cls.s2['id'], 'ACTIVE')
- resp, cls.s2 = cls.client.get_server(cls.s2['id'])
- cls.client.wait_for_server_status(cls.s3['id'], 'ACTIVE')
- resp, cls.s3 = cls.client.get_server(cls.s3['id'])
+ cls.s2_name = rand_name(cls.__name__ + '-instance')
+ resp, cls.s2 = cls.create_server(name=cls.s2_name,
+ image_id=cls.image_ref_alt,
+ flavor=cls.flavor_ref,
+ wait_until='ACTIVE')
+
+ cls.s3_name = rand_name(cls.__name__ + '-instance')
+ resp, cls.s3 = cls.create_server(name=cls.s3_name,
+ image_id=cls.image_ref,
+ flavor=cls.flavor_ref_alt,
+ wait_until='ACTIVE')
cls.fixed_network_name = cls.config.compute.fixed_network_name
- @classmethod
- def tearDownClass(cls):
- cls.client.delete_server(cls.s1['id'])
- cls.client.delete_server(cls.s2['id'])
- cls.client.delete_server(cls.s3['id'])
- super(ListServerFiltersTestJSON, cls).tearDownClass()
-
@utils.skip_unless_attr('multiple_images', 'Only one image found')
@attr(type='gate')
def test_list_servers_filter_by_image(self):
@@ -184,8 +178,8 @@
@attr(type='gate')
def test_list_servers_filtered_by_name_wildcard(self):
- # List all servers that contains 'server' in name
- params = {'name': 'server'}
+ # List all servers that contains '-instance' in name
+ params = {'name': '-instance'}
resp, body = self.client.list_servers(params)
servers = body['servers']
@@ -209,6 +203,7 @@
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
# Here should be listed 1 server
+ resp, self.s1 = self.client.get_server(self.s1['id'])
ip = self.s1['addresses'][self.fixed_network_name][0]['addr']
params = {'ip': ip}
resp, body = self.client.list_servers(params)
@@ -225,6 +220,7 @@
# Filter servers by regex ip
# List all servers filtered by part of ip address.
# Here should be listed all servers
+ resp, self.s1 = self.client.get_server(self.s1['id'])
ip = self.s1['addresses'][self.fixed_network_name][0]['addr'][0:-3]
params = {'ip': ip}
resp, body = self.client.list_servers(params)
diff --git a/tempest/api/volume/test_volumes_actions.py b/tempest/api/volume/test_volumes_actions.py
index 19e3fc6..09131e2 100644
--- a/tempest/api/volume/test_volumes_actions.py
+++ b/tempest/api/volume/test_volumes_actions.py
@@ -32,8 +32,8 @@
cls.image_client = cls.os.image_client
# Create a test shared instance and volume for attach/detach tests
- srv_name = rand_name('Instance-')
- vol_name = rand_name('Volume-')
+ srv_name = rand_name(cls.__name__ + '-Instance-')
+ vol_name = rand_name(cls.__name__ + '-Volume-')
resp, cls.server = cls.servers_client.create_server(srv_name,
cls.image_ref,
cls.flavor_ref)
diff --git a/tempest/stress/driver.py b/tempest/stress/driver.py
index 55404ce..b5cab68 100644
--- a/tempest/stress/driver.py
+++ b/tempest/stress/driver.py
@@ -196,7 +196,7 @@
if not logfiles:
continue
- if _has_error_in_logs(logfiles, computes):
+ if _has_error_in_logs(logfiles, computes, stop_on_error):
had_errors = True
break
diff --git a/tempest/stress/run_stress.py b/tempest/stress/run_stress.py
index 886d94b..e5cc281 100755
--- a/tempest/stress/run_stress.py
+++ b/tempest/stress/run_stress.py
@@ -23,14 +23,20 @@
from testtools.testsuite import iterate_tests
from unittest import loader
+from tempest.openstack.common import log as logging
+
+LOG = logging.getLogger(__name__)
+
def discover_stress_tests(path="./", filter_attr=None, call_inherited=False):
"""Discovers all tempest tests and create action out of them
"""
+ LOG.info("Start test discovery")
tests = []
testloader = loader.TestLoader()
list = testloader.discover(path)
for func in (iterate_tests(list)):
+ attrs = []
try:
method_name = getattr(func, '_testMethodName')
full_name = "%s.%s.%s" % (func.__module__,
@@ -106,4 +112,8 @@
help="Name of the file with test description")
if __name__ == "__main__":
- sys.exit(main(parser.parse_args()))
+ try:
+ sys.exit(main(parser.parse_args()))
+ except Exception:
+ LOG.exception("Failure in the stress test framework")
+ sys.exit(1)