Extend while attached volume
Adding two tests scenarios for extending bootable volumes in Cinder. Co-Authored-By: Benny Kopilov <bkopilov@redhat.com> Change-Id: I3b7f2b4a7bfad96e8623d2c895d09815e4069c9c
This commit is contained in:
parent
6e36e2bd98
commit
417b3a7804
|
@ -0,0 +1,146 @@
|
|||
# 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.
|
||||
|
||||
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.scenario import manager
|
||||
|
||||
CONF = config.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestVolumeExtendWhileAttached(manager.ScenarioTest):
|
||||
|
||||
"""This test case attempts to reproduce the following steps:
|
||||
|
||||
* Create a Cinder volume
|
||||
* Create an instance and attach the volume
|
||||
* Write some data to the volume
|
||||
* Extend the attached volume
|
||||
* Check volume's data
|
||||
* Check volume's size
|
||||
* Check the extend operation is correct
|
||||
"""
|
||||
volume_min_microversion = '3.42'
|
||||
|
||||
@classmethod
|
||||
def skip_checks(cls):
|
||||
super(TestVolumeExtendWhileAttached, cls).skip_checks()
|
||||
if not CONF.volume_feature_enabled.extend_attached_volume:
|
||||
raise cls.skipException('Extend attached volumes is not enabled.')
|
||||
|
||||
def _create_volume(self):
|
||||
return self.create_volume()
|
||||
|
||||
def setUp(self):
|
||||
super(TestVolumeExtendWhileAttached, self).setUp()
|
||||
self.volume = self._create_volume()
|
||||
|
||||
@decorators.idempotent_id('12ba5c30-bb18-4b23-97f4-9a9e97e91c80')
|
||||
@utils.services('compute', 'volume')
|
||||
def test_volume_extend_while_attached_to_instance(self):
|
||||
# keypair and security group allows ssh to instance
|
||||
keypair1 = self.create_keypair()
|
||||
security_group1 = self._create_security_group()
|
||||
|
||||
# Create an instance with ssh access
|
||||
kwargs = {'key_name': keypair1['name'],
|
||||
'security_groups': [{'name': security_group1['name']}]}
|
||||
server = self.create_server(**kwargs)
|
||||
ip_server = self.get_server_ip(server)
|
||||
private_key = keypair1['private_key']
|
||||
|
||||
# attach
|
||||
attach_info = self.nova_volume_attach(server, self.volume)
|
||||
self.addCleanup(self.nova_volume_detach, server, self.volume)
|
||||
device = attach_info['attachments'][0]['device']
|
||||
|
||||
# write content to volume on instance
|
||||
timestamp = self.create_timestamp(ip_server,
|
||||
private_key=keypair1['private_key'],
|
||||
server=server)
|
||||
|
||||
original_size = self.volume['size']
|
||||
expected_size = original_size * 2
|
||||
|
||||
# Check the size before extend
|
||||
ssh_client = self.get_remote_client(ip_server,
|
||||
private_key=private_key,
|
||||
server=server)
|
||||
cmd = "sudo blockdev --getsize64 " + device
|
||||
device_size = int(ssh_client.exec_command(cmd)) / (1024**3)
|
||||
self.assertEqual(original_size, int(round(device_size, 0)))
|
||||
|
||||
# extend volume while attahced to instance
|
||||
self.volumes_client.extend_volume(self.volume['id'],
|
||||
new_size=expected_size)
|
||||
waiters.wait_for_volume_resource_status(self.volumes_client,
|
||||
self.volume['id'], 'in-use')
|
||||
|
||||
# verify the data
|
||||
timestamp2 = self.get_timestamp(ip_server,
|
||||
private_key=private_key,
|
||||
server=server)
|
||||
self.assertEqual(timestamp, timestamp2)
|
||||
|
||||
# Check the size after extend
|
||||
ssh_client_2 = self.get_remote_client(ip_server,
|
||||
private_key=private_key,
|
||||
server=server)
|
||||
device_new_size = int(ssh_client_2.exec_command(cmd)) / (1024**3)
|
||||
self.assertEqual(expected_size, int(round(device_new_size, 0)))
|
||||
|
||||
# verify disk size changed in the instance
|
||||
volume = self.volumes_client.show_volume(self.volume['id'])['volume']
|
||||
self.assertEqual(volume['size'], expected_size)
|
||||
|
||||
|
||||
class TestEncryptedVolumeExtendWhileAttached(TestVolumeExtendWhileAttached,
|
||||
manager.EncryptionScenarioTest):
|
||||
|
||||
"""This test case attempts to reproduce the following steps:
|
||||
|
||||
* Create a encrypted Cinder volume
|
||||
* Create an instance and attach the volume
|
||||
* Write some data to the volume
|
||||
* Extend the attached volume
|
||||
* Check volume's data
|
||||
* Check volume's size
|
||||
* Check the extend operation is correct
|
||||
"""
|
||||
def create_encrypted_volume(self, encryption_provider='luks',
|
||||
key_size=256, cipher='aes-xts-plain64',
|
||||
size=1, control_location='front-end',
|
||||
volume_type=None, imageRef=None):
|
||||
if not size:
|
||||
size = 1
|
||||
# in case volume_type already created
|
||||
if not volume_type:
|
||||
volume_type = self.create_volume_type()
|
||||
|
||||
self.create_encryption_type(type_id=volume_type['id'],
|
||||
provider=encryption_provider,
|
||||
key_size=key_size,
|
||||
cipher=cipher,
|
||||
control_location=control_location)
|
||||
return self.create_volume(volume_type=volume_type['name'],
|
||||
imageRef=imageRef, size=size)
|
||||
|
||||
def _create_volume(self):
|
||||
return self.create_encrypted_volume()
|
||||
|
||||
def setUp(self):
|
||||
super(TestEncryptedVolumeExtendWhileAttached, self).setUp()
|
Loading…
Reference in New Issue