oec-hardware/oec-hardware-1.1.3-fix-network-cdrom-bug-update-log-print.patch
cuixucui e11076b15e Fix bugs and optimize code
(cherry picked from commit 5624dbeb297746cebef6a0b78c9c3e84d9bd5aa6)
2022-11-09 18:19:04 +08:00

304 lines
14 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff -Naur rpm/config/test_config.yaml oech/config/test_config.yaml
--- rpm/config/test_config.yaml 2022-10-24 08:36:33.000000000 +0800
+++ oech/config/test_config.yaml 2022-11-09 17:12:48.008572012 +0800
@@ -3,6 +3,7 @@
#disk: fc\raid\disk testcase need configuration, The disk to be tested, such as sda; Or all, test all qualified disks.
#if_rdma: ethernet testcase need configuration, N means to test according to ordinary network card, y means to test according to RDMA card
#server_ip: ethernet\infiniband testcase need configuration. If the server port is modified, need to add the port number after the IP address. eg: 2.2.2.4:8090.
+# User need to delete the ip manually which are configured by tool after testing.
#clent_ip: ethernet\infiniband testcase need configuration. IP to be configured for the client port
fc:
fc1:
diff -Naur rpm/docs/design_docs/dev_design.md oech/docs/design_docs/dev_design.md
--- rpm/docs/design_docs/dev_design.md 2022-10-24 08:36:33.000000000 +0800
+++ oech/docs/design_docs/dev_design.md 2022-11-09 17:12:48.009572012 +0800
@@ -262,6 +262,7 @@
# client_ip为客户端测试网卡配置的IP
# server_ip为服务端测试网卡配置的IP
# 服务端的端口默认是80如果有修改需要添加上修改后的端口号如下面的eth2示例。
+# 服务端自动配置的IP测试完成后需用户手动删除(ip addr del ip地址 dev 接口)。
ethernet:
# 已手动配置客户端和服务端测试网卡的IP这里需要添加上服务端的IP地址。
eth1:
diff -Naur rpm/hwcompatible/cert_info.py oech/hwcompatible/cert_info.py
--- rpm/hwcompatible/cert_info.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/hwcompatible/cert_info.py 2022-11-09 17:12:48.010572012 +0800
@@ -71,13 +71,13 @@
oec_json["os"] = os_version
curday = date.today().strftime("%Y.%m.%d")
oec_json["date"] = curday
- shanum = self.command.run_cmd(
- "modinfo %s | grep signature | awk '{print $2}'" % device.driver, log_print=False)
- oec_json["sha256"] = shanum[0].replace(":", "").strip("\n")
filename = self.command.run_cmd(
"modinfo %s | grep filename | awk '{print $2}'" % device.driver, log_print=False)
+ shanum = self.command.run_cmd(
+ "sha256sum %s | awk '{print $1}'" % filename[0].strip("\n"), log_print=False)
+ oec_json["sha256"] = shanum[0].strip("\n")
driver_size = self.command.run_cmd(
- "ls -lh %s | awk '{print $5}'" % filename[0], log_print=False)
+ "ls -lh %s | awk '{print $5}'" % filename[0].strip("\n"), log_print=False)
oec_json["driverSize"] = driver_size[0].strip("\n")
oec_json["downloadLink"] = "inbox"
diff -Naur rpm/hwcompatible/command.py oech/hwcompatible/command.py
--- rpm/hwcompatible/command.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/hwcompatible/command.py 2022-11-09 17:12:48.010572012 +0800
@@ -13,9 +13,9 @@
# Create: 2020-04-01
import os
-from signal import signal
-import subprocess
import shlex
+import signal
+import subprocess
from .constants import SHELL_ENV
diff -Naur rpm/hwcompatible/config_ip.py oech/hwcompatible/config_ip.py
--- rpm/hwcompatible/config_ip.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/hwcompatible/config_ip.py 2022-11-09 17:12:48.010572012 +0800
@@ -158,7 +158,8 @@
Configure the IP address of the server.
"""
result = CommandUI().prompt_confirm(
- "Are you sure to configure %s on server port?" % self.server_ip)
+ "Are you sure to configure %s on server port?\n"
+ "After the test, need to manually delete this ip." % self.server_ip)
if not result:
self.logger.warning(
"User won't use the generate IP address, stop the test.")
diff -Naur rpm/README.md oech/README.md
--- rpm/README.md 2022-10-24 08:36:33.000000000 +0800
+++ oech/README.md 2022-11-09 17:12:48.002572012 +0800
@@ -200,9 +200,9 @@
* `/usr/share/oech/kernelrelease.json` 文件中列出了当前支持的所有系统版本,使用`uname -a` 命令确认当前系统内核版本是否属于框架支持的版本。
-* 框架默认会扫描所有网卡,对网卡进行测试前,请自行筛选被测网卡,并给它配上能 `ping` 通服务端的 ip如果客户端是对 InfiniBand 网卡进行测试,服务端也必须有一个 InfiniBand 网卡并提前配好 ip 。建议不要使用业务网口进行网卡测试。
+* 框架默认会扫描所有网卡对网卡进行测试前请自行筛选被测网卡要求测试端口连通状态为up。建议不要使用业务网口进行网卡测试。
-* `/usr/share/oech/lib/config/test_config.yaml ` 是硬件测试项配置文件模板,`fc`、`raid`、`disk`、`ethernet`、`infiniband`硬件测试前需先根据实际环境进行修改,其它硬件测试不需要修改。
+* `/usr/share/oech/lib/config/test_config.yaml ` 是硬件测试项配置文件模板,`fc`、`raid`、`disk`、`ethernet`、`infiniband`硬件测试前需先根据实际环境进行配置其它硬件测试不需要配置。对于网卡测试如果是工具自动添加的IP地址测试完成后为了安全服务端的IP需手动删除。
## 使用步骤
diff -Naur rpm/server/server.py oech/server/server.py
--- rpm/server/server.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/server/server.py 2022-11-09 17:12:48.011572012 +0800
@@ -21,7 +21,6 @@
import base64
import re
import operator
-import stat
from urllib.parse import urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError
@@ -33,7 +32,6 @@
dir_server = os.path.dirname(os.path.realpath(__file__))
dir_results = os.path.join(dir_server, 'results')
dir_files = os.path.join(dir_server, 'files')
-ip_file = os.path.join(dir_server, "ip.txt")
@app.errorhandler(400)
@@ -353,8 +351,6 @@
if operator.eq(quad, eval(card_id)):
subprocess.getoutput(
"ifconfig %s:0 %s/24" % (pt, sever_ip))
- with os.fdopen(os.open(ip_file, os.O_WRONLY | os.O_CREAT, stat.S_IRUSR), 'w+') as f:
- f.write('{},{}'.format(pt, sever_ip))
break
return render_template('index.html')
@@ -391,7 +387,6 @@
if cmd[0] == 'all':
for process_name in valid_commands:
__stop_process(process_name)
- __delete_ip()
else:
__stop_process(cmd[0])
else:
@@ -459,19 +454,5 @@
quad.extend([tmp[-3] + tmp[-4], tmp[-1] + tmp[-2]])
return quad
-
-def __delete_ip():
- """
- Delete the IP configured on the server
- """
- if not os.path.exists(ip_file):
- return
-
- with open(ip_file, 'r') as f:
- ip = f.read().split(',')
- subprocess.Popen(['ip', 'addr', 'del', ip[1], "dev", ip[0]])
- os.remove(ip_file)
-
-
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80)
diff -Naur rpm/tests/cdrom/cdrom.py oech/tests/cdrom/cdrom.py
--- rpm/tests/cdrom/cdrom.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/tests/cdrom/cdrom.py 2022-11-09 17:12:48.013572012 +0800
@@ -32,6 +32,9 @@
self.type = None
self.com_ui = CommandUI()
self.test_dir = "/usr/share/doc"
+ read_dir = os.getcwd()
+ self.mnt_dir = os.path.join(read_dir, "mnt_cdrom")
+ self.device_dir = os.path.join(read_dir, "device_dir")
def setup(self, args=None):
"""
@@ -191,29 +194,32 @@
:return:
"""
devname = self.device.get_property("DEVNAME")
- os.mkdir("mnt_cdrom")
-
+ if os.path.exists(self.mnt_dir):
+ shutil.rmtree(self.mnt_dir)
+ os.mkdir(self.mnt_dir)
self.logger.info("Check to mount media.", terminal_print=True)
self.command.run_cmd("umount %s" % devname, ignore_errors=True)
- self.command.run_cmd("mount -o ro %s ./mnt_cdrom" % devname)
+ self.command.run_cmd("mount -o ro %s %s" % (devname, self.mnt_dir))
cmd_result = self.command.run_cmd(
"df %s | tail -n1 | awk '{print $3}'" % devname)
size = int(cmd_result[0])
if size == 0:
self.logger.error("This is a blank disc.")
- self.command.run_cmd("umount ./mnt_cdrom")
- shutil.rmtree("mnt_cdrom")
+ self.command.run_cmd("umount %s" % self.mnt_dir)
+ shutil.rmtree(self.mnt_dir)
return False
- os.mkdir("device_dir")
- self.logger.info("Check to copy files.", ignore_errors=True)
- self.command.run_cmd("cp -dpRf ./mnt_cdrom ./device_dir")
+ if os.path.exists(self.device_dir):
+ shutil.rmtree(self.device_dir)
+ os.mkdir(self.device_dir)
+ self.logger.info("Check to copy files.", terminal_print=True)
+ self.command.run_cmd("cp -dprf %s/. %s" % (self.mnt_dir, self.device_dir))
self.logger.info(
- "Check to compare files in directory.", ignore_errors=True)
- return_code = self.cmp_tree("mnt_cdrom", "device_dir")
- self.command.run_cmd("umount ./mnt_cdrom")
+ "Check to compare files in directory.", terminal_print=True)
+ return_code = self.cmp_tree(self.mnt_dir, self.device_dir)
+ self.command.run_cmd("umount %s" % self.mnt_dir)
if return_code:
self.logger.info("Compare directory succeed.")
else:
@@ -259,7 +265,7 @@
return True
def teardown(self):
- if os.path.exists("mnt_cdrom"):
- shutil.rmtree("mnt_cdrom")
- if os.path.exists("device_dir"):
- shutil.rmtree("device_dir")
+ if os.path.exists(self.mnt_dir):
+ shutil.rmtree(self.mnt_dir)
+ if os.path.exists(self.device_dir):
+ shutil.rmtree(self.device_dir)
diff -Naur rpm/tests/infiniband/infiniband.py oech/tests/infiniband/infiniband.py
--- rpm/tests/infiniband/infiniband.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/tests/infiniband/infiniband.py 2022-11-09 17:12:48.014572012 +0800
@@ -13,7 +13,6 @@
# Create: 2022-05-24
# Desc: InfiniBand Test
-import re
from tests.network.rdma import RDMATest
diff -Naur rpm/tests/network/ethernet.py oech/tests/network/ethernet.py
--- rpm/tests/network/ethernet.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/tests/network/ethernet.py 2022-11-09 17:12:48.023572011 +0800
@@ -27,8 +27,13 @@
"""
path_netdev = ''.join(['/sys', self.device.get_property("DEVPATH")])
path_pci = path_netdev.split('net')[0]
- result = self.command.run_cmd("ls %s | grep -q infiniband" % path_pci)
- return result[2] == 0
+ result = self.command.run_cmd("ls %s | grep -q infiniband" % path_pci, ignore_errors=False)
+ if result[2] == 0:
+ self.logger.info("Current ethernet supports RoCE.")
+ return True
+
+ self.logger.info("Current ethernet doesn't support RoCE, no need test Roce.")
+ return False
def setup(self, args=None):
"""
diff -Naur rpm/tests/network/network.py oech/tests/network/network.py
--- rpm/tests/network/network.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/tests/network/network.py 2022-11-09 17:12:48.023572011 +0800
@@ -138,10 +138,13 @@
self.command.run_cmd("ip link set down %s" % interface)
for _ in range(5):
result = self.command.run_cmd(
- "ip link show %s | grep 'state DOWN'" % interface)
+ "ip link show %s | grep 'state DOWN'" % interface, ignore_errors=False)
if result[2] == 0:
+ self.logger.info("Set interface %s down succeed." % self.interface)
return True
time.sleep(1)
+
+ self.logger.error("Set interface %s down failed." % self.interface)
return False
def ifup(self, interface):
@@ -153,11 +156,13 @@
self.command.run_cmd("ip link set up %s" % interface)
for _ in range(5):
result = self.command.run_cmd(
- "ip link show %s | grep 'state UP'" % interface)
+ "ip link show %s | grep 'state UP'" % interface, ignore_errors=False)
if result[2] == 0:
+ self.logger.info("Set interface %s up succeed." % self.interface)
return True
time.sleep(1)
+ self.logger.error("Set interface %s up failed." % self.interface)
return False
def get_speed(self):
@@ -419,14 +424,12 @@
Test eth link
:return:
"""
- self.logger.info("Setting interface %s down..." % self.interface)
+ self.logger.info("Setting interface %s down." % self.interface)
if not self.ifdown(self.interface):
- self.logger.error("Set interface %s down failed." % self.interface)
return False
- self.logger.info("Setting interface %s up..." % self.interface)
+ self.logger.info("Setting interface %s up." % self.interface)
if not self.ifup(self.interface):
- self.logger.error("Set interface %s up failed." % self.interface)
return False
self.speed = self.get_speed()
diff -Naur rpm/tests/system/system.py oech/tests/system/system.py
--- rpm/tests/system/system.py 2022-10-24 08:36:33.000000000 +0800
+++ oech/tests/system/system.py 2022-11-09 17:12:48.024572011 +0800
@@ -57,7 +57,7 @@
flag = True
for cert_package in ["oec-hardware"]:
rpm_verify = self.command.run_cmd(
- "rpm -V --nomtime --nomode --nocontexts %s" % cert_package)
+ "rpm -V --nomtime --nomode --nocontexts %s" % cert_package, ignore_errors=True)
if rpm_verify[2] == 0:
continue