From ee9705a1ceb4dd80796f3b4c40de8c5c01ebc7e2 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Wed, 30 Mar 2022 10:15:51 -0700 Subject: [PATCH] [stable-2.13] ansible-test - Fix origin host target filtering. (cherry picked from commit 4b51e61645da35861b872a8d1033965792255092) Co-authored-by: Matt Clay --- changelogs/fragments/ansible-test-target-filter.yml | 5 +++++ .../ansible_test/_internal/commands/integration/filters.py | 2 +- test/lib/ansible_test/_internal/host_configs.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/ansible-test-target-filter.yml diff --git a/changelogs/fragments/ansible-test-target-filter.yml b/changelogs/fragments/ansible-test-target-filter.yml new file mode 100644 index 00000000000..e0af07752f1 --- /dev/null +++ b/changelogs/fragments/ansible-test-target-filter.yml @@ -0,0 +1,5 @@ +bugfixes: + - ansible-test - Correctly detect when running as the ``root`` user (UID 0) on the origin host. + The result of the detection was incorrectly being inverted. + - ansible-test - Fix skipping of tests marked ``needs/root`` on the origin host. + - ansible-test - Fix skipping of tests marked ``needs/python`` on the origin host. diff --git a/test/lib/ansible_test/_internal/commands/integration/filters.py b/test/lib/ansible_test/_internal/commands/integration/filters.py index 9854de57c6a..0396ce9231a 100644 --- a/test/lib/ansible_test/_internal/commands/integration/filters.py +++ b/test/lib/ansible_test/_internal/commands/integration/filters.py @@ -221,7 +221,7 @@ class NetworkInventoryTargetFilter(TargetFilter[NetworkInventoryConfig]): """Target filter for network inventory.""" -class OriginTargetFilter(TargetFilter[OriginConfig]): +class OriginTargetFilter(PosixTargetFilter[OriginConfig]): """Target filter for localhost.""" diff --git a/test/lib/ansible_test/_internal/host_configs.py b/test/lib/ansible_test/_internal/host_configs.py index 720385f734d..fee741e8b97 100644 --- a/test/lib/ansible_test/_internal/host_configs.py +++ b/test/lib/ansible_test/_internal/host_configs.py @@ -419,7 +419,7 @@ class OriginConfig(ControllerHostConfig, PosixConfig): @property def have_root(self): # type: () -> bool """True if root is available, otherwise False.""" - return os.getuid() != 0 + return os.getuid() == 0 @dataclasses.dataclass