Merge "Add mount/umount in scenario tests"

This commit is contained in:
Jenkins 2015-04-21 03:14:46 +00:00 committed by Gerrit Code Review
commit 85f067cff5
3 changed files with 67 additions and 7 deletions

View File

@ -113,6 +113,16 @@ ShareGroup = [
help="Defines whether to run manage/unmanage tests or not. "
"These test may leave orphaned resources, so be careful "
"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."),
]

View File

@ -13,10 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import six # noqa
from oslo_log import log # noqa
from tempest_lib.common.utils import data_utils # noqa
from tempest import clients_share
from tempest.common.utils.linux import remote_client
from tempest import config
from tempest.scenario import manager
@ -150,3 +153,30 @@ class ShareScenarioTest(manager.NetworkScenarioTest):
subnet_id)
self.addCleanup(client.remove_router_interface_with_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

View File

@ -17,6 +17,7 @@ from oslo_log import log as logging # noqa
from tempest_lib.common.utils import data_utils # noqa
from tempest import config
from tempest import exceptions
from tempest.scenario import manager_share as manager
from tempest.scenario import utils as test_utils
from tempest import test
@ -37,6 +38,7 @@ class TestShareBasicOps(manager.ShareScenarioTest):
* Launch an instance
* Allow access
* Perform ssh to instance
* Mount share
* Terminate the instance
"""
protocol = "NFS"
@ -45,10 +47,18 @@ class TestShareBasicOps(manager.ShareScenarioTest):
super(TestShareBasicOps, self).setUp()
# Setup image and flavor the test instance
# 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'):
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()
if not self.image_utils.is_flavor_enough(self.flavor_ref,
self.image_ref):
@ -73,7 +83,8 @@ class TestShareBasicOps(manager.ShareScenarioTest):
'key_name': self.keypair['name'],
'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):
# Obtain a floating IP
@ -85,13 +96,19 @@ class TestShareBasicOps(manager.ShareScenarioTest):
self.floating_ips_client.associate_floating_ip_to_server(
floating_ip['ip'], self.instance['id'])
# Check ssh
ssh_client = self.get_remote_client(
self.ssh_client = self.get_remote_client(
server_or_ip=floating_ip['ip'],
username=self.ssh_user,
private_key=self.keypair['private_key'])
share = self.shares_client.get_share(self.share['id'])
server_ip = share['export_location'].split(":")[0]
ssh_client.exec_command("ping -c 1 %s" % server_ip)
self.share = self.shares_client.get_share(self.share['id'])
server_ip = self.share['export_location'].split(":")[0]
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):
self.net = self._create_network(namestart="manila-share")
@ -131,4 +148,7 @@ class TestShareBasicOps(manager.ShareScenarioTest):
self.boot_instance(self.net)
self.allow_access_ip(self.share['id'], instance=self.instance)
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'])