Fixing restart tests

* Remove rax specific tests
* Fix delete test grouping
* Fix the mess up mysql logic
* Fix ovz command if CONF.use_local_ovz
* Fix logic in Checker that was masking errors in tests

Fixes: Bug #1204233

Change-Id: I6ac8abb47d4cff0ae20432f059686e4f1dd55a7e
This commit is contained in:
Robert Myers 2013-10-10 10:44:05 -05:00
parent d16940a1c3
commit 48aea9a75e
4 changed files with 15 additions and 75 deletions

View File

@ -701,35 +701,6 @@ class WaitForGuestInstallationToFinish(object):
"the instance at the end of the tests.")
@test(depends_on_classes=[WaitForGuestInstallationToFinish],
groups=[GROUP, GROUP_START, GROUP_START_SIMPLE],
enabled=CONFIG.white_box and create_new_instance())
class VerifyGuestStarted(unittest.TestCase):
"""
Test to verify the guest instance is started and we can get the init
process pid.
"""
def test_instance_created(self):
def check_status_of_instance():
status, err = process("sudo vzctl status %s | awk '{print $5}'"
% str(instance_info.local_id))
if string_in_list(status, ["running"]):
self.assertEqual("running", status.strip())
return True
else:
return False
poll_until(check_status_of_instance, sleep_time=5, time_out=(60 * 8))
def test_get_init_pid(self):
def get_the_pid():
out, err = process("pgrep init | vzpid - | awk '/%s/{print $1}'"
% str(instance_info.local_id))
instance_info.pid = out.strip()
return len(instance_info.pid) > 0
poll_until(get_the_pid, sleep_time=10, time_out=(60 * 10))
@test(depends_on_classes=[WaitForGuestInstallationToFinish],
groups=[GROUP, GROUP_START], enabled=create_new_instance())
class TestGuestProcess(object):
@ -737,33 +708,6 @@ class TestGuestProcess(object):
Test that the guest process is started with all the right parameters
"""
@test(enabled=CONFIG.use_local_ovz)
@time_out(60 * 10)
def check_process_alive_via_local_ovz(self):
init_re = ("[\w\W\|\-\s\d,]*nova-guest "
"--flagfile=/etc/nova/nova.conf nova[\W\w\s]*")
init_proc = re.compile(init_re)
guest_re = ("[\w\W\|\-\s]*/usr/bin/nova-guest "
"--flagfile=/etc/nova/nova.conf[\W\w\s]*")
guest_proc = re.compile(guest_re)
apt = re.compile("[\w\W\|\-\s]*apt-get[\w\W\|\-\s]*")
while True:
guest_process, err = process("pstree -ap %s | grep nova-guest"
% instance_info.pid)
if not string_in_list(guest_process, ["nova-guest"]):
time.sleep(10)
else:
if apt.match(guest_process):
time.sleep(10)
else:
init = init_proc.match(guest_process)
guest = guest_proc.match(guest_process)
if init and guest:
assert_true(True, init.group())
else:
assert_false(False, guest_process)
break
@test
def check_hwinfo_before_tests(self):
if CONFIG.test_mgmt:
@ -992,13 +936,14 @@ class CheckDiagnosticsAfterTests(object):
@test(depends_on=[WaitForGuestInstallationToFinish],
depends_on_groups=[GROUP_USERS, GROUP_DATABASES, GROUP_ROOT],
groups=[GROUP, GROUP_STOP])
groups=[GROUP, GROUP_STOP],
runs_after_groups=[GROUP_START,
GROUP_START_SIMPLE, GROUP_TEST, tests.INSTANCES])
class DeleteInstance(object):
""" Delete the created instance """
@time_out(3 * 60)
@test(runs_after_groups=[GROUP_START,
GROUP_START_SIMPLE, GROUP_TEST, tests.INSTANCES])
@test
def test_delete(self):
if do_not_delete_instance():
CONFIG.get_report().log("TESTS_DO_NOT_DELETE_INSTANCE=True was "
@ -1082,8 +1027,8 @@ class AfterDeleteChecks(object):
fail("Could not find instance %s" % instance_info.id)
@test(depends_on_classes=[CreateInstance, VerifyGuestStarted,
WaitForGuestInstallationToFinish],
@test(depends_on_classes=[CreateInstance,
WaitForGuestInstallationToFinish],
groups=[GROUP, GROUP_START, GROUP_START_SIMPLE],
enabled=CONFIG.test_mgmt)
class VerifyInstanceMgmtInfo(object):

View File

@ -137,10 +137,9 @@ class ActionTestBase(object):
self.connection.connect()
check.true(self.connection.is_connected(),
"Able to connect to MySQL.")
if USE_LOCAL_OVZ:
self.proc_id = self.find_mysql_proc_on_instance()
check.true(self.proc_id is not None,
"MySQL process can be found.")
"MySQL process can not be found.")
instance = self.instance
check.false(instance is None)
check.equal(instance.status, "ACTIVE")
@ -205,7 +204,7 @@ class RebootTestBase(ActionTestBase):
poll_until(is_finished_rebooting, time_out=TIME_OUT_TIME)
def assert_mysql_proc_is_different(self):
if not USE_LOCAL_OVZ:
if not USE_IP:
return
new_proc_id = self.find_mysql_proc_on_instance()
assert_not_equal(new_proc_id, self.proc_id,
@ -221,9 +220,9 @@ class RebootTestBase(ActionTestBase):
def mess_up_mysql(self):
"""Ruin MySQL's ability to restart."""
self.fix_mysql() # kill files
server = create_server_connection(self.instance_id)
cmd = "sudo cp /dev/null /var/lib/mysql/ib_logfile%d"
instance_info.dbaas_admin.management.stop(self.instance_id)
for index in range(2):
server.execute(cmd % index)

View File

@ -90,14 +90,10 @@ class Checker(object):
def __exit__(self, _type, value, tb):
self.protected = False
if len(self.messages) == 0:
final_message = None
else:
final_message = '\n'.join(self.messages)
if _type is not None: # An error occurred
if len(self.messages) == 0:
raise _type(*value.args), None, tb
self._add_exception(_type, value, tb)
if _type is not None:
# An error occurred other than an assertion failure.
# Return False to allow the Exception to be raised
return False
if len(self.messages) != 0:
final_message = '\n'.join(self.messages)
raise ASSERTION_ERROR(final_message)

View File

@ -35,7 +35,7 @@ class ServerSSHConnection(object):
self.ip_address = self.instance.ip[0]
def execute(self, cmd):
exe_cmd = "%s %s '%s'" % (tests.SSH_CMD, self.ip_address, cmd)
exe_cmd = "%s %s %s" % (tests.SSH_CMD, self.ip_address, cmd)
print("RUNNING COMMAND: %s" % exe_cmd)
return util.process(exe_cmd)
@ -50,6 +50,6 @@ class OpenVZServerConnection(object):
self.instance_local_id = self.instance.server["local_id"]
def execute(self, cmd):
exe_cmd = "sudo vzctl exec %s '%s'" % (self.instance_local_id, cmd)
exe_cmd = "sudo vzctl exec %s %s" % (self.instance_local_id, cmd)
print("RUNNING COMMAND: %s" % exe_cmd)
return util.process(exe_cmd)