Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sonic-pit] Add PIT(Platform Integration Test) feature, second part, … #12530

Merged
merged 3 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/sonic-pit/pit-sysdiag/cases/cpu_tc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "cpu-test",
"description": "Check CPU information",
"type": "auto",
"tags": ["manufacture", "delivery", "pa", "power", "emc"]
}
6 changes: 6 additions & 0 deletions src/sonic-pit/pit-sysdiag/cases/memory_tc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "memory-test",
"description": "Check memory and pattern test",
"type": "auto",
"tags": ["manufacture", "delivery", "pa", "power", "emc"]
}
6 changes: 6 additions & 0 deletions src/sonic-pit/pit-sysdiag/cases/oob_tc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "oob-test",
"description": "l2 mgmt switch test",
"type": "auto",
"tags": ["manufacture", "delivery", "pa"]
}
6 changes: 6 additions & 0 deletions src/sonic-pit/pit-sysdiag/cases/rtc_tc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "rtc-test",
"description": "Check RTC function",
"type": "auto",
"tags": ["manufacture", "delivery", "pa", "emc"]
}
6 changes: 6 additions & 0 deletions src/sonic-pit/pit-sysdiag/cases/sensor_tc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "sensor-test",
"description": "Check sensors health",
"type": "auto",
"tags": ["manufacture", "delivery", "pa", "power", "emc"]
}
6 changes: 6 additions & 0 deletions src/sonic-pit/pit-sysdiag/cases/ssd_tc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "ssd-test",
"description": "Check SSD capacity",
"type": "auto",
"tags": ["manufacture", "delivery", "pa", "emc", "power"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"fan_info":{
"position": "bmc",
"count": 6,
"direction": "in",
"ratio_target": [10, 80, 20],
"speed_tolerance": 1000,
"speed_max": 20000,
"speed_min": 0,
"motor_count": 2
},
"psu_info":{
"position": "bmc",
"count": 2,
"in_power_min": 0,
"in_power_max": 0,
"in_vol_min": 0,
"in_vol_max": 0,
"in_curr_min": 0,
"in_curr_max": 0,
"out_power_min": 0,
"out_power_max": 0,
"out_vol_min": 0,
"out_vol_max": 0,
"out_curr_min": 0,
"out_curr_max": 0
},
"cpu_info": {
"Model name": "Intel(R) Xeon(R) CPU D-1533N @ 2.10GHz",
"BogoMIPS": 4189.0,
"CPU(s)": 6,
"CPU MHz": 2100.0
},
"memory_free_size": 100,
"rtc_info":{
"delay_time": 5,
"max_time_diff": 1
},
"ssd_test_size": "100M",
"ssd_bom": [
{
"model": "AF2MA31DTDLT240A",
"size": "240 GB"
},
{
"model": "MTFDDAV240TDS",
"size": "240 GB"
}
],
"server_ip": "192.0.0.3",
"bmc_ip": "240.1.1.1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"test_cases": [
"fan_tc",
"psu_tc",
"cpu_tc",
"memory_tc",
"rtc_tc",
"sensor_tc"
]
}
107 changes: 107 additions & 0 deletions src/sonic-pit/pit-sysdiag/src/cpu_tc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
from function import run_command
from test_case import TestCaseCommon
from errcode import E
import traceback


# CPU test class
class CPUTC(TestCaseCommon):
def __init__(self, index, logger, platform_cfg_file, case_cfg_file=None):
MODULE_NAME = "cpu_tc"
TestCaseCommon.__init__(self, index, MODULE_NAME, logger, platform_cfg_file, case_cfg_file)
self.cpu_info_dict = None
try:
if self.platform_cfg_json and 'cpu_info' in self.platform_cfg_json.keys():
self.cpu_info_dict = self.platform_cfg_json['cpu_info']
except Exception as e:
self.logger.log_err(str(e), True)
self.logger.log_err(traceback.format_exc())

def test_cpu_info(self, also_print_console=False):
ret = E.OK
self.logger.log_info("check_cpu_info start", also_print_console)

cmd = "lscpu | head -n25"
status, log = run_command(cmd)
if status != 0 or len(log) <= 0:
reason = "Failed, get cpu info failed, command {}, status {}, log {}".format( \
cmd, status, log)
self.log_reason(reason)
ret = E.ECPU3005
else:
lines = log.splitlines()
expected_cpu_model = self.cpu_info_dict.get('Model name')
expected_bogomips = self.cpu_info_dict.get('BogoMIPS')
expected_cpu_num = self.cpu_info_dict.get('CPU(s)')
expected_cpu_mhz = self.cpu_info_dict.get('CPU MHz')
self.logger.log_dbg("Expected value: {}, {}, {}, {}".format(expected_cpu_model, \
expected_bogomips, expected_cpu_num, expected_cpu_mhz))
for line in lines:
cols = line.strip().split(":")
if len(cols) < 2:
continue

if expected_cpu_model and cols[0] == "Model name":
if cols[1].strip() != expected_cpu_model:
reason = "Failed, CPU model name {}(expected {})".format( \
cols[1].strip(), expected_cpu_model)
self.log_reason(reason)
ret = E.ECPU3001
else:
msg = "Model name {} =======> OK".format(cols[1].strip())
self.logger.log_info(msg)

if expected_bogomips and cols[0] == 'BogoMIPS':
read_bogomips = float(cols[1].strip())
conf_bogomips = float(expected_bogomips)
if read_bogomips <= (conf_bogomips * 0.99) or \
read_bogomips >= conf_bogomips * 1.01:
reason = "Failed, BogoMIPS {}(expected {})".format( \
read_bogomips, expected_bogomips)
self.log_reason(reason)
ret = E.ECPU3001
else:
msg = "BogoMIPS {} ===== OK".format(read_bogomips)
self.logger.log_info(msg)

if expected_cpu_num and cols[0] == 'CPU(s)':
num_cpus = int(cols[1].strip())
if num_cpus != self.cpu_info_dict.get('CPU(s)'):
reason = "Failed, CPU number {}(expected {})".format( \
num_cpus, expected_cpu_num)
self.fail_reason.append(reason)
ret = E.ECPU3001
else:
msg = "Number of CPUs {} ===== OK".format(num_cpus)
self.logger.log_info(msg)

if expected_cpu_mhz and cols[0] == 'CPU MHz':
read_cpu_mhz = float(cols[1].strip())
conf_cpu_mhz = float(expected_cpu_mhz)
if read_cpu_mhz <= (conf_cpu_mhz * 0.99) or \
read_cpu_mhz >= (conf_cpu_mhz * 1.01):
reason = "Failed, CPU MHz {}(expected {})".format( \
read_cpu_mhz, expected_cpu_mhz)
self.log_reason(reason)
ret = E.ECPU3001
else:
msg = "CPU frequency {} ===== OK".format(read_cpu_mhz)
self.logger.log_info(msg)

if ret != E.OK:
self.logger.log_err("test cpu info done, FAILED.", also_print_console)
else:
self.logger.log_info("test cpu info done, PASS.", also_print_console)

return ret

def run_test(self, *argv):
try:
ret = self.test_cpu_info(True)
return ret
except Exception as e:
self.logger.log_err("test cpu info got exception: {}".format(str(e)))
self.logger.log_err(traceback.format_exc())
return ret

return E.OK
Loading