Add mount/umount in scenario tests
This adds mounting and unmounting of a created share. In order to be sure that the nfs/cfis tools are available in the used image it's using the default Ubuntu nfs/cifs image. Since cloudinit is not supported for this image it's using username/password authentication as workaround. Change-Id: I77720ba5beb836614728081bbf74b44991d6e284 Partially-implements: blueprint scenario-tests
This commit is contained in:
parent
11ad2112cc
commit
0d9c1e6489
@ -113,6 +113,16 @@ ShareGroup = [
|
|||||||
help="Defines whether to run manage/unmanage tests or not. "
|
help="Defines whether to run manage/unmanage tests or not. "
|
||||||
"These test may leave orphaned resources, so be careful "
|
"These test may leave orphaned resources, so be careful "
|
||||||
"enabling this opt."),
|
"enabling this opt."),
|
||||||
|
cfg.StrOpt("image_with_share_tools",
|
||||||
|
default="ubuntu_1204_nfs_cifs",
|
||||||
|
help="Image name for vm booting with nfs/smb clients tool."),
|
||||||
|
cfg.StrOpt("image_username",
|
||||||
|
default="ubuntu",
|
||||||
|
help="Image username."),
|
||||||
|
# HINT(mkoderer): workaround for bug #1421104
|
||||||
|
cfg.StrOpt("image_password",
|
||||||
|
default="ubuntu",
|
||||||
|
help="Image password."),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,10 +13,13 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import six # noqa
|
||||||
|
|
||||||
from oslo_log import log # noqa
|
from oslo_log import log # noqa
|
||||||
from tempest_lib.common.utils import data_utils # noqa
|
from tempest_lib.common.utils import data_utils # noqa
|
||||||
|
|
||||||
from tempest import clients_share
|
from tempest import clients_share
|
||||||
|
from tempest.common.utils.linux import remote_client
|
||||||
from tempest import config
|
from tempest import config
|
||||||
from tempest.scenario import manager
|
from tempest.scenario import manager
|
||||||
|
|
||||||
@ -150,3 +153,30 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
|
|||||||
subnet_id)
|
subnet_id)
|
||||||
self.addCleanup(client.remove_router_interface_with_subnet_id,
|
self.addCleanup(client.remove_router_interface_with_subnet_id,
|
||||||
router_id, subnet_id)
|
router_id, subnet_id)
|
||||||
|
|
||||||
|
def get_remote_client(self, *args, **kwargs):
|
||||||
|
if not CONF.share.image_with_share_tools:
|
||||||
|
return super(ShareScenarioTest,
|
||||||
|
self).get_remote_client(*args, **kwargs)
|
||||||
|
# HINT(mkoderer): as workaround for bug #1421104 we have to ignore the
|
||||||
|
# keypair and use the configured username and password
|
||||||
|
server_or_ip = kwargs['server_or_ip']
|
||||||
|
if isinstance(server_or_ip, six.string_types):
|
||||||
|
ip = server_or_ip
|
||||||
|
else:
|
||||||
|
addr = server_or_ip['addresses'][CONF.compute.network_for_ssh][0]
|
||||||
|
ip = addr['addr']
|
||||||
|
|
||||||
|
username = CONF.share.image_username
|
||||||
|
password = CONF.share.image_password
|
||||||
|
|
||||||
|
linux_client = remote_client.RemoteClient(ip, username=username,
|
||||||
|
password=password, pkey=None)
|
||||||
|
try:
|
||||||
|
linux_client.validate_authentication()
|
||||||
|
except Exception:
|
||||||
|
LOG.exception('Initializing SSH connection to %s failed' % ip)
|
||||||
|
self._log_console_output()
|
||||||
|
raise
|
||||||
|
|
||||||
|
return linux_client
|
||||||
|
@ -17,6 +17,7 @@ from oslo_log import log as logging # noqa
|
|||||||
from tempest_lib.common.utils import data_utils # noqa
|
from tempest_lib.common.utils import data_utils # noqa
|
||||||
|
|
||||||
from tempest import config
|
from tempest import config
|
||||||
|
from tempest import exceptions
|
||||||
from tempest.scenario import manager_share as manager
|
from tempest.scenario import manager_share as manager
|
||||||
from tempest.scenario import utils as test_utils
|
from tempest.scenario import utils as test_utils
|
||||||
from tempest import test
|
from tempest import test
|
||||||
@ -37,6 +38,7 @@ class TestShareBasicOps(manager.ShareScenarioTest):
|
|||||||
* Launch an instance
|
* Launch an instance
|
||||||
* Allow access
|
* Allow access
|
||||||
* Perform ssh to instance
|
* Perform ssh to instance
|
||||||
|
* Mount share
|
||||||
* Terminate the instance
|
* Terminate the instance
|
||||||
"""
|
"""
|
||||||
protocol = "NFS"
|
protocol = "NFS"
|
||||||
@ -45,10 +47,18 @@ class TestShareBasicOps(manager.ShareScenarioTest):
|
|||||||
super(TestShareBasicOps, self).setUp()
|
super(TestShareBasicOps, self).setUp()
|
||||||
# Setup image and flavor the test instance
|
# Setup image and flavor the test instance
|
||||||
# Support both configured and injected values
|
# Support both configured and injected values
|
||||||
if not hasattr(self, 'image_ref'):
|
|
||||||
self.image_ref = CONF.compute.image_ref
|
|
||||||
if not hasattr(self, 'flavor_ref'):
|
if not hasattr(self, 'flavor_ref'):
|
||||||
self.flavor_ref = CONF.compute.flavor_ref
|
self.flavor_ref = CONF.compute.flavor_ref
|
||||||
|
if CONF.share.image_with_share_tools:
|
||||||
|
images = self.images_client.list_images()
|
||||||
|
for img in images:
|
||||||
|
if img["name"] == CONF.share.image_with_share_tools:
|
||||||
|
self.image_ref = img['id']
|
||||||
|
break
|
||||||
|
if not self.image_ref:
|
||||||
|
msg = ("Image %s not found" %
|
||||||
|
CONF.share.image_with_share_tools)
|
||||||
|
raise exceptions.InvalidConfiguration(message=msg)
|
||||||
self.image_utils = test_utils.ImageUtils()
|
self.image_utils = test_utils.ImageUtils()
|
||||||
if not self.image_utils.is_flavor_enough(self.flavor_ref,
|
if not self.image_utils.is_flavor_enough(self.flavor_ref,
|
||||||
self.image_ref):
|
self.image_ref):
|
||||||
@ -73,7 +83,8 @@ class TestShareBasicOps(manager.ShareScenarioTest):
|
|||||||
'key_name': self.keypair['name'],
|
'key_name': self.keypair['name'],
|
||||||
'security_groups': security_groups,
|
'security_groups': security_groups,
|
||||||
}
|
}
|
||||||
self.instance = self.create_server(create_kwargs=create_kwargs)
|
self.instance = self.create_server(image=self.image_ref,
|
||||||
|
create_kwargs=create_kwargs)
|
||||||
|
|
||||||
def verify_ssh(self):
|
def verify_ssh(self):
|
||||||
# Obtain a floating IP
|
# Obtain a floating IP
|
||||||
@ -85,13 +96,19 @@ class TestShareBasicOps(manager.ShareScenarioTest):
|
|||||||
self.floating_ips_client.associate_floating_ip_to_server(
|
self.floating_ips_client.associate_floating_ip_to_server(
|
||||||
floating_ip['ip'], self.instance['id'])
|
floating_ip['ip'], self.instance['id'])
|
||||||
# Check ssh
|
# Check ssh
|
||||||
ssh_client = self.get_remote_client(
|
self.ssh_client = self.get_remote_client(
|
||||||
server_or_ip=floating_ip['ip'],
|
server_or_ip=floating_ip['ip'],
|
||||||
username=self.ssh_user,
|
username=self.ssh_user,
|
||||||
private_key=self.keypair['private_key'])
|
private_key=self.keypair['private_key'])
|
||||||
share = self.shares_client.get_share(self.share['id'])
|
self.share = self.shares_client.get_share(self.share['id'])
|
||||||
server_ip = share['export_location'].split(":")[0]
|
server_ip = self.share['export_location'].split(":")[0]
|
||||||
ssh_client.exec_command("ping -c 1 %s" % server_ip)
|
self.ssh_client.exec_command("ping -c 1 %s" % server_ip)
|
||||||
|
|
||||||
|
def mount_share(self, location):
|
||||||
|
self.ssh_client.exec_command("sudo mount \"%s\" /mnt" % location)
|
||||||
|
|
||||||
|
def umount_share(self):
|
||||||
|
self.ssh_client.exec_command("sudo umount /mnt")
|
||||||
|
|
||||||
def create_share_network(self):
|
def create_share_network(self):
|
||||||
self.net = self._create_network(namestart="manila-share")
|
self.net = self._create_network(namestart="manila-share")
|
||||||
@ -131,4 +148,7 @@ class TestShareBasicOps(manager.ShareScenarioTest):
|
|||||||
self.boot_instance(self.net)
|
self.boot_instance(self.net)
|
||||||
self.allow_access_ip(self.share['id'], instance=self.instance)
|
self.allow_access_ip(self.share['id'], instance=self.instance)
|
||||||
self.verify_ssh()
|
self.verify_ssh()
|
||||||
|
for location in self.share['export_locations']:
|
||||||
|
self.mount_share(location)
|
||||||
|
self.umount_share()
|
||||||
self.servers_client.delete_server(self.instance['id'])
|
self.servers_client.delete_server(self.instance['id'])
|
||||||
|
Loading…
Reference in New Issue
Block a user