@@ -8,6 +8,8 @@
import os.path
from typing import TypedDict
+from .settings import SETTINGS
+
"""
DTS logger module with several log level. DTS framework and TestSuite log
will saved into different log files.
@@ -66,10 +68,9 @@ def __init__(self, logger: logging.Logger, node: str = "suite"):
self.logger.addHandler(sh)
self.sh = sh
- if not os.path.exists("output"):
- os.mkdir("output")
+ logging_file_prefix = os.path.join(SETTINGS.output_dir, node)
- fh = logging.FileHandler(f"output/{node}.log")
+ fh = logging.FileHandler(f"{logging_file_prefix}.log")
fh.setFormatter(
logging.Formatter(
fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
@@ -83,7 +84,7 @@ def __init__(self, logger: logging.Logger, node: str = "suite"):
# This outputs EVERYTHING, intended for post-mortem debugging
# Also optimized for processing via AWK (awk -F '|' ...)
- verbose_handler = logging.FileHandler(f"output/{node}.verbose.log")
+ verbose_handler = logging.FileHandler(f"{logging_file_prefix}.verbose.log")
verbose_handler.setFormatter(
logging.Formatter(
fmt="%(asctime)s|%(name)s|%(levelname)s|%(pathname)s|%(lineno)d|%(funcName)s|"
@@ -7,6 +7,7 @@
import argparse
import os
from dataclasses import dataclass
+from enum import Enum, unique
from typing import Any
@@ -38,10 +39,40 @@ def wrapper(**kwargs) -> _EnvironmentArgument:
@dataclass(slots=True, frozen=True)
-class _Settings:
+class _EnvSettings:
config_file_path: str
+ compile_timeout: int
timeout: float
verbose: bool
+ output_dir: str
+ skip_setup: bool
+ test_cases: list
+ re_run: int
+ remote_dpdk_dir: str
+
+
+@dataclass(slots=True)
+class _RuntimeSettings:
+ dpdk_ref: str
+
+
+class _Settings(_EnvSettings, _RuntimeSettings):
+ pass
+
+
+@unique
+class DTSRuntimeErrors(Enum):
+ NO_ERR = 0
+ GENERIC_ERR = 1
+ DPDK_BUILD_ERR = (2,)
+ SUT_SETUP_ERR = (3,)
+ TG_SETUP_ERR = (4,)
+ SUITE_SETUP_ERR = (5,)
+ SUITE_EXECUTE_ERR = 6
+
+
+# TODO singleton
+DTSRuntimeError: DTSRuntimeErrors = DTSRuntimeErrors.NO_ERR
def _get_parser() -> argparse.ArgumentParser:
@@ -63,6 +94,14 @@ def _get_parser() -> argparse.ArgumentParser:
help="[DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.",
)
+ parser.add_argument(
+ "--compile-timeout",
+ action=_env_arg("DTS_COMPILE_TIMEOUT"),
+ default=1200,
+ required=False,
+ help="[DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK.",
+ )
+
parser.add_argument(
"-v",
"--verbose",
@@ -72,15 +111,62 @@ def _get_parser() -> argparse.ArgumentParser:
help="[DTS_VERBOSE] Set to 'Y' to enable verbose output, logging all messages to the console.",
)
+ parser.add_argument(
+ "--dpdk-ref",
+ "--git",
+ "--snapshot",
+ action=_env_arg("DTS_DPDK_REF"),
+ default="dep/dpdk.tar.gz",
+ help="[DTS_DPDK_REF] Reference to DPDK source code, "
+ "can be either a path to a tarball or a git refspec. "
+ "In case of a tarball, it will be extracted in the same directory.",
+ )
+
+ parser.add_argument(
+ "--output-dir",
+ "--output",
+ action=_env_arg("DTS_OUTPUT_DIR"),
+ default="output",
+ help="[DTS_OUTPUT_DIR] Output directory where dts logs and results are saved.",
+ )
+
+ parser.add_argument(
+ "-s",
+ "--skip-setup",
+ action=_env_arg("DTS_SKIP_SETUP"),
+ help="[DTS_SKIP_SETUP] Set to 'Y' to skip all setup steps on SUT and TG nodes.",
+ )
+
+ parser.add_argument(
+ "--test-cases",
+ action=_env_arg("DTS_TESTCASES"),
+ help="[DTS_TESTCASES] Comma-separated list of testcases to execute",
+ )
+
+ parser.add_argument(
+ "--re-run",
+ "--re_run",
+ action=_env_arg("DTS_RERUN"),
+ default=0,
+ help="[DTS_RERUN] Re-run tests the specified amount of times if a test failure occurs",
+ )
+
return parser
def _get_settings() -> _Settings:
- args = _get_parser().parse_args()
+ parsed_args = _get_parser().parse_args()
return _Settings(
- config_file_path=args.config_file,
- timeout=float(args.timeout),
- verbose=(args.verbose == "Y"),
+ config_file_path=parsed_args.config_file,
+ compile_timeout=parsed_args.compile_timeout,
+ timeout=parsed_args.timeout,
+ verbose=(parsed_args.verbose == "Y"),
+ output_dir=parsed_args.output_dir,
+ skip_setup=(parsed_args.skip_setup == "Y"),
+ test_cases=parsed_args.test_cases.split(","),
+ re_run=int(parsed_args.re_run),
+ remote_dpdk_dir="/tmp/",
+ dpdk_ref=parsed_args.dpdk_ref,
)