提交 0ff5b371 编写于 作者: O openharmony_ci 提交者: Gitee

!10 解决xts同子系统多用例概率并发失败问题

Merge pull request !10 from alex_hold/master
...@@ -266,7 +266,9 @@ class CppTestDriver(IDriver): ...@@ -266,7 +266,9 @@ class CppTestDriver(IDriver):
command=collect_test_command, command=collect_test_command,
case_type=DeviceTestType.cpp_test_lite, case_type=DeviceTestType.cpp_test_lite,
timeout=15, receiver=None) timeout=15, receiver=None)
if "not mount properly, Test Stop" in result:
tests = []
return tests
tests = self.read_nfs_xml(request, self.config.device_xml_path) tests = self.read_nfs_xml(request, self.config.device_xml_path)
self.delete_device_xml(request, self.config.device_xml_path) self.delete_device_xml(request, self.config.device_xml_path)
return tests return tests
...@@ -850,6 +852,7 @@ class BuildOnlyTestDriver(IDriver): ...@@ -850,6 +852,7 @@ class BuildOnlyTestDriver(IDriver):
self.config.device = request.config.environment.devices[0] self.config.device = request.config.environment.devices[0]
self.file_name = request.root.source.test_name self.file_name = request.root.source.test_name
self.config_file = request.root.source.config_file self.config_file = request.root.source.config_file
self.testcases_path = request.config.testcases_path
file_path = self._get_log_file() file_path = self._get_log_file()
result_list = self._get_result_list(file_path) result_list = self._get_result_list(file_path)
if len(result_list) == 0: if len(result_list) == 0:
...@@ -880,7 +883,7 @@ class BuildOnlyTestDriver(IDriver): ...@@ -880,7 +883,7 @@ class BuildOnlyTestDriver(IDriver):
@classmethod @classmethod
def _get_result_list(cls, file_path): def _get_result_list(cls, file_path):
result_list = list() result_list = list()
for root_path, _, file_names in os.walk(file_path): for root_path, dirs_path, file_names in os.walk(file_path):
for file_name in file_names: for file_name in file_names:
if file_name == "logfile": if file_name == "logfile":
result_list.append(os.path.join(root_path, file_name)) result_list.append(os.path.join(root_path, file_name))
...@@ -890,7 +893,12 @@ class BuildOnlyTestDriver(IDriver): ...@@ -890,7 +893,12 @@ class BuildOnlyTestDriver(IDriver):
json_config = JsonParser(self.config_file) json_config = JsonParser(self.config_file)
log_path = get_config_value('log_path', json_config.get_driver(), log_path = get_config_value('log_path', json_config.get_driver(),
False) False)
file_path = get_file_absolute_path(log_path) log_path = str(log_path.replace("/", "", 1)) if log_path.startswith(
"/") else str(log_path)
LOG.debug("The log path is:%s" % log_path)
file_path = get_file_absolute_path(log_path,
paths=[self.testcases_path])
LOG.debug("The file path is:%s" % file_path)
return file_path return file_path
def __result__(self): def __result__(self):
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
import json import json
import time import time
import re import re
...@@ -26,7 +25,6 @@ from _core.exception import LiteDeviceTimeout ...@@ -26,7 +25,6 @@ from _core.exception import LiteDeviceTimeout
from _core.exception import LiteDeviceConnectError from _core.exception import LiteDeviceConnectError
from _core.exception import LiteDeviceExecuteCommandError from _core.exception import LiteDeviceExecuteCommandError
from _core.logger import platform_logger from _core.logger import platform_logger
from _core.utils import convert_port
__all__ = ["generate_report", "LiteHelper"] __all__ = ["generate_report", "LiteHelper"]
...@@ -37,6 +35,8 @@ CPP_ERR_MESSAGE = "[ERR]No such file or directory: " ...@@ -37,6 +35,8 @@ CPP_ERR_MESSAGE = "[ERR]No such file or directory: "
CTEST_STANDARD_SIGN = "Start to run test suite" CTEST_STANDARD_SIGN = "Start to run test suite"
AT_CMD_ENDS = "OK" AT_CMD_ENDS = "OK"
CTEST_END_SIGN = "All the test suites finished" CTEST_END_SIGN = "All the test suites finished"
CPP_TEST_STOP_SIGN = "Test Stop"
CPP_TEST_MOUNT_SIGN = "not mount properly"
_START_JSUNIT_RUN_MARKER = "[start] start run suites" _START_JSUNIT_RUN_MARKER = "[start] start run suites"
_END_JSUNIT_RUN_MARKER = "[end] run suites end" _END_JSUNIT_RUN_MARKER = "[end] run suites end"
...@@ -76,7 +76,10 @@ def check_read_test_end(result=None, input_command=None): ...@@ -76,7 +76,10 @@ def check_read_test_end(result=None, input_command=None):
if result_output.find(INSTALL_END_MARKER) != -1: if result_output.find(INSTALL_END_MARKER) != -1:
return True return True
if (result_output.find(CPP_TEST_MOUNT_SIGN) != -1
and result_output.find(CPP_TEST_STOP_SIGN) != -1):
LOG.info("find test stop")
return True
if "%s%s" % (CPP_ERR_MESSAGE, input_command[2:]) in result_output: if "%s%s" % (CPP_ERR_MESSAGE, input_command[2:]) in result_output:
LOG.error("execute file not exist, result is %s" % result_output, LOG.error("execute file not exist, result is %s" % result_output,
error_no="00402") error_no="00402")
...@@ -143,7 +146,8 @@ class LiteHelper: ...@@ -143,7 +146,8 @@ class LiteHelper:
expect_result = [bytes(CPP_TEST_STANDARD_SIGN, encoding="utf8"), expect_result = [bytes(CPP_TEST_STANDARD_SIGN, encoding="utf8"),
bytes(CPP_SYS_STANDARD_SIGN, encoding="utf8"), bytes(CPP_SYS_STANDARD_SIGN, encoding="utf8"),
bytes(CPP_TEST_END_SIGN, encoding="utf8")] bytes(CPP_TEST_END_SIGN, encoding="utf8"),
bytes(CPP_TEST_STOP_SIGN, encoding="utf8")]
while time.time() - start_time < timeout: while time.time() - start_time < timeout:
if not Scheduler.is_execute: if not Scheduler.is_execute:
raise ExecuteTerminate("Execute terminate", error_no="00300") raise ExecuteTerminate("Execute terminate", error_no="00300")
...@@ -274,7 +278,7 @@ class LiteHelper: ...@@ -274,7 +278,7 @@ class LiteHelper:
error_no="00402") error_no="00402")
LOG.info("local_%s execute command shell %s with timeout %ss" % LOG.info("local_%s execute command shell %s with timeout %ss" %
(convert_port(com.port), command, str(timeout))) (com.port, command, str(timeout)))
if isinstance(command, str): if isinstance(command, str):
command = command.encode("utf-8") command = command.encode("utf-8")
...@@ -297,8 +301,7 @@ class LiteHelper: ...@@ -297,8 +301,7 @@ class LiteHelper:
error_no="00402") error_no="00402")
LOG.info( LOG.info(
"local_%s execute command shell %s" % (convert_port(com.port), "local_%s execute command shell %s" % (com.port, command))
command))
command = command.encode("utf-8") command = command.encode("utf-8")
if command[-2:] != b"\r\n": if command[-2:] != b"\r\n":
command = command.rstrip() + b'\r\n' command = command.rstrip() + b'\r\n'
......
...@@ -24,6 +24,7 @@ import subprocess ...@@ -24,6 +24,7 @@ import subprocess
import shutil import shutil
import platform import platform
import glob import glob
import time
from _core.logger import platform_logger from _core.logger import platform_logger
from _core.plugin import Plugin from _core.plugin import Plugin
...@@ -234,10 +235,20 @@ class MountKit(ITestKit): ...@@ -234,10 +235,20 @@ class MountKit(ITestKit):
replace("nfs_directory", linux_directory).replace( replace("nfs_directory", linux_directory).replace(
"device_directory", target).replace("//", "/") "device_directory", target).replace("//", "/")
timeout = 15 if command.startswith("mount") else 1 timeout = 15 if command.startswith("mount") else 1
result, status, _ = device.execute_command_with_timeout(
command=command, case_type=case_type, timeout=timeout)
if command.startswith("mount"): if command.startswith("mount"):
self.mounted_dir.add(target) self.mounted_dir.add(target)
for mount_time in range(1, 4):
result, status, _ = device.\
execute_command_with_timeout(command=command,
case_type=case_type,
timeout=timeout)
if status:
break
LOG.info("mount failed,try "
"again {} time".format(mount_time))
else:
result, status, _ = device.execute_command_with_timeout(
command=command, case_type=case_type, timeout=timeout)
LOG.info('prepare environment success') LOG.info('prepare environment success')
def __setup__(self, device, **kwargs): def __setup__(self, device, **kwargs):
...@@ -303,6 +314,12 @@ class MountKit(ITestKit): ...@@ -303,6 +314,12 @@ class MountKit(ITestKit):
if (str(get_local_ip()) == linux_host) and ( if (str(get_local_ip()) == linux_host) and (
linux_directory == ("/data%s" % testcases_dir)): linux_directory == ("/data%s" % testcases_dir)):
return return
ip = remote_info.get("ip", "")
port = remote_info.get("port", "")
remote_dir = remote_info.get("dir", "")
if not ip or not port or not remote_dir:
LOG.warning("nfs server's ip or port or dir is empty")
return
for _file in file_local_paths: for _file in file_local_paths:
# remote copy # remote copy
LOG.info("Trying to copy the file from {} to nfs server". LOG.info("Trying to copy the file from {} to nfs server".
...@@ -310,8 +327,7 @@ class MountKit(ITestKit): ...@@ -310,8 +327,7 @@ class MountKit(ITestKit):
if not is_remote.lower() == "false": if not is_remote.lower() == "false":
try: try:
import paramiko import paramiko
client = paramiko.Transport((remote_info.get("ip"), client = paramiko.Transport(ip, int(port))
int(remote_info.get("port"))))
client.connect(username=remote_info.get("username"), client.connect(username=remote_info.get("username"),
password=remote_info.get("password")) password=remote_info.get("password"))
sftp = paramiko.SFTPClient.from_transport(client) sftp = paramiko.SFTPClient.from_transport(client)
...@@ -362,12 +378,19 @@ class MountKit(ITestKit): ...@@ -362,12 +378,19 @@ class MountKit(ITestKit):
else: else:
device.execute_command_with_timeout(command="cd /", timeout=1) device.execute_command_with_timeout(command="cd /", timeout=1)
for mounted_dir in self.mounted_dir: for mounted_dir in self.mounted_dir:
device.execute_command_with_timeout(command="umount {}". for mount_time in range(1, 3):
format(mounted_dir), result, status, _ = device.execute_command_with_timeout(
timeout=2) command="umount {}".format(mounted_dir),
device.execute_command_with_timeout(command="rm -r {}". timeout=2)
format(mounted_dir), if status:
timeout=1) break
LOG.info("umount failed,try "
"again {} time".format(mount_time))
time.sleep(1)
if result.find("Resource busy") == -1:
device.execute_command_with_timeout(command="rm -r {}".
format(mounted_dir)
, timeout=1)
def copy_file_as_temp(original_file, str_length): def copy_file_as_temp(original_file, str_length):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册