From: Aleš Mrázek Date: Thu, 13 Jun 2024 04:12:39 +0000 (+0200) Subject: manager: tests: unused integration tests removed X-Git-Tag: v6.0.8~10^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=570dc347fccb29bc945926b14cb3ec42d6d652a7;p=thirdparty%2Fknot-resolver.git manager: tests: unused integration tests removed --- diff --git a/manager/tests/integration/.gitignore b/manager/tests/integration/.gitignore deleted file mode 100644 index 3feccc83d..000000000 --- a/manager/tests/integration/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -cache/ -run/ \ No newline at end of file diff --git a/manager/tests/integration/config.yml b/manager/tests/integration/config.yml deleted file mode 100644 index b05f18b36..000000000 --- a/manager/tests/integration/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -network: - listen: - - interface: 127.0.0.1@5353 -server: - id: integration-test - workers: 1 - rundir: tests/integration/run - management: - interface: 127.0.0.1@5001 -cache: - storage: cache -logging: - level: debug \ No newline at end of file diff --git a/manager/tests/integration/runner.py b/manager/tests/integration/runner.py deleted file mode 100644 index 000d7ae81..000000000 --- a/manager/tests/integration/runner.py +++ /dev/null @@ -1,96 +0,0 @@ -import logging -import sys -from pathlib import Path -from typing import Callable - -from knot_resolver_manager.client import KnotManagerClient, count_running_kresds, start_manager_in_background - -PORT = 5001 -HOST = "localhost" -BASE_URL = f"http://{HOST}:{PORT}" - - -Test = Callable[[KnotManagerClient], None] - - -logger = logging.getLogger(__name__) - - -def test_wrapper(test: Test) -> bool: - p = start_manager_in_background(Path("tests/integration/config.yaml")) - client = KnotManagerClient(BASE_URL) - client.wait_for_initialization() - - logger.info("Starting test %s", test.__name__) - try: - test(client) - res = True - except AssertionError: - logger.error("Test %s failed", exc_info=True) - res = False - - try: - client.stop() - p.join() - except Exception: - logger.warn("Failed to stop manager gracefully, terminating by force...") - p.terminate() - p.join() - - return res - - -def worker_count(client: KnotManagerClient): - client.set_num_workers(2) - cnt = count_running_kresds() - assert cnt == 2, f"Expected 2 kresd instances, found {cnt}" - - client.set_num_workers(1) - cnt = count_running_kresds() - assert cnt == 1, f"Expected 1 kresd instance, found {cnt}" - - -def crash_resistance(client: KnotManagerClient): - client.set_num_workers(2) - cnt = count_running_kresds() - assert cnt == 2, f"Expected 2 kresd instances, found {cnt}" - - # kill the server - # p.terminate() - # p.join() - - # no change in number of workers should be visible - cnt = count_running_kresds() - assert cnt == 2, f"Expected 2 kresd instances, found {cnt}" - - # start the server again - p = start_manager_in_background(Path("test/integration/config.yaml")) - try: - client.wait_for_initialization() - except TimeoutError as e: - p.terminate() - raise e - - # no change in number of workers should be visible - cnt = count_running_kresds() - assert cnt == 2, f"Expected 2 kresd instances, found {cnt}" - - # however the manager should now react to changes - client.set_num_workers(1) - cnt = count_running_kresds() - assert cnt == 1, f"Expected 1 kresd instance, found {cnt}" - - -if __name__ == "__main__": - logging.basicConfig(level=logging.DEBUG) - - # create run directories if it does not exist - Path("tests/integration/run").mkdir(exist_ok=True) - - # run the tests - success = True - success &= test_wrapper(worker_count) - # success &= test_wrapper(crash_resistance) - - # exit with proper exitcode - sys.exit(int(not success))