[Tempest] Create heavy scenario resources in parallel
Manila Tempest scenario tests create all resources one by one and they
are very slow because of it.
Therefore, make all resource 'waiters' run after all resource creation
requests are sent.
Change-Id: I435a5d04bce340b0a2c0a2d30fa5a99e50b311e1
Closes-Bug: #1493405
diff --git a/manila_tempest_tests/tests/scenario/manager_share.py b/manila_tempest_tests/tests/scenario/manager_share.py
index f2604e7..972654b 100644
--- a/manila_tempest_tests/tests/scenario/manager_share.py
+++ b/manila_tempest_tests/tests/scenario/manager_share.py
@@ -107,6 +107,7 @@
search_opts={"share_network": sn_id})
for server in servers:
client.delete_share_server(server['id'])
+ for server in servers:
client.wait_for_resource_deletion(server_id=server['id'])
def _create_share_network(self, client=None, **kwargs):
diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
index a3e0e1f..dbe5599 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -14,6 +14,7 @@
# under the License.
from oslo_log import log as logging
+from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
@@ -65,14 +66,17 @@
'user: {ssh_user}'.format(
image=self.image_ref, flavor=self.flavor_ref,
ssh_user=self.ssh_user))
+ self.security_group = self._create_security_group()
+ if CONF.share.multitenancy_enabled:
+ self.create_share_network()
- def boot_instance(self):
+ def boot_instance(self, wait_until="ACTIVE"):
self.keypair = self.create_keypair()
security_groups = [{'name': self.security_group['name']}]
create_kwargs = {
'key_name': self.keypair['name'],
'security_groups': security_groups,
- 'wait_until': 'ACTIVE',
+ 'wait_until': wait_until,
}
if CONF.share.multitenancy_enabled:
create_kwargs['networks'] = [{'uuid': self.net['id']}, ]
@@ -152,7 +156,6 @@
'share_type_id': self._get_share_type()['id'],
}
if CONF.share.multitenancy_enabled:
- self.create_share_network()
kwargs.update({'share_network_id': self.share_net['id']})
self.share = self._create_share(**kwargs)
@@ -163,6 +166,7 @@
first_address = net_addresses.values()[0][0]
ip = first_address['addr']
except Exception:
+ LOG.debug("Instance: %s" % instance)
# In case on an error ip will be still none
LOG.exception("Instance does not have a valid IP address."
"Falling back to default")
@@ -171,12 +175,17 @@
self._allow_access(share_id, access_type='ip', access_to=ip,
cleanup=cleanup)
+ def wait_for_active_instance(self, instance_id):
+ waiters.wait_for_server_status(
+ self.manager.servers_client, instance_id, "ACTIVE")
+ return self.manager.servers_client.show_server(instance_id)["server"]
+
@test.services('compute', 'network')
@test.attr(type=[base.TAG_POSITIVE, base.TAG_BACKEND])
def test_mount_share_one_vm(self):
- self.security_group = self._create_security_group()
+ instance = self.boot_instance(wait_until="BUILD")
self.create_share()
- instance = self.boot_instance()
+ instance = self.wait_for_active_instance(instance["id"])
self.allow_access_ip(self.share['id'], instance=instance,
cleanup=False)
ssh_client = self.init_ssh(instance)
@@ -198,11 +207,15 @@
def test_read_write_two_vms(self):
"""Boots two vms and writes/reads data on it."""
test_data = "Some test data to write"
- self.security_group = self._create_security_group()
- self.create_share()
- # boot first VM and write data
- instance1 = self.boot_instance()
+ # Boot two VMs and create share
+ instance1 = self.boot_instance(wait_until="BUILD")
+ instance2 = self.boot_instance(wait_until="BUILD")
+ self.create_share()
+ instance1 = self.wait_for_active_instance(instance1["id"])
+ instance2 = self.wait_for_active_instance(instance2["id"])
+
+ # Write data to first VM
self.allow_access_ip(self.share['id'], instance=instance1,
cleanup=False)
ssh_client_inst1 = self.init_ssh(instance1)
@@ -219,9 +232,9 @@
ssh_client_inst1)
self.write_data(test_data, ssh_client_inst1)
- # boot second VM and read
- instance2 = self.boot_instance()
- self.allow_access_ip(self.share['id'], instance=instance2)
+ # Read from second VM
+ self.allow_access_ip(
+ self.share['id'], instance=instance2, cleanup=False)
ssh_client_inst2 = self.init_ssh(instance2)
self.mount_share(locations[0], ssh_client_inst2)
self.addCleanup(self.umount_share,
@@ -247,8 +260,9 @@
"are needed to run migration tests. "
"Skipping.")
- self.security_group = self._create_security_group()
+ instance = self.boot_instance(wait_until="BUILD")
self.create_share()
+ instance = self.wait_for_active_instance(instance["id"])
share = self.shares_client.get_share(self.share['id'])
dest_pool = next((x for x in pools if x['name'] != share['host']),
@@ -259,10 +273,9 @@
dest_pool = dest_pool['name']
- instance1 = self.boot_instance()
- self.allow_access_ip(self.share['id'], instance=instance1,
+ self.allow_access_ip(self.share['id'], instance=instance,
cleanup=False)
- ssh_client = self.init_ssh(instance1)
+ ssh_client = self.init_ssh(instance)
if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
locations = self.share['export_locations']