From c3bde10f75635ef70378c61539d58329dd0321e0 Mon Sep 17 00:00:00 2001 From: Carl Baillargeon Date: Thu, 25 Apr 2024 08:09:08 -0400 Subject: [PATCH] Fix stuff after rebase --- anta/runner.py | 54 -------------------------------------------------- 1 file changed, 54 deletions(-) diff --git a/anta/runner.py b/anta/runner.py index 13a3f49c5..681686de0 100644 --- a/anta/runner.py +++ b/anta/runner.py @@ -10,7 +10,6 @@ import os import resource from collections import defaultdict -from collections import defaultdict from typing import TYPE_CHECKING from anta import GITHUB_SUGGESTION @@ -19,8 +18,6 @@ from anta.tools import Catchtime, cprofile if TYPE_CHECKING: - from anta.catalog import AntaCatalog, AntaTestDefinition - from anta.device import AntaDevice from anta.catalog import AntaCatalog, AntaTestDefinition from anta.device import AntaDevice from anta.inventory import AntaInventory @@ -31,31 +28,6 @@ DEFAULT_NOFILE = 16384 -def adjust_rlimit_nofile() -> tuple[int, int]: - """Adjust the maximum number of open file descriptors for the ANTA process. - - The limit is set to the lower of the current hard limit and the value of the ANTA_NOFILE environment variable. - - If the `ANTA_NOFILE` environment variable is not set or is invalid, `DEFAULT_NOFILE` is used. - - Returns - ------- - tuple[int, int]: The new soft and hard limits for open file descriptors. - """ - try: - nofile = int(os.environ.get("ANTA_NOFILE", DEFAULT_NOFILE)) - except ValueError as exception: - logger.warning("The ANTA_NOFILE environment variable value is invalid: %s\nDefault to %s.", exc_to_str(exception), DEFAULT_NOFILE) - nofile = DEFAULT_NOFILE - - limits = resource.getrlimit(resource.RLIMIT_NOFILE) - logger.debug("Initial limit numbers for open file descriptors for the current ANTA process: Soft Limit: %s | Hard Limit: %s", limits[0], limits[1]) - nofile = nofile if limits[1] > nofile else limits[1] - logger.debug("Setting soft limit for open file descriptors for the current ANTA process to %s", nofile) - resource.setrlimit(resource.RLIMIT_NOFILE, (nofile, limits[1])) - return resource.getrlimit(resource.RLIMIT_NOFILE) - - def adjust_rlimit_nofile() -> tuple[int, int]: """Adjust the maximum number of open file descriptors for the ANTA process. @@ -211,9 +183,6 @@ async def main( # noqa: PLR0913 devices: Devices on which to run tests. None means all devices. These may come from the `--device / -d` CLI option in NRFU. tests: Tests to run against devices. None means all tests. These may come from the `--test / -t` CLI option in NRFU. tags: Tags to filter devices from the inventory. These may come from the `--tags` CLI option in NRFU. - devices: Devices on which to run tests. None means all devices. These may come from the `--device / -d` CLI option in NRFU. - tests: Tests to run against devices. None means all tests. These may come from the `--test / -t` CLI option in NRFU. - tags: Tags to filter devices from the inventory. These may come from the `--tags` CLI option in NRFU. established_only: Include only established device(s). dry_run: Build the list of coroutine to run and stop before test execution. """ @@ -252,22 +221,6 @@ async def main( # noqa: PLR0913 logger.info(run_info) - if catalog.final_tests_count > limits[0]: - logger.warning( - "The number of concurrent tests is higher than the open file descriptors limit for this ANTA process.\n" - "Errors may occur while running the tests.\n" - "Please consult the ANTA FAQ." - ) - run_info = ( - "--- ANTA NRFU Run Information ---\n" - f"Number of devices: {len(inventory)} ({len(selected_inventory)} established)\n" - f"Total number of selected tests: {catalog.final_tests_count}\n" - f"Maximum number of open file descriptors for the current ANTA process: {limits[0]}\n" - "---------------------------------" - ) - - logger.info(run_info) - if catalog.final_tests_count > limits[0]: logger.warning( "The number of concurrent tests is higher than the open file descriptors limit for this ANTA process.\n" @@ -308,14 +261,7 @@ async def main( # noqa: PLR0913 test_results = await asyncio.gather(*coros) for r in test_results: manager.add(r) - logger.info("Running ANTA tests...") - test_results = await asyncio.gather(*coros) - for r in test_results: - manager.add(r) logger.info("Running ANTA tests completed in %s", run_t.time) log_cache_statistics(selected_inventory.devices) - logger.info("Running ANTA tests completed in %s", run_t.time) - - log_cache_statistics(selected_inventory.devices)