Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common sanity ignore & skip to ansible-test. #59416

Merged
merged 3 commits into from Jul 23, 2019

Conversation

mattclay
Copy link
Member

SUMMARY

Add common sanity ignore & skip to ansible-test.

This is the first step in moving towards a single unified ignore/skip file for all sanity tests. It consolidates the logic for processing ignore and skip files for all regular sanity tests, eliminating the code formerly implemented in each individual test.

Follow-up PRs will combine the existing ignore and skip files into a single file and then extend this common skip/ignore support for the existing code-smell tests.

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible-test

@mattclay mattclay added this to In progress in Testing Collections via automation Jul 23, 2019
@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Jul 23, 2019
@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Jul 23, 2019

if not ignore_entry:
continue
settings = self.load_settings(args, 'AnsibleTest')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I don't fully understand what the code arg is for, why is this in PascalCase where most of the others is in snake_code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When ansible-test runs sanity tests, it checks the skip and ignore files for issues. If there are any to report, and the sanity test uses error codes, then ansible-test needs its own error code to report those errors. I chose to make the error codes ansible-test uses match the style of error code used by the sanity test for which the errors will be reported.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just sounds somewhat arbitrary, from what I can see it's only in the actual error message. Just thinking that it should be the same for all or based on the test name to save passing another arg that is just used for reporting. I see it's just placed before the actual sanity issue like;

# from https://app.shippable.com/github/ansible/ansible/runs/133262/1/tests
test/sanity/pslint/ignore.txt:104:1: AnsibleTest Duplicate code 'PSAvoidUsingEmptyCatchBlock' for path 'lib/ansible/modules/windows/win_find.ps1' first found on line 101

I can see in this case it matches the PSAvoidUsingEmptyCatchBlock but considering it's placed before the actual sanity issue (Duplicate code...) it sounds like it should be based on the sanity test name. Even so when collections merge this into the 1 file wouldn't any test that accesses the file also produce a similar error that may or may not be related to it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the codes themselves are arbitrary. Although they're only for display purposes, I expect them to be included in documentation for the sanity tests at some point.

The argument cannot be removed since we need to know if the test uses codes or not when parsing the ignores. It could be made into a bool instead, if we didn't want to customize the code for each test.

I chose to match the style of codes used in each test so that results were more visually consistent within a given test. Here are some examples:

pylint
ERROR: lib/ansible/modules/system/ping.py:14:0: bare-except No exception type(s) specified
ERROR: test/sanity/pylint/ignore.txt:2:1: ansible-test Ignoring 'blacklisted-name' on 'lib/ansible/modules/system/ping.py' is unnecessary
pep8
ERROR: lib/ansible/modules/system/ping.py:14:1: E722 do not use bare 'except'
ERROR: test/sanity/pep8/skip.txt:4:1: A100 File 'does/not/exist.py' does not exist

If we can come up with code(s) that are more clear than the current implementation in the PR, I'm fine switching to something else. I just figured that having test results with mixed codes like "E772" and "ansible-test" would look a bit strange, particularly if they end up in tables or other columnar output.

As for the error handling when everything is combined into a single file, there will be a new sanity test that reports issues with the file itself, so some of the messages will move to that test. That will avoid issues with unrelated errors. However, there will always be sanity test specific messages from ansible-test that will appear within individual test results.

@mattclay mattclay merged commit 44a2627 into ansible:devel Jul 23, 2019
Testing Collections automation moved this from In progress to Done Jul 23, 2019
@mattclay mattclay deleted the at-collections-common-sanity branch July 23, 2019 20:31
@ansible ansible locked and limited conversation to collaborators Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 core_review In order to be merged, this PR must follow the core review workflow. feature This issue/PR relates to a feature request. has_issue support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants