Skip to content

Commit 8d4ce4f

Browse files
authored
Merge pull request #139 from pridhiviraj/torture_tests
IPMI and Console Torture tests
2 parents 2f7924d + 66b9676 commit 8d4ce4f

File tree

3 files changed

+280
-3
lines changed

3 files changed

+280
-3
lines changed

common/OpTestIPMI.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ def arguments(self):
6565
s += ' '
6666
return s
6767

68-
def run(self, cmd, background=False, cmdprefix=None):
68+
def run(self, cmd, background=False, cmdprefix=None, logcmd=True):
6969
if cmdprefix:
7070
cmd = cmdprefix + self.binary + self.arguments() + cmd
7171
else:
7272
cmd = self.binary + self.arguments() + cmd
73-
print cmd
73+
if logcmd:
74+
print cmd
7475
if background:
7576
try:
7677
child = subprocess.Popen(cmd, shell=True)

testcases/IpmiTorture.py

+270
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
#!/usr/bin/python
2+
# OpenPOWER Automated Test Project
3+
#
4+
# Contributors Listed Below - COPYRIGHT 2017
5+
# [+] International Business Machines Corp.
6+
#
7+
#
8+
# Licensed under the Apache License, Version 2.0 (the "License");
9+
# you may not use this file except in compliance with the License.
10+
# You may obtain a copy of the License at
11+
#
12+
# http://www.apache.org/licenses/LICENSE-2.0
13+
#
14+
# Unless required by applicable law or agreed to in writing, software
15+
# distributed under the License is distributed on an "AS IS" BASIS,
16+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17+
# implied. See the License for the specific language governing
18+
# permissions and limitations under the License.
19+
#
20+
21+
import unittest
22+
import time
23+
import threading
24+
25+
import OpTestConfiguration
26+
from common.OpTestSystem import OpSystemState
27+
from common.OpTestConstants import OpTestConstants as BMC_CONST
28+
29+
class OobIpmiThread(threading.Thread):
30+
def __init__(self, threadID, name, cmd, execution_time):
31+
threading.Thread.__init__(self)
32+
self.threadID = threadID
33+
self.name = name
34+
self.cmd = cmd
35+
self.execution_time = execution_time
36+
conf = OpTestConfiguration.conf
37+
self.cv_IPMI = conf.ipmi()
38+
39+
def run(self):
40+
print "Starting " + self.name
41+
self.oob_ipmi_thread(self.name, self.cmd, self.execution_time)
42+
print "Exiting " + self.name
43+
44+
def oob_ipmi_thread(self, threadName, cmd, t):
45+
execution_time = time.time() + 60*t
46+
print "Starting %s for oob-ipmi %s" % (threadName, cmd)
47+
while True:
48+
try:
49+
self.cv_IPMI.ipmitool.run(cmd, logcmd=False)
50+
except:
51+
pass
52+
if time.time() > execution_time:
53+
break
54+
time.sleep(2)
55+
56+
57+
class InbandIpmiThread(threading.Thread):
58+
def __init__(self, threadID, name, ipmi_method, cmd, execution_time):
59+
threading.Thread.__init__(self)
60+
self.threadID = threadID
61+
self.name = name
62+
self.ipmi_method = ipmi_method
63+
self.cmd = cmd
64+
self.execution_time = execution_time
65+
conf = OpTestConfiguration.conf
66+
self.host = conf.host()
67+
68+
def run(self):
69+
print "Starting " + self.name
70+
self.inband_ipmi_thread(self.name, self.cmd, self.execution_time)
71+
print "Exiting " + self.name
72+
73+
def inband_ipmi_thread(self, threadName, cmd, t):
74+
execution_time = time.time() + 60*t
75+
self.c = self.host.get_ssh_connection()
76+
print "Starting %s for inband-ipmi %s" % (threadName, cmd)
77+
while True:
78+
try:
79+
self.c.run_command(self.ipmi_method + cmd)
80+
except:
81+
pass
82+
if time.time() > execution_time:
83+
break
84+
time.sleep(2)
85+
86+
class SolConsoleThread(threading.Thread):
87+
def __init__(self, threadID, name, test, execution_time):
88+
threading.Thread.__init__(self)
89+
self.threadID = threadID
90+
self.name = name
91+
self.test = test
92+
self.execution_time = execution_time
93+
conf = OpTestConfiguration.conf
94+
self.cv_SYSTEM = conf.system()
95+
96+
def run(self):
97+
print "Starting " + self.name
98+
self.sol_console_thread(self.name, self.execution_time)
99+
print "Exiting " + self.name
100+
101+
def sol_console_thread(self, threadName, t):
102+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()
103+
# Enable kernel logging(printk) to console
104+
self.c.run_command("echo 10 > /proc/sys/kernel/printk")
105+
execution_time = time.time() + 60*self.execution_time
106+
i = 0
107+
while True:
108+
print "Iteration %s, SOL open/close" % i
109+
try:
110+
self.c.get_console()
111+
# Execute any host command(for console IO) if system is in runtime
112+
if "runtime" in self.test:
113+
try:
114+
self.c.run_command("ipmitool power status")
115+
# Enable console traffic by printing the processes/tasks to the console
116+
self.c.run_command("echo t > /proc/sysrq-trigger")
117+
except:
118+
pass
119+
self.c.close()
120+
except:
121+
pass
122+
time.sleep(3)
123+
i += 1
124+
if time.time() > execution_time:
125+
break
126+
127+
class IpmiInterfaceTorture(unittest.TestCase):
128+
def setUp(self):
129+
conf = OpTestConfiguration.conf
130+
self.cv_HOST = conf.host()
131+
self.cv_IPMI = conf.ipmi()
132+
self.cv_SYSTEM = conf.system()
133+
self.torture_time = 2400
134+
self.bmc_type = conf.args.bmc_type
135+
136+
def runTest(self):
137+
self.setup_test()
138+
self.thread_list = []
139+
# OOB IPMI Torture
140+
torture_time = self.torture_time
141+
cmd_list = ["sdr list", "fru print", "sel list", "sensor list","power status"]
142+
for j in range(1,3):
143+
for idx, cmd in enumerate(cmd_list):
144+
num = j*(idx + 1)
145+
thread = OobIpmiThread(num, "Thread-%s" % num, cmd, torture_time)
146+
thread.start()
147+
self.thread_list.append(thread)
148+
149+
if "skiroot" in self.test:
150+
return
151+
152+
if self.test == "standby":
153+
return
154+
155+
# In-band IPMI Torture (Open Interface)
156+
cmd_list = ["sdr list", "fru print", "sel list", "sensor list","power status"]
157+
for j in range(1,3):
158+
for idx, cmd in enumerate(cmd_list):
159+
num = j*(idx + 1)
160+
thread = InbandIpmiThread(num, "Thread-%s" % num, BMC_CONST.IPMITOOL_OPEN, cmd, torture_time)
161+
thread.start()
162+
self.thread_list.append(thread)
163+
164+
if "FSP" in self.bmc_type:
165+
return
166+
167+
# In-band IPMI Torture (USB Interface)
168+
cmd_list = ["sdr list", "fru print", "sel list", "sensor list","power status"]
169+
for idx, cmd in enumerate(cmd_list):
170+
thread = InbandIpmiThread(idx, "Thread-%s" % idx, BMC_CONST.IPMITOOL_USB, cmd, torture_time)
171+
thread.start()
172+
self.thread_list.append(thread)
173+
174+
def tearDown(self):
175+
# wait for all the threads to finish
176+
for thread in self.thread_list:
177+
thread.join()
178+
179+
class ConsoleIpmiTorture(unittest.TestCase):
180+
def setUp(self):
181+
conf = OpTestConfiguration.conf
182+
self.cv_HOST = conf.host()
183+
self.cv_IPMI = conf.ipmi()
184+
self.cv_SYSTEM = conf.system()
185+
self.torture_time = 2400
186+
187+
def ipmi_interface_torture(self):
188+
# OOB IPMI Torture
189+
torture_time = self.torture_time
190+
self.thread_list = []
191+
cmd_list = ["sdr list", "fru print", "sel list", "sensor list","power status"]
192+
for j in range(1,3):
193+
for idx, cmd in enumerate(cmd_list):
194+
num = j*(idx + 1)
195+
thread = OobIpmiThread(num, "Thread-%s" % num, cmd, torture_time)
196+
thread.start()
197+
self.thread_list.append(thread)
198+
199+
if self.test == "standby":
200+
return
201+
202+
if "skiroot" in self.test:
203+
return
204+
205+
return # Don't enable below inband ipmi torture, console and ssh sessions make the o/p clutter
206+
# In-band IPMI Torture
207+
cmd_list = ["sdr list", "fru print", "sel list", "sensor list","power status"]
208+
for j in range(1,3):
209+
for idx, cmd in enumerate(cmd_list):
210+
num = j*(idx + 1)
211+
thread = InbandIpmiThread(num, "Thread-%s" % num, BMC_CONST.IPMITOOL_OPEN, cmd, torture_time)
212+
thread.start()
213+
self.thread_list.append(thread)
214+
215+
def console_torture(self):
216+
thread = SolConsoleThread(1, "SOL-Thread", self.test, self.torture_time)
217+
thread.start()
218+
self.thread_list.append(thread)
219+
220+
def runTest(self):
221+
self.setup_test()
222+
self.ipmi_interface_torture()
223+
self.console_torture()
224+
225+
def tearDown(self):
226+
# Wait for all the thread to finish
227+
for thread in self.thread_list:
228+
thread.join()
229+
230+
class SkirootConsoleTorture(ConsoleIpmiTorture):
231+
def setup_test(self):
232+
self.test = "skiroot_runtime"
233+
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
234+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()
235+
self.cv_SYSTEM.host_console_unique_prompt()
236+
237+
238+
class SkirootIpmiTorture(IpmiInterfaceTorture):
239+
def setup_test(self):
240+
self.test = "skiroot_runtime"
241+
self.cv_SYSTEM.goto_state(OpSystemState.PETITBOOT_SHELL)
242+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()
243+
244+
class RuntimeConsoleTorture(ConsoleIpmiTorture):
245+
def setup_test(self):
246+
self.test = "runtime"
247+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
248+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()
249+
self.cv_SYSTEM.host_console_login()
250+
self.cv_SYSTEM.host_console_unique_prompt()
251+
252+
class StandbyConsoleTorture(ConsoleIpmiTorture):
253+
def setup_test(self):
254+
self.test = "standby"
255+
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
256+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()
257+
258+
class RuntimeIpmiInterfaceTorture(IpmiInterfaceTorture):
259+
def setup_test(self):
260+
self.test = "runtime"
261+
self.cv_SYSTEM.goto_state(OpSystemState.OS)
262+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()
263+
self.cv_SYSTEM.host_console_login()
264+
self.cv_SYSTEM.host_console_unique_prompt()
265+
266+
class StandbyIpmiInterfaceTorture(IpmiInterfaceTorture):
267+
def setup_test(self):
268+
self.test = "standby"
269+
self.cv_SYSTEM.goto_state(OpSystemState.OFF)
270+
self.c = self.cv_SYSTEM.sys_get_ipmi_console()

testcases/OpalErrorLog.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def runTest(self):
9898
self.cv_FSP.generate_error_log_from_fsp()
9999
self.cv_HOST.host_list_all_errorlogs()
100100
self.cv_HOST.host_list_all_service_action_logs()
101-
101+
self.cv_FSP.list_all_errorlogs_in_fsp()
102102
res = self.cv_HOST.host_get_number_of_errorlogs()
103103
transfer_complete = False
104104
tries = 60
@@ -120,3 +120,9 @@ class FullTest(BasicTest):
120120
def count(self):
121121
self.count = 255
122122
return self.count
123+
124+
class TortureTest(BasicTest):
125+
126+
def count(self):
127+
self.count = 100000
128+
return self.count

0 commit comments

Comments
 (0)