summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelogs/fragments/ansible-test-integration-target-prefixes.yml4
-rw-r--r--test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/target-prefixes.something2
-rw-r--r--test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/one-part_test/aliases0
-rw-r--r--test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/two_part_test/aliases0
-rwxr-xr-xtest/integration/targets/ansible-test-integration-targets/test.py12
-rw-r--r--test/lib/ansible_test/_internal/target.py10
6 files changed, 21 insertions, 7 deletions
diff --git a/changelogs/fragments/ansible-test-integration-target-prefixes.yml b/changelogs/fragments/ansible-test-integration-target-prefixes.yml
new file mode 100644
index 0000000000..9a31a0ac9c
--- /dev/null
+++ b/changelogs/fragments/ansible-test-integration-target-prefixes.yml
@@ -0,0 +1,4 @@
+bugfixes:
+ - ansible-test - Integration test target prefixes defined in a ``tests/integration/target-prefixes.{group}`` file
+ can now contain an underscore (``_``) character.
+ Resolves issue https://github.com/ansible/ansible/issues/79225
diff --git a/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/target-prefixes.something b/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/target-prefixes.something
new file mode 100644
index 0000000000..b306549277
--- /dev/null
+++ b/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/target-prefixes.something
@@ -0,0 +1,2 @@
+one-part
+two_part
diff --git a/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/one-part_test/aliases b/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/one-part_test/aliases
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/one-part_test/aliases
diff --git a/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/two_part_test/aliases b/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/two_part_test/aliases
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/integration/targets/ansible-test-integration-targets/ansible_collections/ns/col/tests/integration/targets/two_part_test/aliases
diff --git a/test/integration/targets/ansible-test-integration-targets/test.py b/test/integration/targets/ansible-test-integration-targets/test.py
index 443ed59d62..8effb647fc 100755
--- a/test/integration/targets/ansible-test-integration-targets/test.py
+++ b/test/integration/targets/ansible-test-integration-targets/test.py
@@ -31,5 +31,17 @@ class OptionsTest(unittest.TestCase):
raise Exception(f'{ex}:\n>>> Standard Output:\n{ex.stdout}\n>>> Standard Error:\n{ex.stderr}') from ex
+class PrefixesTest(unittest.TestCase):
+ def test_prefixes(self):
+ try:
+ command = ['ansible-test', 'integration', '--list-targets']
+
+ something = subprocess.run([*command, 'something/'], text=True, capture_output=True, check=True)
+
+ self.assertEqual(something.stdout.splitlines(), ['one-part_test', 'two_part_test'])
+ except subprocess.CalledProcessError as ex:
+ raise Exception(f'{ex}:\n>>> Standard Output:\n{ex.stdout}\n>>> Standard Error:\n{ex.stderr}') from ex
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/lib/ansible_test/_internal/target.py b/test/lib/ansible_test/_internal/target.py
index 70016a71a5..a6fa3bf289 100644
--- a/test/lib/ansible_test/_internal/target.py
+++ b/test/lib/ansible_test/_internal/target.py
@@ -610,13 +610,9 @@ class IntegrationTarget(CompletionTarget):
if 'needs/httptester' in groups:
groups.append('cloud/httptester') # backwards compatibility for when it was not a cloud plugin
- if '_' in self.name:
- prefix = self.name[:self.name.find('_')]
- else:
- prefix = None
-
- if prefix in prefixes:
- group = prefixes[prefix]
+ for prefix, group in prefixes.items():
+ if not self.name.startswith(f'{prefix}_'):
+ continue
if group != prefix:
group = '%s/%s' % (group, prefix)