Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible-test - Parse content config only once. (#78418)
- Loading branch information
Showing
17 changed files
with
168 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bugfixes: | ||
- "ansible-test - Test configuration for collections is now parsed only once, prior to delegation. | ||
Fixes issue: https://github.com/ansible/ansible/issues/78334" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
shippable/posix/group1 # runs in the distro test containers | ||
shippable/generic/group1 # runs in the default test container | ||
context/controller | ||
needs/target/collection |
1 change: 1 addition & 0 deletions
1
...tegration/targets/ansible-test-config-invalid/ansible_collections/ns/col/tests/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invalid |
1 change: 1 addition & 0 deletions
1
...ble-test-config-invalid/ansible_collections/ns/col/tests/integration/targets/test/aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
context/controller |
1 change: 1 addition & 0 deletions
1
...le-test-config-invalid/ansible_collections/ns/col/tests/integration/targets/test/runme.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#!/usr/bin/env bash |
2 changes: 2 additions & 0 deletions
2
...st-config-invalid/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def test_me(): | ||
pass |
12 changes: 12 additions & 0 deletions
12
test/integration/targets/ansible-test-config-invalid/runme.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# Make sure that ansible-test continues to work when content config is invalid. | ||
|
||
set -eu | ||
|
||
source ../collection/setup.sh | ||
|
||
set -x | ||
|
||
ansible-test sanity --test import --python "${ANSIBLE_TEST_PYTHON_VERSION}" --color --venv -v | ||
ansible-test units --python "${ANSIBLE_TEST_PYTHON_VERSION}" --color --venv -v | ||
ansible-test integration --color --venv -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
shippable/posix/group1 # runs in the distro test containers | ||
shippable/generic/group1 # runs in the default test container | ||
context/controller | ||
needs/target/collection |
14 changes: 14 additions & 0 deletions
14
...ation/targets/ansible-test-config/ansible_collections/ns/col/plugins/module_utils/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sys | ||
import os | ||
|
||
|
||
def version_to_str(value): | ||
return '.'.join(str(v) for v in value) | ||
|
||
|
||
controller_min_python_version = tuple(int(v) for v in os.environ['ANSIBLE_CONTROLLER_MIN_PYTHON_VERSION'].split('.')) | ||
current_python_version = sys.version_info[:2] | ||
|
||
if current_python_version < controller_min_python_version: | ||
raise Exception('Current Python version %s is lower than the minimum controller Python version of %s. ' | ||
'Did the collection config get ignored?' % (version_to_str(current_python_version), version_to_str(controller_min_python_version))) |
2 changes: 2 additions & 0 deletions
2
test/integration/targets/ansible-test-config/ansible_collections/ns/col/tests/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
modules: | ||
python_requires: controller # allow tests to pass when run against a Python version not supported by the controller |
5 changes: 5 additions & 0 deletions
5
...sible-test-config/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from ansible_collections.ns.col.plugins.module_utils import test | ||
|
||
|
||
def test_me(): | ||
assert test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
# Make sure that ansible-test is able to parse collection config when using a venv. | ||
|
||
set -eu | ||
|
||
source ../collection/setup.sh | ||
|
||
set -x | ||
|
||
# On systems with a Python version below the minimum controller Python version, such as the default container, this test | ||
# will verify that the content config is working properly after delegation. Otherwise it will only verify that no errors | ||
# occur while trying to access content config (such as missing requirements). | ||
|
||
ansible-test sanity --test import --color --venv -v | ||
ansible-test units --color --venv -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.