Permalink
Browse files

Merge "Addresses lp#1004971"

  • Loading branch information...
2 parents f01d3b6 + 98e66dd commit 6729d26741e55757789cc8cf0f5c209aa0c0c3d1 Jenkins committed with openstack-gerrit Aug 10, 2012
@@ -1,4 +1,4 @@
-LAST_REBOOT_TIME_FORMAT = '%Y-%m-%d %H:%M'
+LAST_REBOOT_TIME_FORMAT = '%Y-%m-%d %H:%M:%S'
PING_IPV4_COMMAND = 'ping -c 3 '
PING_IPV6_COMMAND = 'ping6 -c 3 '
PING_PACKET_LOSS_REGEX = '(\d{1,3})\.?\d*\% packet loss'
@@ -1,7 +1,10 @@
from tempest.common.ssh import Client
from tempest.config import TempestConfig
+from tempest.common import utils
from tempest.exceptions import SSHTimeout, ServerUnreachable
+import time
+
class RemoteClient():
@@ -52,3 +55,10 @@ def get_partitions(self):
command = 'cat /proc/partitions'
output = self.ssh_client.exec_command(command)
return output
+
+ def get_boot_time(self):
+ cmd = 'date -d "`cut -f1 -d. /proc/uptime` seconds ago" \
+ "+%Y-%m-%d %H:%M:%S"'
+ boot_time_string = self.ssh_client.exec_command(cmd)
+ boot_time_string = boot_time_string.replace('\n', '')
+ return time.strptime(boot_time_string, utils.LAST_REBOOT_TIME_FORMAT)
@@ -24,13 +24,15 @@
import tempest.config
from tempest import exceptions
from tempest.common.utils.data_utils import rand_name
+from tempest.common.utils.linux.remote_client import RemoteClient
from tempest.tests.compute.base import BaseComputeTest
from tempest.tests import compute
class ServerActionsTest(BaseComputeTest):
resize_available = tempest.config.TempestConfig().compute.resize_available
+ run_ssh = tempest.config.TempestConfig().compute.run_ssh
@classmethod
def setUpClass(cls):
@@ -43,7 +45,7 @@ def setUp(self):
self.image_ref,
self.flavor_ref)
self.server_id = server['id']
-
+ self.password = server['adminPass']
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
def tearDown(self):
@@ -54,25 +56,60 @@ def tearDown(self):
'Change password not available.')
def test_change_server_password(self):
"""The server's password should be set to the provided password"""
- resp, body = self.client.change_password(self.server_id, 'newpass')
+ new_password = 'Newpass1234'
+ resp, body = self.client.change_password(self.server_id, new_password)
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ if self.run_ssh:
+ # Verify that the user can authenticate with the new password
+ resp, server = self.client.get_server(self.server_id)
+ linux_client = RemoteClient(server, self.ssh_user, new_password)
+ self.assertTrue(linux_client.can_authenticate())
+
@attr(type='smoke')
def test_reboot_server_hard(self):
""" The server should be power cycled """
+ if self.run_ssh:
+ # Get the time the server was last rebooted,
+ # waiting for one minute as who doesn't have seconds precision
+ resp, server = self.client.get_server(self.server_id)
+ linux_client = RemoteClient(server, self.ssh_user, self.password)
+ boot_time = linux_client.get_boot_time()
+ time.sleep(60)
+
resp, body = self.client.reboot(self.server_id, 'HARD')
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ if self.run_ssh:
+ # Log in and verify the boot time has changed
+ linux_client = RemoteClient(server, self.ssh_user, self.password)
+ new_boot_time = linux_client.get_boot_time()
+ self.assertGreater(new_boot_time, boot_time)
+
@attr(type='smoke')
@unittest.skip('Until bug 1014647 is dealt with.')
def test_reboot_server_soft(self):
"""The server should be signaled to reboot gracefully"""
+ if self.run_ssh:
+ # Get the time the server was last rebooted,
+ # waiting for one minute as who doesn't have seconds precision
+ resp, server = self.client.get_server(self.server_id)
+ linux_client = RemoteClient(server, self.ssh_user, self.password)
+ boot_time = linux_client.get_boot_time()
+ time.sleep(60)
+
resp, body = self.client.reboot(self.server_id, 'SOFT')
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
+ if self.run_ssh:
+ # Log in and verify the boot time has changed
+ linux_client = RemoteClient(server, self.ssh_user, self.password)
+ new_boot_time = linux_client.get_boot_time()
+ self.assertGreater(new_boot_time, boot_time)
+
@attr(type='smoke')
def test_rebuild_server(self):
""" The server should be rebuilt using the provided image and data """
@@ -81,12 +118,12 @@ def test_rebuild_server(self):
file_contents = 'Test server rebuild.'
personality = [{'path': '/etc/rebuild.txt',
'contents': base64.b64encode(file_contents)}]
-
+ password = 'rebuildPassw0rd'
resp, rebuilt_server = self.client.rebuild(self.server_id,
self.image_ref_alt,
name=new_name, meta=meta,
personality=personality,
- adminPass='rebuild')
+ adminPass=password)
#Verify the properties in the initial response are correct
self.assertEqual(self.server_id, rebuilt_server['id'])
@@ -101,6 +138,11 @@ def test_rebuild_server(self):
self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))
self.assertEqual(new_name, rebuilt_server['name'])
+ if self.run_ssh:
+ # Verify that the user can authenticate with the provided password
+ linux_client = RemoteClient(server, self.ssh_user, password)
+ self.assertTrue(linux_client.can_authenticate())
+
@attr(type='smoke')
@unittest.skipIf(not resize_available, 'Resize not available.')
def test_resize_server_confirm(self):

0 comments on commit 6729d26

Please sign in to comment.