forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ansible-test - Narrow the scope of some sanity tests (ansible#81273)
* ansible-test - Limit scope of replace-urlopen test Only ansible-core code and plugins in collections can be expected to rely on module_utils. * ansible-test - Limit scope of use-compat-six test Only ansible-core code and plugins in collections can be expected to rely on module_utils. * ansible-test - Limit scope of no-get-exception test Only ansible-core code and plugins in collections should be checked for usage of outdated module_utils functions. * Add integration tests
- Loading branch information
Showing
20 changed files
with
101 additions
and
5 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,7 @@ | ||
minor_changes: | ||
- ansible-test - The ``replace-urlopen`` sanity test is now limited to plugins in collections. | ||
Previously any Python file in a collection was checked for ``urlopen`` usage. | ||
- ansible-test - The ``use-compat-six`` sanity test is now limited to plugins in collections. | ||
Previously any Python file in a collection was checked for ``six`` usage. | ||
- ansible-test - The ``no-get-exception`` sanity test is now limited to plugins in collections. | ||
Previously any Python file in a collection was checked for ``get_exception`` usage. |
4 changes: 4 additions & 0 deletions
4
test/integration/targets/ansible-test-sanity-no-get-exception/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,4 @@ | ||
shippable/posix/group3 # runs in the distro test containers | ||
shippable/generic/group1 # runs in the default test container | ||
context/controller | ||
needs/target/collection |
5 changes: 5 additions & 0 deletions
5
...argets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.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.module_utils.pycompat24 import get_exception | ||
|
||
|
||
def do_stuff(): | ||
get_exception() |
5 changes: 5 additions & 0 deletions
5
...sible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.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.module_utils.pycompat24 import get_exception | ||
|
||
|
||
def do_stuff(): | ||
get_exception() |
2 changes: 2 additions & 0 deletions
2
test/integration/targets/ansible-test-sanity-no-get-exception/expected.txt
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 @@ | ||
plugins/modules/check-me.py:1:44: do not use `get_exception` | ||
plugins/modules/check-me.py:5:4: do not use `get_exception` |
12 changes: 12 additions & 0 deletions
12
test/integration/targets/ansible-test-sanity-no-get-exception/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 | ||
|
||
set -eu | ||
|
||
source ../collection/setup.sh | ||
|
||
set -x | ||
|
||
ansible-test sanity --test no-get-exception --color --lint --failure-ok "${@}" > actual.txt | ||
|
||
diff -u "${TEST_DIR}/expected.txt" actual.txt | ||
diff -u do-not-check-me.py plugins/modules/check-me.py |
4 changes: 4 additions & 0 deletions
4
test/integration/targets/ansible-test-sanity-replace-urlopen/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,4 @@ | ||
shippable/posix/group3 # runs in the distro test containers | ||
shippable/generic/group1 # runs in the default test container | ||
context/controller | ||
needs/target/collection |
5 changes: 5 additions & 0 deletions
5
...targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/do-not-check-me.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 @@ | ||
import urllib.request | ||
|
||
|
||
def do_stuff(): | ||
urllib.request.urlopen('https://www.ansible.com/') |
5 changes: 5 additions & 0 deletions
5
...nsible-test-sanity-replace-urlopen/ansible_collections/ns/col/plugins/modules/check-me.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 @@ | ||
import urllib.request | ||
|
||
|
||
def do_stuff(): | ||
urllib.request.urlopen('https://www.ansible.com/') |
1 change: 1 addition & 0 deletions
1
test/integration/targets/ansible-test-sanity-replace-urlopen/expected.txt
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 @@ | ||
plugins/modules/check-me.py:5:20: use `ansible.module_utils.urls.open_url` instead of `urlopen` |
12 changes: 12 additions & 0 deletions
12
test/integration/targets/ansible-test-sanity-replace-urlopen/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 | ||
|
||
set -eu | ||
|
||
source ../collection/setup.sh | ||
|
||
set -x | ||
|
||
ansible-test sanity --test replace-urlopen --color --lint --failure-ok "${@}" > actual.txt | ||
|
||
diff -u "${TEST_DIR}/expected.txt" actual.txt | ||
diff -u do-not-check-me.py plugins/modules/check-me.py |
4 changes: 4 additions & 0 deletions
4
test/integration/targets/ansible-test-sanity-use-compat-six/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,4 @@ | ||
shippable/posix/group3 # runs in the distro test containers | ||
shippable/generic/group1 # runs in the default test container | ||
context/controller | ||
needs/target/collection |
5 changes: 5 additions & 0 deletions
5
.../targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/do-not-check-me.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 @@ | ||
import six | ||
|
||
|
||
def do_stuff(): | ||
assert six.text_type |
5 changes: 5 additions & 0 deletions
5
...ansible-test-sanity-use-compat-six/ansible_collections/ns/col/plugins/modules/check-me.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 @@ | ||
import six | ||
|
||
|
||
def do_stuff(): | ||
assert six.text_type |
1 change: 1 addition & 0 deletions
1
test/integration/targets/ansible-test-sanity-use-compat-six/expected.txt
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 @@ | ||
plugins/modules/check-me.py:1:1: use `ansible.module_utils.six` instead of `six` |
12 changes: 12 additions & 0 deletions
12
test/integration/targets/ansible-test-sanity-use-compat-six/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 | ||
|
||
set -eu | ||
|
||
source ../collection/setup.sh | ||
|
||
set -x | ||
|
||
ansible-test sanity --test use-compat-six --color --lint --failure-ok "${@}" > actual.txt | ||
|
||
diff -u "${TEST_DIR}/expected.txt" actual.txt | ||
diff -u do-not-check-me.py plugins/modules/check-me.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,9 @@ | |
"extensions": [ | ||
".py" | ||
], | ||
"prefixes": [ | ||
"lib/ansible/", | ||
"plugins/" | ||
], | ||
"output": "path-line-column-message" | ||
} |
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