Add locking to test_aggregates
There is a race condition when running testr in parallel between
the XML and JSON versions of:
test_aggregate_add_host_create_server_with_az
because a host can only be in one availability zone at a time. This
commit adds file locking to that test using oslo lockutils so that
the XML and JSON tests will never run at the same time.
part of blueprint speed-up-tempest
Change-Id: I1ce76ccd9c57d8f44f19958498c632910112528b
diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample
index 356bb42..825965f 100644
--- a/etc/tempest.conf.sample
+++ b/etc/tempest.conf.sample
@@ -1,5 +1,6 @@
[DEFAULT]
# log_config = /opt/stack/tempest/etc/logging.conf.sample
+lock_path=/tmp
[identity]
# This section contains configuration options that a variety of Tempest
diff --git a/tempest/api/compute/admin/test_aggregates.py b/tempest/api/compute/admin/test_aggregates.py
index b66bd7e..107d635 100644
--- a/tempest/api/compute/admin/test_aggregates.py
+++ b/tempest/api/compute/admin/test_aggregates.py
@@ -18,6 +18,7 @@
from tempest.api.compute import base
from tempest.common.utils.data_utils import rand_name
from tempest import exceptions
+from tempest.openstack.common import lockutils
from tempest.test import attr
@@ -197,6 +198,7 @@
self.assertIn(self.host, body['hosts'])
@attr(type='gate')
+ @lockutils.synchronized('availability_zone', 'tempest-', True)
def test_aggregate_add_host_create_server_with_az(self):
# Add an host to the given aggregate and create a server.
aggregate_name = rand_name(self.aggregate_name_prefix)
@@ -205,7 +207,6 @@
self.addCleanup(self.client.delete_aggregate, aggregate['id'])
self.client.add_host(aggregate['id'], self.host)
self.addCleanup(self.client.remove_host, aggregate['id'], self.host)
-
server_name = rand_name('test_server_')
servers_client = self.servers_client
admin_servers_client = self.os_adm.servers_client