Skip to content

Commit 3e73029

Browse files
clarklee-guizhaosonic-otn
authored andcommitted
[sonic-pit] Add PIT(Platform Integration Test) feature, second part, … (sonic-net#12530)
* [sonic-pit] Add PIT(Platform Integration Test) feature, second part, add 6 test cases. Signed-off-by: Li Hua <[email protected]> * Add missing test case configuration and platform configuration. Signed-off-by: Li Hua <[email protected]> * Remove unsed comment, replace duplicated function with import from other moduls. --------- Signed-off-by: Li Hua <[email protected]>
1 parent af194fa commit 3e73029

File tree

14 files changed

+1022
-0
lines changed

14 files changed

+1022
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "cpu-test",
3+
"description": "Check CPU information",
4+
"type": "auto",
5+
"tags": ["manufacture", "delivery", "pa", "power", "emc"]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "memory-test",
3+
"description": "Check memory and pattern test",
4+
"type": "auto",
5+
"tags": ["manufacture", "delivery", "pa", "power", "emc"]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "oob-test",
3+
"description": "l2 mgmt switch test",
4+
"type": "auto",
5+
"tags": ["manufacture", "delivery", "pa"]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "rtc-test",
3+
"description": "Check RTC function",
4+
"type": "auto",
5+
"tags": ["manufacture", "delivery", "pa", "emc"]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "sensor-test",
3+
"description": "Check sensors health",
4+
"type": "auto",
5+
"tags": ["manufacture", "delivery", "pa", "power", "emc"]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "ssd-test",
3+
"description": "Check SSD capacity",
4+
"type": "auto",
5+
"tags": ["manufacture", "delivery", "pa", "emc", "power"]
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"fan_info":{
3+
"position": "bmc",
4+
"count": 6,
5+
"direction": "in",
6+
"ratio_target": [10, 80, 20],
7+
"speed_tolerance": 1000,
8+
"speed_max": 20000,
9+
"speed_min": 0,
10+
"motor_count": 2
11+
},
12+
"psu_info":{
13+
"position": "bmc",
14+
"count": 2,
15+
"in_power_min": 0,
16+
"in_power_max": 0,
17+
"in_vol_min": 0,
18+
"in_vol_max": 0,
19+
"in_curr_min": 0,
20+
"in_curr_max": 0,
21+
"out_power_min": 0,
22+
"out_power_max": 0,
23+
"out_vol_min": 0,
24+
"out_vol_max": 0,
25+
"out_curr_min": 0,
26+
"out_curr_max": 0
27+
},
28+
"cpu_info": {
29+
"Model name": "Intel(R) Xeon(R) CPU D-1533N @ 2.10GHz",
30+
"BogoMIPS": 4189.0,
31+
"CPU(s)": 6,
32+
"CPU MHz": 2100.0
33+
},
34+
"memory_free_size": 100,
35+
"rtc_info":{
36+
"delay_time": 5,
37+
"max_time_diff": 1
38+
},
39+
"ssd_test_size": "100M",
40+
"ssd_bom": [
41+
{
42+
"model": "AF2MA31DTDLT240A",
43+
"size": "240 GB"
44+
},
45+
{
46+
"model": "MTFDDAV240TDS",
47+
"size": "240 GB"
48+
}
49+
],
50+
"server_ip": "192.0.0.3",
51+
"bmc_ip": "240.1.1.1"
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"test_cases": [
3+
"fan_tc",
4+
"psu_tc",
5+
"cpu_tc",
6+
"memory_tc",
7+
"rtc_tc",
8+
"sensor_tc"
9+
]
10+
}
+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from function import run_command
2+
from test_case import TestCaseCommon
3+
from errcode import E
4+
import traceback
5+
6+
7+
# CPU test class
8+
class CPUTC(TestCaseCommon):
9+
def __init__(self, index, logger, platform_cfg_file, case_cfg_file=None):
10+
MODULE_NAME = "cpu_tc"
11+
TestCaseCommon.__init__(self, index, MODULE_NAME, logger, platform_cfg_file, case_cfg_file)
12+
self.cpu_info_dict = None
13+
try:
14+
if self.platform_cfg_json and 'cpu_info' in self.platform_cfg_json.keys():
15+
self.cpu_info_dict = self.platform_cfg_json['cpu_info']
16+
except Exception as e:
17+
self.logger.log_err(str(e), True)
18+
self.logger.log_err(traceback.format_exc())
19+
20+
def test_cpu_info(self, also_print_console=False):
21+
ret = E.OK
22+
self.logger.log_info("check_cpu_info start", also_print_console)
23+
24+
cmd = "lscpu | head -n25"
25+
status, log = run_command(cmd)
26+
if status != 0 or len(log) <= 0:
27+
reason = "Failed, get cpu info failed, command {}, status {}, log {}".format( \
28+
cmd, status, log)
29+
self.log_reason(reason)
30+
ret = E.ECPU3005
31+
else:
32+
lines = log.splitlines()
33+
expected_cpu_model = self.cpu_info_dict.get('Model name')
34+
expected_bogomips = self.cpu_info_dict.get('BogoMIPS')
35+
expected_cpu_num = self.cpu_info_dict.get('CPU(s)')
36+
expected_cpu_mhz = self.cpu_info_dict.get('CPU MHz')
37+
self.logger.log_dbg("Expected value: {}, {}, {}, {}".format(expected_cpu_model, \
38+
expected_bogomips, expected_cpu_num, expected_cpu_mhz))
39+
for line in lines:
40+
cols = line.strip().split(":")
41+
if len(cols) < 2:
42+
continue
43+
44+
if expected_cpu_model and cols[0] == "Model name":
45+
if cols[1].strip() != expected_cpu_model:
46+
reason = "Failed, CPU model name {}(expected {})".format( \
47+
cols[1].strip(), expected_cpu_model)
48+
self.log_reason(reason)
49+
ret = E.ECPU3001
50+
else:
51+
msg = "Model name {} =======> OK".format(cols[1].strip())
52+
self.logger.log_info(msg)
53+
54+
if expected_bogomips and cols[0] == 'BogoMIPS':
55+
read_bogomips = float(cols[1].strip())
56+
conf_bogomips = float(expected_bogomips)
57+
if read_bogomips <= (conf_bogomips * 0.99) or \
58+
read_bogomips >= conf_bogomips * 1.01:
59+
reason = "Failed, BogoMIPS {}(expected {})".format( \
60+
read_bogomips, expected_bogomips)
61+
self.log_reason(reason)
62+
ret = E.ECPU3001
63+
else:
64+
msg = "BogoMIPS {} ===== OK".format(read_bogomips)
65+
self.logger.log_info(msg)
66+
67+
if expected_cpu_num and cols[0] == 'CPU(s)':
68+
num_cpus = int(cols[1].strip())
69+
if num_cpus != self.cpu_info_dict.get('CPU(s)'):
70+
reason = "Failed, CPU number {}(expected {})".format( \
71+
num_cpus, expected_cpu_num)
72+
self.fail_reason.append(reason)
73+
ret = E.ECPU3001
74+
else:
75+
msg = "Number of CPUs {} ===== OK".format(num_cpus)
76+
self.logger.log_info(msg)
77+
78+
if expected_cpu_mhz and cols[0] == 'CPU MHz':
79+
read_cpu_mhz = float(cols[1].strip())
80+
conf_cpu_mhz = float(expected_cpu_mhz)
81+
if read_cpu_mhz <= (conf_cpu_mhz * 0.99) or \
82+
read_cpu_mhz >= (conf_cpu_mhz * 1.01):
83+
reason = "Failed, CPU MHz {}(expected {})".format( \
84+
read_cpu_mhz, expected_cpu_mhz)
85+
self.log_reason(reason)
86+
ret = E.ECPU3001
87+
else:
88+
msg = "CPU frequency {} ===== OK".format(read_cpu_mhz)
89+
self.logger.log_info(msg)
90+
91+
if ret != E.OK:
92+
self.logger.log_err("test cpu info done, FAILED.", also_print_console)
93+
else:
94+
self.logger.log_info("test cpu info done, PASS.", also_print_console)
95+
96+
return ret
97+
98+
def run_test(self, *argv):
99+
try:
100+
ret = self.test_cpu_info(True)
101+
return ret
102+
except Exception as e:
103+
self.logger.log_err("test cpu info got exception: {}".format(str(e)))
104+
self.logger.log_err(traceback.format_exc())
105+
return ret
106+
107+
return E.OK

0 commit comments

Comments
 (0)