Skip to content

Commit

Permalink
Fix testcase failures for run_command api changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Pridhiviraj Paidipeddi <[email protected]>
Signed-off-by: Stewart Smith <[email protected]>
  • Loading branch information
pridhiviraj authored and stewartsmith committed Apr 3, 2017
1 parent 6e9d2ee commit 259d7da
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 139 deletions.
4 changes: 2 additions & 2 deletions common/OpTestConstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ class OpTestConstants():
IPMI_FIREWALL_INFO = "firewall info channel 1 lun 0"
IPMI_PEF_INFO = "pef info"
IPMI_PEF_STATUS = "pef status"
IPMI_PEF_POLICY = "pef policy"
IPMI_PEF_LIST = "pef list"
IPMI_PEF_POLICY = "pef policy help"
IPMI_PEF_LIST = "pef policy list"
IPMI_RAW_POH = "-v raw 0x0 0xf"
IPMI_SDR_GET = "sdr get "

Expand Down
20 changes: 17 additions & 3 deletions common/OpTestHost.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def host_check_command(self, *i_cmd):
try:
l_res = self.host_run_command(l_cmd)
except CommandFailed as c:
l_msg = "host_check_command: (%s) not present on host. output of '%s': %s" % (','.join(i_cmd), l_cmd, '\n'.join(l_res))
l_msg = "host_check_command: (%s) not present on host. output of '%s': %s" % (','.join(i_cmd), l_cmd, '\n'.join(c.output))
print l_msg
raise OpTestError(l_msg)

Expand Down Expand Up @@ -928,10 +928,24 @@ def host_clear_all_dumps(self):
def host_disable_kdump_service(self, os_level):
if "Ubuntu" in os_level:
self.host_run_command("systemctl stop kdump-tools.service")
self.host_run_command("systemctl status kdump-tools.service")
try:
self.host_run_command("systemctl status kdump-tools.service")
except CommandFailed as cf:
if cf.exitcode == 3:
pass
else:
print str(cf)
raise OpTestError("kdump-tools service is failed to stop")
else:
self.host_run_command("systemctl stop kdump.service")
self.host_run_command("systemctl status kdump.service")
try:
self.host_run_command("systemctl status kdump.service")
except CommandFailed as cf:
if cf.exitcode == 3:
pass
else:
print str(cf)
raise OpTestError("kdump service is failed to stop")

##
# @brief This function disables kdump service
Expand Down
6 changes: 0 additions & 6 deletions common/OpTestSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ def run_OFF(self, state):
if state == OpSystemState.PETITBOOT:
self.cv_IPMI.ipmi_set_boot_to_petitboot()

# Make sure system is in standby state before power on.
# otherwise ipmi power on will be non functional
r = self.sys_wait_for_standby_state()
if r == BMC_CONST.FW_FAILED:
raise "Invalid state transition from runtime to runtime"

r = self.sys_power_on()
# Only retry once
if r == BMC_CONST.FW_FAILED:
Expand Down
1 change: 1 addition & 0 deletions op-test
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ from testcases import OpalErrorLog
from testcases import LightPathDiagnostics
from testcases import DPO
from testcases import EPOW
from testcases import OpTestKernel
import testcases

args, remaining_args = OpTestConfiguration.conf.parse_args(sys.argv)
Expand Down
1 change: 1 addition & 0 deletions testcases/EPOW.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def get_epow_limits(self):
print limits
cmd = cmd + "| cut -d '#' -f 1"
limits = self.cv_FSP.fspc.run_command(cmd)
limits = limits.splitlines()
dic = {}
for i in range(len(limits)):
pair = ((limits[i]).replace(" ", "")).replace("\t", "")
Expand Down
17 changes: 8 additions & 9 deletions testcases/OpTestDumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def tearDown(self):
self.cv_HOST.host_gather_opal_msg_log()
self.cv_HOST.host_gather_kernel_log()


