mirror of https://github.com/ansible/ansible.git
[stable-2.14] ansible-test - Fix integration test target filter. (#78862)
- Allow disabled, unsupported, unstable and destructive integration test targets to be selected using their respective prefixes.
- Allow unstable tests to run when targeted changes are made and the ``--allow-unstable-changed`` option is specified (resolves https://github.com/ansible/ansible/issues/74213).
(cherry picked from commit d3d7785472
)
Co-authored-by: Matt Clay <matt@mystile.com>
pull/78870/head
parent
7aff371ba5
commit
4655fe6d8b
@ -0,0 +1,4 @@
|
||||
bugfixes:
|
||||
- ansible-test - Allow disabled, unsupported, unstable and destructive integration test targets to be selected using their respective prefixes.
|
||||
- ansible-test - Allow unstable tests to run when targeted changes are made and the ``--allow-unstable-changed`` option is specified
|
||||
(resolves https://github.com/ansible/ansible/issues/74213).
|
@ -0,0 +1,4 @@
|
||||
shippable/posix/group3 # runs in the distro test containers
|
||||
shippable/generic/group1 # runs in the default test container
|
||||
context/controller
|
||||
needs/target/collection
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
destructive
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
destructive
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
disabled
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
disabled
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
unstable
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
unstable
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
unsupported
|
@ -0,0 +1,2 @@
|
||||
context/controller
|
||||
unsupported
|
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
test="$(pwd)/test.py"
|
||||
|
||||
source ../collection/setup.sh
|
||||
|
||||
set -x
|
||||
|
||||
"${test}" -v
|
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
|
||||
class OptionsTest(unittest.TestCase):
|
||||
options = (
|
||||
'unsupported',
|
||||
'disabled',
|
||||
'unstable',
|
||||
'destructive',
|
||||
)
|
||||
|
||||
def test_options(self):
|
||||
for option in self.options:
|
||||
with self.subTest(option=option):
|
||||
try:
|
||||
command = ['ansible-test', 'integration', '--list-targets']
|
||||
|
||||
skip_all = subprocess.run([*command, f'{option}_a', f'{option}_b'], text=True, capture_output=True, check=True)
|
||||
allow_all = subprocess.run([*command, f'--allow-{option}', f'{option}_a', f'{option}_b'], text=True, capture_output=True, check=True)
|
||||
allow_first = subprocess.run([*command, f'{option}/{option}_a', f'{option}_b'], text=True, capture_output=True, check=True)
|
||||
allow_last = subprocess.run([*command, f'{option}_a', f'{option}/{option}_b'], text=True, capture_output=True, check=True)
|
||||
|
||||
self.assertEqual(skip_all.stdout.splitlines(), [])
|
||||
self.assertEqual(allow_all.stdout.splitlines(), [f'{option}_a', f'{option}_b'])
|
||||
self.assertEqual(allow_first.stdout.splitlines(), [f'{option}_a'])
|
||||
self.assertEqual(allow_last.stdout.splitlines(), [f'{option}_b'])
|
||||
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()
|
Loading…
Reference in New Issue