From: Aleš Mrázek Date: Fri, 21 Jun 2024 10:30:08 +0000 (+0200) Subject: manager: tests moved to the repository root X-Git-Tag: v6.0.9~27^2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a6790241638a0571d64846da9048ee94b2938412;p=thirdparty%2Fknot-resolver.git manager: tests moved to the repository root --- diff --git a/distro/tests/extra/all/control b/distro/tests/extra/all/control index b13cc27d2..1130b04dc 100644 --- a/distro/tests/extra/all/control +++ b/distro/tests/extra/all/control @@ -1,2 +1,41 @@ -{# This adds all tests for manager's packaging #} -{% include 'manager/tests/packaging/control' %} +{# Test that all packages are installed #} +Tests: dependencies.py +Tests-Directory: tests/packaging/ + + +{# Test that kresctl command exists and is in $PATH #} +Tests: kresctl.sh +Tests-Directory: tests/packaging + + +{# Test that knot-resolver command exists and is in $PATH #} +Tests: knot-resolver.sh +Tests-Directory: tests/packaging + + +{# Tests that the manager can be started with default config and it resolves some domains #} +Tests: systemd_service.sh +Tests-Directory: tests/packaging +Restrictions: needs-root +{% if distro.match('fedora') -%} +Depends: knot-utils, jq, curl, procps +{% elif distro.match('debian') or distro.match('ubuntu') -%} +Depends: knot-dnsutils, jq, curl, procps +{% elif distro.match('arch') -%} +Depends: knot, jq, curl +{% elif distro.match('rocky', 'centos') -%} +Depends: knot-utils, jq, curl +{% elif distro.match('almalinux') -%} +Depends: knot-utils, jq, curl-minimal, procps +{% elif distro.match('opensuse') -%} +Depends: knot-utils, jq, curl +{% else -%} +Depends: unsupported-distro-this-package-does-not-exist-and-the-test-should-fail +{%- endif %} + + +Tests: manpage.sh +Tests-Directory: tests/packaging +{% if distro.match('fedora') or distro.match('rocky') or distro.match('opensuse') -%} +Depends: man +{%- endif %} diff --git a/manager/pyproject.toml b/manager/pyproject.toml index 7f1bde1f2..3f1cb4542 100644 --- a/manager/pyproject.toml +++ b/manager/pyproject.toml @@ -62,7 +62,7 @@ configure = { cmd = "scripts/meson-configure", help = "Configure Knot Resolver d run = { cmd = "scripts/run", help = "Run the manager" } run-debug = { cmd = "scripts/run-debug", help = "Run the manager under debugger" } docs = { cmd = "scripts/docs", help = "Create HTML documentation" } -test = { shell = "env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=knot_resolver_manager --show-capture=all tests/unit/", help = "Run tests" } +test = { shell = "env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=knot_resolver_manager --show-capture=all ../tests/manager", help = "Run tests" } check = { cmd = "scripts/codecheck", help = "Run static code analysis" } format = { shell = "black knot_resolver_manager/ tests/ scripts/ build_c_extensions.py; isort .", help = "Run code formatter" } fixdeps = { shell = "poetry install; npm install; npm update", help = "Install/update dependencies according to configuration files"} diff --git a/manager/tests/README.md b/manager/tests/README.md deleted file mode 100644 index 1b6fc185e..000000000 --- a/manager/tests/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Testing infrastructure - -## Unit tests - -The unit tests use `pytest` and can be invoked by the command `poe test`. They reside in the `unit` subdirectory. They can be run from freshly cloned repository and they should suceed. - -## Integration tests - -The integration tests spawn a full manager with `kresd` instances (which it expects to be installed). The tests are implemented by a custom script and they can be invoked by `poe integration` command. \ No newline at end of file diff --git a/manager/tests/packaging/control b/manager/tests/packaging/control deleted file mode 100644 index 75c270934..000000000 --- a/manager/tests/packaging/control +++ /dev/null @@ -1,41 +0,0 @@ -{# Test that all packages are installed #} -Tests: dependencies.py -Tests-Directory: manager/tests/packaging/ - - -{# Test that kresctl command exists and is in $PATH #} -Tests: kresctl.sh -Tests-Directory: manager/tests/packaging - - -{# Test that knot-resolver command exists and is in $PATH #} -Tests: knot-resolver.sh -Tests-Directory: manager/tests/packaging - - -{# Tests that manager can be started with default config and it resolves some domains #} -Tests: systemd_service.sh -Tests-Directory: manager/tests/packaging -Restrictions: needs-root -{% if distro.match('fedora') -%} -Depends: knot-utils, jq, curl, procps -{% elif distro.match('debian') or distro.match('ubuntu') -%} -Depends: knot-dnsutils, jq, curl, procps -{% elif distro.match('arch') -%} -Depends: knot, jq, curl -{% elif distro.match('rocky', 'centos') -%} -Depends: knot-utils, jq, curl -{% elif distro.match('almalinux') -%} -Depends: knot-utils, jq, curl-minimal, procps -{% elif distro.match('opensuse') -%} -Depends: knot-utils, jq, curl -{% else -%} -Depends: unsupported-distro-this-package-does-not-exist-and-the-test-should-fail -{%- endif %} - - -Tests: manpage.sh -Tests-Directory: manager/tests/packaging -{% if distro.match('fedora') or distro.match('rocky') or distro.match('opensuse') -%} -Depends: man -{%- endif %} diff --git a/tests/README.rst b/tests/README.rst index 37867b389..c2239f2fd 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -1,13 +1,23 @@ .. SPDX-License-Identifier: GPL-3.0-or-later -Tests -===== +********************** +Testing infrastructure +********************** + +The following is a non-exhaustive list of various tests that can be found in this repo. +Some can be enabled by meson build system and some can be performed by Poetry tool. + + +The manager unit tests +====================== + +The unit tests use ``pytest`` and can be run with the command ``poe test``. +They can be run from a freshly cloned repository and should be successful. +They are located in the ``manager`` subdirectory. -The following is a non-comprehensitve lists of various tests that can be found -in this repo. These can be enabled by the build system. Unit tests ----------- +========== The unit tests depend on cmocka_ and can easily be executed after compilation. They are enabled by default (if ``cmocka`` is found). @@ -17,8 +27,9 @@ They are enabled by default (if ``cmocka`` is found). $ ninja -C build_dir $ meson test -C build_dir --suite unit + Postinstall tests ------------------ +================= There following tests require a working installation of kresd. The binary ``kresd`` found in ``$PATH`` will be tested. When testing through meson, @@ -29,8 +40,9 @@ kresd first. $ ninja install -C build_dir + Config tests ------------- +============ Config tests utilize the kresd's lua config file to execute arbitrary tests, typically testing various modules, their API etc. @@ -45,8 +57,9 @@ the build dir). $ ninja install -C build_dir $ meson test -C build_dir --suite config + Extra tests ------------ +=========== The extra tests require a large set of additional dependencies and executing them outside of upstream development is probably redundant. @@ -82,7 +95,7 @@ example TCP, TLS and its connection management. $ meson test -C build_dir --suite pytests Useful meson commands ---------------------- +===================== It's possible to run only specific test suite or a test. diff --git a/manager/tests/unit/__init__.py b/tests/manager/__init__.py similarity index 100% rename from manager/tests/unit/__init__.py rename to tests/manager/__init__.py diff --git a/manager/tests/unit/datamodel/templates/test_cache_macros.py b/tests/manager/datamodel/templates/test_cache_macros.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_cache_macros.py rename to tests/manager/datamodel/templates/test_cache_macros.py diff --git a/manager/tests/unit/datamodel/templates/test_common_macros.py b/tests/manager/datamodel/templates/test_common_macros.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_common_macros.py rename to tests/manager/datamodel/templates/test_common_macros.py diff --git a/manager/tests/unit/datamodel/templates/test_forward_macros.py b/tests/manager/datamodel/templates/test_forward_macros.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_forward_macros.py rename to tests/manager/datamodel/templates/test_forward_macros.py diff --git a/manager/tests/unit/datamodel/templates/test_network_macros.py b/tests/manager/datamodel/templates/test_network_macros.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_network_macros.py rename to tests/manager/datamodel/templates/test_network_macros.py diff --git a/manager/tests/unit/datamodel/templates/test_policy_macros.py b/tests/manager/datamodel/templates/test_policy_macros.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_policy_macros.py rename to tests/manager/datamodel/templates/test_policy_macros.py diff --git a/manager/tests/unit/datamodel/templates/test_types_render.py b/tests/manager/datamodel/templates/test_types_render.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_types_render.py rename to tests/manager/datamodel/templates/test_types_render.py diff --git a/manager/tests/unit/datamodel/templates/test_view_macros.py b/tests/manager/datamodel/templates/test_view_macros.py similarity index 100% rename from manager/tests/unit/datamodel/templates/test_view_macros.py rename to tests/manager/datamodel/templates/test_view_macros.py diff --git a/manager/tests/unit/datamodel/test_config_schema.py b/tests/manager/datamodel/test_config_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_config_schema.py rename to tests/manager/datamodel/test_config_schema.py diff --git a/manager/tests/unit/datamodel/test_forward_schema.py b/tests/manager/datamodel/test_forward_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_forward_schema.py rename to tests/manager/datamodel/test_forward_schema.py diff --git a/manager/tests/unit/datamodel/test_local_data.py b/tests/manager/datamodel/test_local_data.py similarity index 100% rename from manager/tests/unit/datamodel/test_local_data.py rename to tests/manager/datamodel/test_local_data.py diff --git a/manager/tests/unit/datamodel/test_lua_schema.py b/tests/manager/datamodel/test_lua_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_lua_schema.py rename to tests/manager/datamodel/test_lua_schema.py diff --git a/manager/tests/unit/datamodel/test_management_schema.py b/tests/manager/datamodel/test_management_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_management_schema.py rename to tests/manager/datamodel/test_management_schema.py diff --git a/manager/tests/unit/datamodel/test_network_schema.py b/tests/manager/datamodel/test_network_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_network_schema.py rename to tests/manager/datamodel/test_network_schema.py diff --git a/manager/tests/unit/datamodel/test_policy_schema.py b/tests/manager/datamodel/test_policy_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_policy_schema.py rename to tests/manager/datamodel/test_policy_schema.py diff --git a/manager/tests/unit/datamodel/test_rpz_schema.py b/tests/manager/datamodel/test_rpz_schema.py similarity index 100% rename from manager/tests/unit/datamodel/test_rpz_schema.py rename to tests/manager/datamodel/test_rpz_schema.py diff --git a/manager/tests/unit/datamodel/types/test_base_types.py b/tests/manager/datamodel/types/test_base_types.py similarity index 100% rename from manager/tests/unit/datamodel/types/test_base_types.py rename to tests/manager/datamodel/types/test_base_types.py diff --git a/manager/tests/unit/datamodel/types/test_custom_types.py b/tests/manager/datamodel/types/test_custom_types.py similarity index 100% rename from manager/tests/unit/datamodel/types/test_custom_types.py rename to tests/manager/datamodel/types/test_custom_types.py diff --git a/manager/tests/unit/datamodel/types/test_generic_types.py b/tests/manager/datamodel/types/test_generic_types.py similarity index 100% rename from manager/tests/unit/datamodel/types/test_generic_types.py rename to tests/manager/datamodel/types/test_generic_types.py diff --git a/manager/tests/unit/test_config_store.py b/tests/manager/test_config_store.py similarity index 100% rename from manager/tests/unit/test_config_store.py rename to tests/manager/test_config_store.py diff --git a/manager/tests/unit/test_knot_resolver_manager.py b/tests/manager/test_knot_resolver_manager.py similarity index 100% rename from manager/tests/unit/test_knot_resolver_manager.py rename to tests/manager/test_knot_resolver_manager.py diff --git a/manager/tests/unit/utils/modeling/test_base_schema.py b/tests/manager/utils/modeling/test_base_schema.py similarity index 100% rename from manager/tests/unit/utils/modeling/test_base_schema.py rename to tests/manager/utils/modeling/test_base_schema.py diff --git a/manager/tests/unit/utils/modeling/test_etag.py b/tests/manager/utils/modeling/test_etag.py similarity index 100% rename from manager/tests/unit/utils/modeling/test_etag.py rename to tests/manager/utils/modeling/test_etag.py diff --git a/manager/tests/unit/utils/modeling/test_json_pointer.py b/tests/manager/utils/modeling/test_json_pointer.py similarity index 100% rename from manager/tests/unit/utils/modeling/test_json_pointer.py rename to tests/manager/utils/modeling/test_json_pointer.py diff --git a/manager/tests/unit/utils/modeling/test_query.py b/tests/manager/utils/modeling/test_query.py similarity index 100% rename from manager/tests/unit/utils/modeling/test_query.py rename to tests/manager/utils/modeling/test_query.py diff --git a/manager/tests/unit/utils/modeling/test_renaming.py b/tests/manager/utils/modeling/test_renaming.py similarity index 100% rename from manager/tests/unit/utils/modeling/test_renaming.py rename to tests/manager/utils/modeling/test_renaming.py diff --git a/manager/tests/unit/utils/modeling/test_types.py b/tests/manager/utils/modeling/test_types.py similarity index 100% rename from manager/tests/unit/utils/modeling/test_types.py rename to tests/manager/utils/modeling/test_types.py diff --git a/manager/tests/unit/utils/test_dataclasses.py b/tests/manager/utils/test_dataclasses.py similarity index 100% rename from manager/tests/unit/utils/test_dataclasses.py rename to tests/manager/utils/test_dataclasses.py diff --git a/manager/tests/unit/utils/test_functional.py b/tests/manager/utils/test_functional.py similarity index 100% rename from manager/tests/unit/utils/test_functional.py rename to tests/manager/utils/test_functional.py diff --git a/tests/packaging/README.md b/tests/packaging/README.md new file mode 100644 index 000000000..633bd5760 --- /dev/null +++ b/tests/packaging/README.md @@ -0,0 +1,5 @@ +# Packaging tests + +## Distro tests + +Tests in this directory are part of the distro tests included in the `distro/tests/extra/all/control` file and can be run with the `apkg test` command. diff --git a/manager/tests/packaging/dependencies.py b/tests/packaging/dependencies.py similarity index 95% rename from manager/tests/packaging/dependencies.py rename to tests/packaging/dependencies.py index d92be71a9..324ff30b4 100755 --- a/manager/tests/packaging/dependencies.py +++ b/tests/packaging/dependencies.py @@ -15,7 +15,7 @@ sys.modules["setuptools"] = dummy sys.modules["build_c_extensions"] = dummy # load install_requires array from setup.py -spec = importlib.util.spec_from_file_location("setup", sys.argv[1] if len(sys.argv) == 2 else "manager/setup.py") +spec = importlib.util.spec_from_file_location("setup", sys.argv[1] if len(sys.argv) == 2 else "setup.py") mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) install_requires = mod.install_requires diff --git a/manager/tests/packaging/interactive/cache-clear.sh b/tests/packaging/interactive/cache-clear.sh similarity index 100% rename from manager/tests/packaging/interactive/cache-clear.sh rename to tests/packaging/interactive/cache-clear.sh diff --git a/manager/tests/packaging/interactive/etag.sh b/tests/packaging/interactive/etag.sh similarity index 100% rename from manager/tests/packaging/interactive/etag.sh rename to tests/packaging/interactive/etag.sh diff --git a/manager/tests/packaging/interactive/metrics.sh b/tests/packaging/interactive/metrics.sh similarity index 100% rename from manager/tests/packaging/interactive/metrics.sh rename to tests/packaging/interactive/metrics.sh diff --git a/manager/tests/packaging/interactive/reload.sh b/tests/packaging/interactive/reload.sh similarity index 100% rename from manager/tests/packaging/interactive/reload.sh rename to tests/packaging/interactive/reload.sh diff --git a/manager/tests/packaging/interactive/workers.sh b/tests/packaging/interactive/workers.sh similarity index 100% rename from manager/tests/packaging/interactive/workers.sh rename to tests/packaging/interactive/workers.sh diff --git a/manager/tests/packaging/knot-resolver.sh b/tests/packaging/knot-resolver.sh similarity index 100% rename from manager/tests/packaging/knot-resolver.sh rename to tests/packaging/knot-resolver.sh diff --git a/manager/tests/packaging/kresctl.sh b/tests/packaging/kresctl.sh similarity index 100% rename from manager/tests/packaging/kresctl.sh rename to tests/packaging/kresctl.sh diff --git a/manager/tests/packaging/manpage.sh b/tests/packaging/manpage.sh similarity index 100% rename from manager/tests/packaging/manpage.sh rename to tests/packaging/manpage.sh diff --git a/manager/tests/packaging/systemd_service.sh b/tests/packaging/systemd_service.sh similarity index 100% rename from manager/tests/packaging/systemd_service.sh rename to tests/packaging/systemd_service.sh