summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2022-03-30 10:15:51 -0700
committerMatt Clay <matt@mystile.com>2022-03-30 15:42:13 -0700
commitde70bfbcb05c74b93110496dae347a734be88ef1 (patch)
treeb851d79155c3568b745e6481f430ab8c69227c32
parentd8bc9c4056df12deaaa11b0caa50138abb8bbb04 (diff)
downloadansible-de70bfbcb05c74b93110496dae347a734be88ef1.tar.gz
[stable-2.12] ansible-test - Fix origin host target filtering.
(cherry picked from commit 4b51e61645da35861b872a8d1033965792255092) Co-authored-by: Matt Clay <matt@mystile.com>
-rw-r--r--changelogs/fragments/ansible-test-target-filter.yml5
-rw-r--r--test/lib/ansible_test/_internal/commands/integration/filters.py2
-rw-r--r--test/lib/ansible_test/_internal/host_configs.py2
3 files changed, 7 insertions, 2 deletions
diff --git a/changelogs/fragments/ansible-test-target-filter.yml b/changelogs/fragments/ansible-test-target-filter.yml
new file mode 100644
index 0000000000..e0af07752f
--- /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 9854de57c6..0396ce9231 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 87030ae0ec..41fb7a89b9 100644
--- a/test/lib/ansible_test/_internal/host_configs.py
+++ b/test/lib/ansible_test/_internal/host_configs.py
@@ -412,7 +412,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