Update attach logic in VolumeEncryptionTest
Pick the same logic as volume attach tests have, when after
volume attach server is rebooted to make sure guest OS
recognize new device.
Change-Id: I92098c7d994dc7d85643da29380866a805f4e869
Related-Prod: PRODX-360
(cherry picked from commit 40bbd545a59328363c9ca8785d0d1eaed1eb8aed)
(cherry picked from commit c17ff148134712b8c8606608ef7d7abc789605ce)
diff --git a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
index c2033fb..c7d2577 100644
--- a/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
+++ b/barbican_tempest_plugin/tests/scenario/test_volume_encryption.py
@@ -12,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
+import time
+
from oslo_log import log as logging
from tempest.common import utils
+from tempest.common import waiters
from tempest import config
from tempest.lib import decorators
+from tempest.lib import exceptions as lib_exc
from barbican_tempest_plugin.tests.scenario import barbican_manager
@@ -54,12 +58,36 @@
control_location='front-end')
return self.create_volume(volume_type=volume_type['name'])
+ def wait_for_disk(self, server_ip, keypair, device_name, wait_interval=1,
+ wait_timeout=15):
+ start = int(time.time())
+ ssh_client = self.get_remote_client(
+ server_ip, private_key=keypair['private_key'])
+ disks = ssh_client.get_disks()
+ while True:
+ time.sleep(wait_interval)
+ if device_name in disks:
+ return
+ if int(time.time()) - start >= wait_timeout:
+ message = ('Device %s did not appear in %d sec' % (
+ device_name, wait_timeout))
+ raise lib_exc.TimeoutException(message)
+
def attach_detach_volume(self, server, volume, keypair):
# Attach volume
- self.nova_volume_attach(server, volume)
+ attached_volume = self.nova_volume_attach(server, volume)
# Write a timestamp to volume
server_ip = self.get_server_ip(server)
+ self.servers_client.stop_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'SHUTOFF')
+
+ self.servers_client.start_server(server['id'])
+ waiters.wait_for_server_status(self.servers_client, server['id'],
+ 'ACTIVE')
+ self.wait_for_disk(server_ip, keypair,
+ CONF.compute.volume_device_name)
timestamp = self.create_timestamp(
server_ip,
dev_name=CONF.compute.volume_device_name,
@@ -72,6 +100,9 @@
)
self.assertEqual(timestamp, timestamp2)
+ # Detach volume
+ self.nova_volume_detach(server, attached_volume)
+
@decorators.idempotent_id('89165fb4-5534-4b9d-8429-97ccffb8f86f')
@utils.services('compute', 'volume', 'image')
def test_encrypted_cinder_volumes_luks(self):