Merge "Added test to check list/show extensions-neutron"
diff --git a/HACKING.rst b/HACKING.rst
index 2fa949d..9878b67 100644
--- a/HACKING.rst
+++ b/HACKING.rst
@@ -123,8 +123,8 @@
earlier a problem is detected the easier it is to debug, especially
where there is complicated setup required.
-Parallel Test Exectution
-------------------------
+Parallel Test Execution
+-----------------------
Tempest by default runs its tests in parallel this creates the possibility for
interesting interactions between tests which can cause unexpected failures.
Tenant isolation provides protection from most of the potential race conditions
@@ -133,7 +133,7 @@
- Resources outside of a tenant scope still have the potential to conflict. This
is a larger concern for the admin tests since most resources and actions that
- require admin privleges are outside of tenants.
+ require admin privileges are outside of tenants.
- Races between methods in the same class are not a problem because
parallelization in tempest is at the test class level, but if there is a json
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index a5dceca..40b005d 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -15,25 +15,13 @@
# License for the specific language governing permissions and limitations
# under the License.
-import fixtures
-
from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
-from tempest.openstack.common import lockutils
from tempest.test import attr
-class LockFixture(fixtures.Fixture):
- def __init__(self, name):
- self.mgr = lockutils.lock(name, 'tempest-', True)
-
- def setUp(self):
- super(LockFixture, self).setUp()
- self.addCleanup(self.mgr.__exit__, None, None, None)
- self.mgr.__enter__()
-
-
class AggregatesAdminTestJSON(base.BaseComputeAdminTest):
"""
@@ -160,7 +148,7 @@
@attr(type='gate')
def test_aggregate_add_remove_host(self):
# Add an host to the given aggregate and remove.
- self.useFixture(LockFixture('availability_zone'))
+ self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = rand_name(self.aggregate_name_prefix)
resp, aggregate = self.client.create_aggregate(aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
@@ -182,7 +170,7 @@
@attr(type='gate')
def test_aggregate_add_host_list(self):
# Add an host to the given aggregate and list.
- self.useFixture(LockFixture('availability_zone'))
+ self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = rand_name(self.aggregate_name_prefix)
resp, aggregate = self.client.create_aggregate(aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
@@ -200,7 +188,7 @@
@attr(type='gate')
def test_aggregate_add_host_get_details(self):
# Add an host to the given aggregate and get details.
- self.useFixture(LockFixture('availability_zone'))
+ self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = rand_name(self.aggregate_name_prefix)
resp, aggregate = self.client.create_aggregate(aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
@@ -215,7 +203,7 @@
@attr(type='gate')
def test_aggregate_add_host_create_server_with_az(self):
# Add an host to the given aggregate and create a server.
- self.useFixture(LockFixture('availability_zone'))
+ self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = rand_name(self.aggregate_name_prefix)
az_name = rand_name(self.az_name_prefix)
resp, aggregate = self.client.create_aggregate(aggregate_name, az_name)
@@ -262,7 +250,7 @@
@attr(type=['negative', 'gate'])
def test_aggregate_remove_host_as_user(self):
# Regular user is not allowed to remove a host from an aggregate.
- self.useFixture(LockFixture('availability_zone'))
+ self.useFixture(fixtures.LockFixture('availability_zone'))
aggregate_name = rand_name(self.aggregate_name_prefix)
resp, aggregate = self.client.create_aggregate(aggregate_name)
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
diff --git a/tempest/api/compute/admin/test_hosts.py b/tempest/api/compute/admin/test_hosts.py
index 19d7973..bf09428 100644
--- a/tempest/api/compute/admin/test_hosts.py
+++ b/tempest/api/compute/admin/test_hosts.py
@@ -15,6 +15,7 @@
# under the License.
from tempest.api.compute import base
+from tempest.common import tempest_fixtures as fixtures
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
from tempest.test import attr
@@ -42,6 +43,7 @@
@attr(type='gate')
def test_list_hosts_with_zone(self):
+ self.useFixture(fixtures.LockFixture('availability_zone'))
resp, hosts = self.client.list_hosts()
host = hosts[0]
zone_name = host['zone']
diff --git a/tempest/api/volume/test_volumes_negative.py b/tempest/api/volume/test_volumes_negative.py
index 7eeb1ee..a48cea2 100644
--- a/tempest/api/volume/test_volumes_negative.py
+++ b/tempest/api/volume/test_volumes_negative.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import uuid
+
from tempest.api.volume import base
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
@@ -29,37 +31,24 @@
super(VolumesNegativeTest, cls).setUpClass()
cls.client = cls.volumes_client
+ # Create a test shared instance and volume for attach/detach tests
+ vol_name = rand_name('Volume-')
+
+ cls.volume = cls.create_volume(size=1, display_name=vol_name)
+ cls.client.wait_for_volume_status(cls.volume['id'], 'available')
+ cls.mountpoint = "/dev/vdc"
+
@attr(type='gate')
def test_volume_get_nonexistant_volume_id(self):
- # Should not be able to get a non-existent volume
- # Creating a non-existent volume id
- volume_id_list = []
- resp, volumes = self.client.list_volumes()
- for i in range(len(volumes)):
- volume_id_list.append(volumes[i]['id'])
- while True:
- non_exist_id = rand_name('999')
- if non_exist_id not in volume_id_list:
- break
- # Trying to Get a non-existent volume
+ # Should not be able to get a non-existant volume
self.assertRaises(exceptions.NotFound, self.client.get_volume,
- non_exist_id)
+ str(uuid.uuid4()))
@attr(type='gate')
def test_volume_delete_nonexistant_volume_id(self):
- # Should not be able to delete a non-existent Volume
- # Creating non-existent volume id
- volume_id_list = []
- resp, volumes = self.client.list_volumes()
- for i in range(len(volumes)):
- volume_id_list.append(volumes[i]['id'])
- while True:
- non_exist_id = '12345678-abcd-4321-abcd-123456789098'
- if non_exist_id not in volume_id_list:
- break
- # Try to delete a non-existent volume
+ # Should not be able to delete a non-existant Volume
self.assertRaises(exceptions.NotFound, self.client.delete_volume,
- non_exist_id)
+ str(uuid.uuid4()))
@attr(type='gate')
def test_create_volume_with_invalid_size(self):
@@ -109,6 +98,26 @@
# Should not be able to delete volume when empty ID is passed
self.assertRaises(exceptions.NotFound, self.client.delete_volume, '')
+ @attr(type=['negative', 'gate'])
+ def test_attach_volumes_with_nonexistent_volume_id(self):
+ srv_name = rand_name('Instance-')
+ resp, server = self.servers_client.create_server(srv_name,
+ self.image_ref,
+ self.flavor_ref)
+ self.addCleanup(self.servers_client.delete_server, server['id'])
+ self.servers_client.wait_for_server_status(server['id'], 'ACTIVE')
+ self.assertRaises(exceptions.NotFound,
+ self.client.attach_volume,
+ str(uuid.uuid4()),
+ server['id'],
+ self.mountpoint)
+
+ @attr(type=['negative', 'gate'])
+ def test_detach_volumes_with_invalid_volume_id(self):
+ self.assertRaises(exceptions.NotFound,
+ self.client.detach_volume,
+ 'xxx')
+
class VolumesNegativeTestXML(VolumesNegativeTest):
_interface = 'xml'
diff --git a/tempest/common/tempest_fixtures.py b/tempest/common/tempest_fixtures.py
new file mode 100644
index 0000000..081b271
--- /dev/null
+++ b/tempest/common/tempest_fixtures.py
@@ -0,0 +1,30 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2013 IBM Corp.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import fixtures
+
+from tempest.openstack.common import lockutils
+
+
+class LockFixture(fixtures.Fixture):
+ def __init__(self, name):
+ self.mgr = lockutils.lock(name, 'tempest-', True)
+
+ def setUp(self):
+ super(LockFixture, self).setUp()
+ self.addCleanup(self.mgr.__exit__, None, None, None)
+ self.mgr.__enter__()
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index f71ea46..44788f2 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -374,8 +374,10 @@
**ruleset)
self.set_resource(sg_rule.id, sg_rule)
- def create_server(self, client, name=None, image=None, flavor=None,
+ def create_server(self, client=None, name=None, image=None, flavor=None,
create_kwargs={}):
+ if client is None:
+ client = self.compute_client
if name is None:
name = rand_name('scenario-server-')
if image is None:
@@ -481,7 +483,9 @@
cls.config.identity.password,
cls.config.identity.tenant_name).tenant_id
- def _create_security_group(self, client, namestart='secgroup-smoke-'):
+ def _create_security_group(self, client=None, namestart='secgroup-smoke-'):
+ if client is None:
+ client = self.compute_client
# Create security group
sg_name = rand_name(namestart)
sg_desc = sg_name + " description"
diff --git a/tempest/scenario/test_minimum_basic.py b/tempest/scenario/test_minimum_basic.py
index ce4d1bd..752ff6f 100644
--- a/tempest/scenario/test_minimum_basic.py
+++ b/tempest/scenario/test_minimum_basic.py
@@ -87,8 +87,7 @@
def nova_boot(self):
create_kwargs = {'key_name': self.keypair.name}
- self.server = self.create_server(self.compute_client,
- image=self.image,
+ self.server = self.create_server(image=self.image,
create_kwargs=create_kwargs)
def nova_list(self):
diff --git a/tempest/scenario/test_network_basic_ops.py b/tempest/scenario/test_network_basic_ops.py
index 2aa5de3..7f7ba91 100644
--- a/tempest/scenario/test_network_basic_ops.py
+++ b/tempest/scenario/test_network_basic_ops.py
@@ -168,8 +168,7 @@
name=rand_name('keypair-smoke-'))
def _create_security_groups(self):
- self.security_groups[self.tenant_id] = self._create_security_group(
- self.compute_client)
+ self.security_groups[self.tenant_id] = self._create_security_group()
def _create_networks(self):
network = self._create_network(self.tenant_id)
@@ -214,8 +213,7 @@
'key_name': keypair_name,
'security_groups': security_groups,
}
- server = self.create_server(self.compute_client, name=name,
- create_kwargs=create_kwargs)
+ server = self.create_server(name=name, create_kwargs=create_kwargs)
return server
def _create_servers(self):
diff --git a/tempest/scenario/test_server_advanced_ops.py b/tempest/scenario/test_server_advanced_ops.py
index 26bc95e..853b1ba 100644
--- a/tempest/scenario/test_server_advanced_ops.py
+++ b/tempest/scenario/test_server_advanced_ops.py
@@ -48,7 +48,7 @@
@services('compute')
def test_resize_server_confirm(self):
# We create an instance for use in this test
- instance = self.create_server(self.compute_client)
+ instance = self.create_server()
instance_id = instance.id
resize_flavor = self.config.compute.flavor_ref_alt
LOG.debug("Resizing instance %s from flavor %s to flavor %s",
@@ -66,7 +66,7 @@
@services('compute')
def test_server_sequence_suspend_resume(self):
# We create an instance for use in this test
- instance = self.create_server(self.compute_client)
+ instance = self.create_server()
instance_id = instance.id
LOG.debug("Suspending instance %s. Current status: %s",
instance_id, instance.status)
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index 03e6e41..c32d49d 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -56,8 +56,7 @@
create_kwargs = {
'key_name': self.keypair.id
}
- instance = self.create_server(self.compute_client,
- create_kwargs=create_kwargs)
+ instance = self.create_server(create_kwargs=create_kwargs)
self.set_resource('instance', instance)
def pause_server(self):
diff --git a/tempest/scenario/test_snapshot_pattern.py b/tempest/scenario/test_snapshot_pattern.py
index 8c2cc76..ba347e0 100644
--- a/tempest/scenario/test_snapshot_pattern.py
+++ b/tempest/scenario/test_snapshot_pattern.py
@@ -34,8 +34,7 @@
create_kwargs = {
'key_name': self.keypair.name
}
- return self.create_server(self.compute_client, image=image_id,
- create_kwargs=create_kwargs)
+ return self.create_server(image=image_id, create_kwargs=create_kwargs)
def _add_keypair(self):
self.keypair = self.create_keypair()
diff --git a/tempest/scenario/test_stamp_pattern.py b/tempest/scenario/test_stamp_pattern.py
index ab464e3..4f49d65 100644
--- a/tempest/scenario/test_stamp_pattern.py
+++ b/tempest/scenario/test_stamp_pattern.py
@@ -58,8 +58,7 @@
create_kwargs = {
'key_name': self.keypair.name
}
- return self.create_server(self.compute_client, image=image_id,
- create_kwargs=create_kwargs)
+ return self.create_server(image=image_id, create_kwargs=create_kwargs)
def _add_keypair(self):
self.keypair = self.create_keypair()
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 3572166..d12cd56 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -49,8 +49,7 @@
'block_device_mapping': bd_map,
'key_name': keypair.name
}
- return self.create_server(self.compute_client,
- create_kwargs=create_kwargs)
+ return self.create_server(create_kwargs=create_kwargs)
def _create_snapshot_from_volume(self, vol_id):
volume_snapshots = self.volume_client.volume_snapshots
diff --git a/tempest/stress/README.rst b/tempest/stress/README.rst
index 7c180f6..ae86f6e 100644
--- a/tempest/stress/README.rst
+++ b/tempest/stress/README.rst
@@ -31,7 +31,7 @@
To test installation, do the following (from the tempest/stress directory):
- ./run_stress.py etc/server-create-destroy-test.json -d 30
+ ./run_stress.py -t etc/server-create-destroy-test.json -d 30
This sample test tries to create a few VMs and kill a few VMs.
diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py
index 0999e2c..92d66ae 100644
--- a/tools/install_venv_common.py
+++ b/tools/install_venv_common.py
@@ -119,8 +119,7 @@
self.pip_install('setuptools')
self.pip_install('pbr')
- self.pip_install('-r', self.requirements)
- self.pip_install('-r', self.test_requirements)
+ self.pip_install('-r', self.requirements, '-r', self.test_requirements)
def post_process(self):
self.get_distro().post_process()