def fipsdump_initiate_from_host(self):
dumpname = self.cv_FSP.fsp_run_command("fipsdump -l | sed 's/\ .*//'")
self.cv_HOST.host_run_command('echo 1 > /sys/firmware/opal/dump/initiate_dump')
Expand Down Expand Up @@ -92,7 +91,7 @@ def fipsdump_initiate_from_host(self):
for j in range(1, tries):
time.sleep(4)
res = self.cv_HOST.host_run_command('ls /var/log/dump')
if res.__contains__(new_dumpname):
if '\n'.join(res).__contains__(new_dumpname):
print "fips dump transfered to host"
break
self.assertIn(new_dumpname, res,
Expand All @@ -105,13 +104,13 @@ def verify_fipsdump(self, dumpname, size_fsp):
for j in range(1, tries):
time.sleep(5)
res = self.cv_HOST.host_run_command('ls /var/log/dump')
if res.__contains__(dumpname):
if '\n'.join(res).__contains__(dumpname):
print "FipS dump transfered to Host"
break
self.assertIn(dumpname, res,
self.assertIn(dumpname, '\n'.join(res),
"fips dump file transfer to host is failed when initiates from host")
cmd = "ls /var/log/dump/%s -l| awk '{print $5}'" % dumpname
size_host = (self.cv_HOST.host_run_command(cmd)).strip()
size_host = '\n'.join((self.cv_HOST.host_run_command(cmd))).strip()
if size_fsp.__contains__(size_host):
print "Total size of FSP dump file transfered to host from fsp"
else:
Expand All @@ -133,7 +132,7 @@ def runTest(self):
if "FSP" not in self.bmc_type:
self.skipTest("FSP Platform OPAL specific dump tests")
self.cv_HOST.host_check_command("opal-dump-parse")
self.cv_HOST.host_run_command("rm -rf /var/log/dump/SYSDUMP* \r")
self.cv_HOST.host_run_command("rm -rf /var/log/dump/SYSDUMP*")
self.cv_FSP.fsp_get_console()
if not self.cv_FSP.mount_exists():
raise OpTestError("Please mount NFS and retry the test")
Expand All @@ -156,9 +155,9 @@ def runTest(self):
print res
res = self.cv_HOST.host_run_command("opal-dump-parse -l /var/log/dump/SYSDUMP*")
print res
self.assertIn("Opal", res, "sysdump test failed in dumping Opal-log section")
self.assertIn("HostBoot-Runtime-log", res, "sysdump test failed in dumping HBRT section")
self.assertIn("printk", res, "sysdump test failed in dumping printk section")
self.assertIn("Opal", '\n'.join(res), "sysdump test failed in dumping Opal-log section")
self.assertIn("HostBoot-Runtime-log", '\n'.join(res), "sysdump test failed in dumping HBRT section")
self.assertIn("printk", '\n'.join(res), "sysdump test failed in dumping printk section")

class FIPS_DUMP(OpTestDumps):

Expand Down
1 change: 1 addition & 0 deletions testcases/OpTestEM.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import OpTestConfiguration
from common.OpTestUtil import OpTestUtil
from common.OpTestSystem import OpSystemState
from common.Exceptions import CommandFailed


class OpTestEM():
Expand Down
6 changes: 3 additions & 3 deletions testcases/OpTestEnergyScale.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def setUp(self):
#
def run_ipmi_cmd(self, i_cmd):
l_cmd = i_cmd
l_res = self.cv_IPMI.ipmitool_run(l_cmd)
l_res = self.cv_IPMI.ipmitool.run(l_cmd)
print l_res
return l_res

Expand Down Expand Up @@ -163,7 +163,7 @@ class OpTestEnergyScaleRuntime(OpTestEnergyScale):
# @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
#
def runTest(self):
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
self.cv_SYSTEM.goto_state(OpSystemState.OS)

print "Energy Scale Test 2: Get, Set, activate and deactivate platform power limit at runtime"
l_power_limit_low, l_power_limit_high = self.get_platform_power_limits(self.cv_PLATFORM)
Expand Down Expand Up @@ -244,7 +244,7 @@ def runTest(self):

class OpTestEnergyScaleDCMIruntime(OpTestEnergyScale):
def runTest(self):
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
self.cv_SYSTEM.goto_state(OpSystemState.OS)

print "Performing a IPMI Power ON Operation"
# Perform a IPMI Power ON Operation
Expand Down
133 changes: 61 additions & 72 deletions testcases/OpTestHMIHandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ def ipmi_monitor_sol_ipl(self, console, timeout):
self.assertTrue(ipl_status, "HMI Core checkstop: IPL not started/finished")
return

def verify_proc_recovery(self, l_res):
if any("Processor Recovery done" in line for line in l_res) and \
any("Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
print "Processor recovery done"
return
else:
raise Exception("HMI handling failed to log message: for proc_recv_done")

def verify_timer_facility_recovery(self, l_res):
if any("Timer facility experienced an error" in line for line in l_res) and \
any("Severe Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
print "Timer facility experienced an error and got recovered"
return
else:
raise Exception("HMI handling failed to log message")

def init_test(self):
self.cv_SYSTEM.goto_state(OpSystemState.OS)
Expand Down Expand Up @@ -253,28 +268,22 @@ def _test_proc_recv_done(self):
console = self.cv_SYSTEM.sys_get_ipmi_console()
console.run_command("dmesg -C")
try:
l_res = console.run_command(l_cmd)
l_res = console.run_command(l_cmd,timeout=120)
except CommandFailed as cf:
if cf.exitcode == 5:
if cf.exitcode == 1:
pass
else:
raise cf
else:
if any("Kernel panic - not syncing" in line for line in l_res):
raise Exception("Processor recovery failed: Kernel got panic")
elif any("Petitboot" in line for line in l_res):
raise Exception("System reached petitboot:Processor recovery failed")
elif any("ISTEP" in line for line in l_res):
raise Exception("System started booting: Processor recovery failed")
else:
raise Exception("Failed to inject thread hang recoverable error")

if any("Kernel panic - not syncing" in line for line in l_res):
raise Exception("Processor recovery failed: Kernel got panic")
elif any("Petitboot" in line for line in l_res):
raise Exception("System reached petitboot:Processor recovery failed")
elif any("ISTEP" in line for line in l_res):
raise Exception("System started booting: Processor recovery failed")
else:
raise Exception("Failed to inject thread hang recoverable error %s", str(cf))
time.sleep(0.2)
l_res = console.run_command("dmesg")
if any("Processor Recovery done" in line for line in l_res) and \
any("Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
print "Processor recovery done"
else:
raise Exception("HMI handling failed to log message: for proc_recv_done")
self.verify_proc_recovery(l_res)
return

##
Expand All @@ -290,28 +299,22 @@ def _test_proc_recv_error_masked(self):
console = self.cv_SYSTEM.sys_get_ipmi_console()
console.run_command("dmesg -C")
try:
l_res = console.run_command(l_cmd)
l_res = console.run_command(l_cmd, timeout=120)
except CommandFailed as cf:
if cf.exitcode == 1:
pass
else:
raise cf
else:
if any("Kernel panic - not syncing" in line for line in l_res):
raise Exception("Processor recovery failed: Kernel got panic")
elif any("Petitboot" in line for line in l_res):
raise Exception("System reached petitboot:Processor recovery failed")
elif any("ISTEP" in line for line in l_res):
raise Exception("System started booting: Processor recovery failed")
else:
raise Exception("Failed to inject thread hang recoverable error")

if any("Kernel panic - not syncing" in line for line in l_res):
raise Exception("Processor recovery failed: Kernel got panic")
elif any("Petitboot" in line for line in l_res):
raise Exception("System reached petitboot:Processor recovery failed")
elif any("ISTEP" in line for line in l_res):
raise Exception("System started booting: Processor recovery failed")
else:
raise Exception("Failed to inject thread hang recoverable error %s", str(cf))
time.sleep(0.2)
l_res = console.run_command("dmesg")
if any("Processor Recovery done" in line for line in l_res) and \
any("Harmless Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
print "Processor recovery done"
else:
raise Exception("HMI handling failed to log message")
self.verify_proc_recovery(l_res)
return

##
Expand Down Expand Up @@ -376,30 +379,23 @@ def _testTFMR_Errors(self, i_error):
console = self.cv_SYSTEM.sys_get_ipmi_console()
console.run_command("dmesg -C")
try:
l_res = console.run_command(l_cmd)
l_res = console.run_command(l_cmd, timeout=120)
except CommandFailed as cf:
if cf.exitcode == 1:
pass
else:
raise cf
else:
if any("Kernel panic - not syncing" in line for line in l_res):
l_msg = "TFMR error injection: Kernel got panic"
elif any("Petitboot" in line for line in l_res):
l_msg = "System reached petitboot:TFMR error injection recovery failed"
elif any("ISTEP" in line for line in l_res):
l_msg = "System started booting: TFMR error injection recovery failed"
else:
raise Exception("Failed to inject TFMR error %s " % l_error)
if any("Kernel panic - not syncing" in line for line in l_res):
l_msg = "TFMR error injection: Kernel got panic"
elif any("Petitboot" in line for line in l_res):
l_msg = "System reached petitboot:TFMR error injection recovery failed"
elif any("ISTEP" in line for line in l_res):
l_msg = "System started booting: TFMR error injection recovery failed"
else:
raise Exception("Failed to inject TFMR error %s " % str(cf))

time.sleep(0.2)
l_res = console.run_command("dmesg")
if any("Timer facility experienced an error" in line for line in l_res) and \
any("Severe Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
print "Timer facility experienced an error and got recovered"
else:
raise Exception("HMI handling failed to log message")

self.verify_timer_facility_recovery(l_res)
return

##
Expand All @@ -425,31 +421,24 @@ def _test_tod_errors(self, i_error):
# But getscom to TOD error reg there is no access
# TOD Error reg has only WO access and there is no read access
try:
l_res = console.run_command(l_cmd)
l_res = console.run_command(l_cmd, timeout=120)
except CommandFailed as cf:
if cf.exitcode == 1:
pass
else:
raise cf
else:
if any("Kernel panic - not syncing" in line for line in l_res):
print "TOD ERROR Injection-kernel got panic"
elif any("login:" in line for line in l_res):
print "System booted to host OS without any kernel panic message"
elif any("Petitboot" in line for line in l_res):
print "System reached petitboot without any kernel panic message"
elif any("ISTEP" in line for line in l_res):
print "System started booting without any kernel panic message"
else:
raise Exception("TOD: PSS Hamming distance error injection failed")

if any("Kernel panic - not syncing" in line for line in l_res):
print "TOD ERROR Injection-kernel got panic"
elif any("login:" in line for line in l_res):
print "System booted to host OS without any kernel panic message"
elif any("Petitboot" in line for line in l_res):
print "System reached petitboot without any kernel panic message"
elif any("ISTEP" in line for line in l_res):
print "System started booting without any kernel panic message"
else:
raise Exception("TOD: PSS Hamming distance error injection failed %s", str(c))
time.sleep(0.2)
l_res = console.run_command("dmesg")
if any("Timer facility experienced an error" in line for line in l_res) and \
any("Severe Hypervisor Maintenance interrupt [Recovered]" in line for line in l_res):
print "Timer facility experienced an error and got recovered"
else:
raise Exception("HMI handling failed to log message")

self.verify_timer_facility_recovery(l_res)
return

##
Expand Down
Loading

0 comments on commit 259d7da

Please sign in to comment.