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

This commit is contained in:
alex_hold 2021-04-02 18:01:27 +08:00 committed by Gitee
parent 1ec9693ca1
commit 7051dc1360
3 changed files with 53 additions and 20 deletions

View File

@ -266,7 +266,9 @@ class CppTestDriver(IDriver):
command=collect_test_command,
case_type=DeviceTestType.cpp_test_lite,
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)
self.delete_device_xml(request, self.config.device_xml_path)
return tests
@ -850,6 +852,7 @@ class BuildOnlyTestDriver(IDriver):
self.config.device = request.config.environment.devices[0]
self.file_name = request.root.source.test_name
self.config_file = request.root.source.config_file
self.testcases_path = request.config.testcases_path
file_path = self._get_log_file()
result_list = self._get_result_list(file_path)
if len(result_list) == 0:
@ -880,7 +883,7 @@ class BuildOnlyTestDriver(IDriver):
@classmethod
def _get_result_list(cls, file_path):
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:
if file_name == "logfile":
result_list.append(os.path.join(root_path, file_name))
@ -890,7 +893,12 @@ class BuildOnlyTestDriver(IDriver):
json_config = JsonParser(self.config_file)
log_path = get_config_value('log_path', json_config.get_driver(),
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
def __result__(self):

View File

@ -15,7 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import json
import time
import re
@ -26,7 +25,6 @@ from _core.exception import LiteDeviceTimeout
from _core.exception import LiteDeviceConnectError
from _core.exception import LiteDeviceExecuteCommandError
from _core.logger import platform_logger
from _core.utils import convert_port
__all__ = ["generate_report", "LiteHelper"]
@ -37,6 +35,8 @@ CPP_ERR_MESSAGE = "[ERR]No such file or directory: "
CTEST_STANDARD_SIGN = "Start to run test suite"
AT_CMD_ENDS = "OK"
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"
_END_JSUNIT_RUN_MARKER = "[end] run suites end"
@ -76,7 +76,10 @@ def check_read_test_end(result=None, input_command=None):
if result_output.find(INSTALL_END_MARKER) != -1:
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:
LOG.error("execute file not exist, result is %s" % result_output,
error_no="00402")
@ -143,7 +146,8 @@ class LiteHelper:
expect_result = [bytes(CPP_TEST_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:
if not Scheduler.is_execute:
raise ExecuteTerminate("Execute terminate", error_no="00300")
@ -274,7 +278,7 @@ class LiteHelper:
error_no="00402")
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):
command = command.encode("utf-8")
@ -297,8 +301,7 @@ class LiteHelper:
error_no="00402")
LOG.info(
"local_%s execute command shell %s" % (convert_port(com.port),
command))
"local_%s execute command shell %s" % (com.port, command))
command = command.encode("utf-8")
if command[-2:] != b"\r\n":
command = command.rstrip() + b'\r\n'

View File

@ -24,6 +24,7 @@ import subprocess
import shutil
import platform
import glob
import time
from _core.logger import platform_logger
from _core.plugin import Plugin
@ -234,10 +235,19 @@ class MountKit(ITestKit):
replace("nfs_directory", linux_directory).replace(
"device_directory", target).replace("//", "/")
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"):
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')
def __setup__(self, device, **kwargs):
@ -303,6 +313,12 @@ class MountKit(ITestKit):
if (str(get_local_ip()) == linux_host) and (
linux_directory == ("/data%s" % testcases_dir)):
return
ip = remote_info.get("ip", "")
port = remote_info.get("port", "")
_dir = remote_info.get("dir", "")
if not ip or not port or not _dir:
LOG.warning("nfs server's ip or port or dir is empty")
return
for _file in file_local_paths:
# remote copy
LOG.info("Trying to copy the file from {} to nfs server".
@ -310,8 +326,7 @@ class MountKit(ITestKit):
if not is_remote.lower() == "false":
try:
import paramiko
client = paramiko.Transport((remote_info.get("ip"),
int(remote_info.get("port"))))
client = paramiko.Transport(ip, int(port))
client.connect(username=remote_info.get("username"),
password=remote_info.get("password"))
sftp = paramiko.SFTPClient.from_transport(client)
@ -362,12 +377,19 @@ class MountKit(ITestKit):
else:
device.execute_command_with_timeout(command="cd /", timeout=1)
for mounted_dir in self.mounted_dir:
device.execute_command_with_timeout(command="umount {}".
format(mounted_dir),
timeout=2)
device.execute_command_with_timeout(command="rm -r {}".
format(mounted_dir),
timeout=1)
for mount_time in range(1, 3):
result, status, _ = device.execute_command_with_timeout(
command="umount {}".format(mounted_dir),
timeout=2)
if status:
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):