X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=test%2Frun.py;h=da461e8de7a05eb95eb97e65c9e19067615e143a;hb=0157885517dcc0236b4719d4fc0ad789b3a15187;hp=646354ab060642255d7a8ad3a21d83880ddfdd19;hpb=c872cec3f0b31f7baf36dd50d75c285f0d0f4bec;p=vpp.git diff --git a/test/run.py b/test/run.py index 646354ab060..da461e8de7a 100755 --- a/test/run.py +++ b/test/run.py @@ -25,6 +25,8 @@ from subprocess import Popen, PIPE, STDOUT, call import sys import time import venv +import datetime +import re # Required Std. Path Variables @@ -46,12 +48,9 @@ vpp_plugin_path = vpp_test_plugin_path = ld_library_path = None pip_version = "22.0.4" pip_tools_version = "6.6.0" -# Test requirement files -test_requirements_file = os.path.join(test_dir, "requirements.txt") -# Auto-generated requirement file +# Compiled pip requirements file pip_compiled_requirements_file = os.path.join(test_dir, "requirements-3.txt") - # Gracefully exit after executing cleanup scripts # upon receiving a SIGINT or SIGTERM def handler(signum, frame): @@ -63,10 +62,15 @@ signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGTERM, handler) -def show_progress(stream): +def show_progress(stream, exclude_pattern=None): """ Read lines from a subprocess stdout/stderr streams and write to sys.stdout & the logfile + + arguments: + stream - subprocess stdout or stderr data stream + exclude_pattern - lines matching this reg-ex will be excluded + from stdout. """ while True: s = stream.readline() @@ -76,7 +80,11 @@ def show_progress(stream): # Filter the annoying SIGTERM signal from the output when VPP is # terminated after a test run if "SIGTERM" not in data: - sys.stdout.write(data) + if exclude_pattern is not None: + if bool(re.search(exclude_pattern, data)) is False: + sys.stdout.write(data) + else: + sys.stdout.write(data) logging.debug(data) sys.stdout.flush() stream.close() @@ -105,11 +113,6 @@ class ExtendedEnvBuilder(venv.EnvBuilder): os.environ[ "CUSTOM_COMPILE_COMMAND" ] = "make test-refresh-deps (or update requirements.txt)" - # Cleanup previously auto-generated pip req. file - try: - os.unlink(pip_compiled_requirements_file) - except OSError: - pass # Set the venv python executable & binary install path env_exe = context.env_exe bin_path = context.bin_path @@ -118,15 +121,6 @@ class ExtendedEnvBuilder(venv.EnvBuilder): test_req = [ ["pip", "install", "pip===%s" % pip_version], ["pip", "install", "pip-tools===%s" % pip_tools_version], - [ - "piptools", - "compile", - "-q", - "--generate-hashes", - test_requirements_file, - "--output-file", - pip_compiled_requirements_file, - ], ["piptools", "sync", pip_compiled_requirements_file], ["pip", "install", "-e", papi_python_src_dir], ] @@ -221,10 +215,13 @@ def vm_test_runner(test_name, kernel_image, test_data_dir, cpu_mask, mem, jobs=" p = Popen( [script, test_name, kernel_image, test_data_dir, cpu_mask, mem], stdout=PIPE, - stderr=STDOUT, cwd=ws_root, ) - show_progress(p.stdout) + # Show only the test result without clobbering the stdout. + # The VM console displays VPP stderr & Linux IPv6 netdev change + # messages, which is logged by default and can be excluded. + exclude_pattern = r"vpp\[\d+\]:|ADDRCONF\(NETDEV_CHANGE\):" + show_progress(p.stdout, exclude_pattern) post_vm_test_run() @@ -282,6 +279,7 @@ def run_tests_in_venv( log_dir, socket_dir="", running_vpp=False, + extended=False, ): """Runs tests in the virtual environment set by venv_dir. @@ -291,6 +289,7 @@ def run_tests_in_venv( log_dir: Directory location for storing log files socket_dir: Use running VPP's socket files running_vpp: True if tests are run against a running VPP + extended: Run extended tests """ script = os.path.join(test_dir, "scripts", "run.sh") args = [ @@ -300,9 +299,13 @@ def run_tests_in_venv( f"--filter={test}", f"--jobs={jobs}", f"--log-dir={log_dir}", + f"--tmp-dir={log_dir}", + f"--cache-vpp-output", ] if running_vpp: args = args + [f"--use-running-vpp"] + if extended: + args = args + [f"--extended"] print(f"Running script: {script} " f"{' '.join(args)}") process_args = [script] + args call(process_args) @@ -376,9 +379,9 @@ if __name__ == "__main__": parser.add_argument( "--log-dir", action="store", - default="/tmp", + default=os.path.abspath(f"./test-run-{datetime.date.today()}"), help="directory where to store directories " - "containing log files (default: /tmp)", + "containing log files (default: ./test-run-YYYY-MM-DD)", ) parser.add_argument( "--jobs", @@ -407,6 +410,15 @@ if __name__ == "__main__": "Default: /var/run/vpp if VPP is started as the root user, else " "/var/run/user/${uid}/vpp.", ) + parser.add_argument( + "-e", + "--extended", + dest="extended", + required=False, + action="store_true", + default=False, + help="Run extended tests.", + ) args = parser.parse_args() vm_tests = False # Enable VM tests @@ -434,6 +446,7 @@ if __name__ == "__main__": log_dir=args.log_dir, socket_dir=args.socket_dir, running_vpp=args.running_vpp, + extended=args.extended, ) # Run tests against a VPP inside a VM else: