From d28b6868f56ab6f8e40bdbfd8e5c433c17be0f9e Mon Sep 17 00:00:00 2001 From: Maksim Malchuk Date: Mon, 6 Jun 2016 19:00:04 +0300 Subject: [PATCH] Fix instance volume mount script creation Now the volume mount script would be created with correct newlines. Also, this change contain some additional debugging information, so the process of creating and mounting the volume logged to the instance /var/log/messages through syslog. Also, this commit contain the the workaround for the AuthenticationException because the Cirros image starts ssh servece just before the cloud-init and in some cases we need to wait when the instance_initial_scenario canges the password for the cirros user. Change-Id: Icb981c90a5ed8beb75fa119158161bf5ea3e5900 Closes-Bug: #1588808 Signed-off-by: Maksim Malchuk --- fuelweb_test/helpers/instance_initial_scenario | 2 +- fuelweb_test/tests/test_ceph.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fuelweb_test/helpers/instance_initial_scenario b/fuelweb_test/helpers/instance_initial_scenario index ea88f675b..5514fa70d 100644 --- a/fuelweb_test/helpers/instance_initial_scenario +++ b/fuelweb_test/helpers/instance_initial_scenario @@ -4,7 +4,7 @@ echo "Creating test file" touch /home/test_file echo "Creating volume mount script on instance" -echo "#!/bin/sh\nsudo /usr/sbin/mkfs.ext4 /dev/vdb\nsudo mount /dev/vdb /mnt" | tee /home/mount_volume.sh +echo -e '#!/bin/sh\nsudo /usr/sbin/mkfs.ext4 /dev/vdb | logger -t mount_volume.sh\nsudo mount -t ext4 /dev/vdb /mnt | logger -t mount_volume.sh\nmount | grep /mnt | logger -t mount_volume.sh' | tee /home/mount_volume.sh chmod 777 /home/mount_volume.sh echo -e "test\ntest" | passwd cirros diff --git a/fuelweb_test/tests/test_ceph.py b/fuelweb_test/tests/test_ceph.py index 7ff08e121..d4b5a8d71 100644 --- a/fuelweb_test/tests/test_ceph.py +++ b/fuelweb_test/tests/test_ceph.py @@ -16,6 +16,7 @@ import time from ConfigParser import ConfigParser from cStringIO import StringIO +import paramiko from pkg_resources import parse_version from proboscis.asserts import assert_true, assert_false, assert_equal from proboscis import SkipTest @@ -657,7 +658,17 @@ class VmBackedWithCephMigrationBasic(TestBasic): wait(lambda: tcp_ping(floating_ip.ip, 22), timeout=120) + def ssh_ready(remote, ip, creds): + try: + os.execute_through_host(remote, ip, '/bin/true', creds) + return True + except paramiko.AuthenticationException: + logger.info("Authentication failed. Trying again in a minute.") + time.sleep(60) + return False + with self.fuel_web.get_ssh_for_node("slave-01") as remote: + wait(lambda: ssh_ready(remote, floating_ip.ip, creds), timeout=300) md5before = os.get_md5sum( "/home/test_file", remote, floating_ip.ip, creds) @@ -745,6 +756,8 @@ class VmBackedWithCephMigrationBasic(TestBasic): logger.info("Create filesystem and mount volume") with self.fuel_web.get_ssh_for_node("slave-01") as remote: + wait(lambda: ssh_ready(remote, floating_ip.ip, creds), timeout=300) + os.execute_through_host( remote, floating_ip.ip, 'sudo sh /home/mount_volume.sh', creds)