Skip to content

Instantly share code, notes, and snippets.

@titom73
Created November 5, 2019 07:32
Show Gist options
  • Save titom73/c9ae3e05dcc2e5f061c9887943265471 to your computer and use it in GitHub Desktop.
Save titom73/c9ae3e05dcc2e5f061c9887943265471 to your computer and use it in GitHub Desktop.
ansible-test sanity results
$ ansible-test sanity
WARNING: Command "git submodule status --recursive ." returned exit status 1.
>>> Standard Error
error: pathspec '.' did not match any file(s) known to git
WARNING: PyYAML will be slow due to installation without libyaml support for interpreter: /usr/local/bin/python3.7
Running sanity test 'action-plugin-docs' with Python 3.7
Running sanity test 'ansible-doc' with Python 3.7
ERROR: Command "ansible-doc -t module arista.cvp.cv_configlet arista.cvp.cv_container arista.cvp.cv_device arista.cvp.cv_facts arista.cvp.cv_image arista.cvp.cv_task" returned exit status 1.
>>> Standard Error
ERROR! module arista.cvp.cv_device missing documentation (or could not parse documentation): invalid syntax (<unknown>, line 130)
WARNING: Skipping sanity test 'compile' on Python 2.6 due to missing interpreter.
Running sanity test 'compile' with Python 2.7
WARNING: Skipping sanity test 'compile' on Python 3.5 due to missing interpreter.
WARNING: Skipping sanity test 'compile' on Python 3.6 due to missing interpreter.
Running sanity test 'compile' with Python 3.7
ERROR: Found 2 compile issue(s) on python 3.7 which need to be resolved:
ERROR: plugins/modules/cv_device.py:130:25: SyntaxError: except CvpLoginError, e:
ERROR: plugins/modules/cv_image.py:93:25: SyntaxError: except CvpLoginError, e:
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/compile.html
WARNING: Skipping sanity test 'compile' on Python 3.8 due to missing interpreter.
Running sanity test 'empty-init' with Python 3.7
Running sanity test 'future-import-boilerplate' with Python 3.7
ERROR: Found 11 future-import-boilerplate issue(s) which need to be resolved:
ERROR: plugins/module_utils/cv_api2018.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/module_utils/cv_api2019.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/module_utils/cv_client.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/module_utils/cv_client_errors.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/modules/cv_configlet.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/modules/cv_container.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/modules/cv_device.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/modules/cv_facts.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/modules/cv_image.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: plugins/modules/cv_task.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
ERROR: tests/output/.tmp/sanity/import/minimal-py27/bin/activate_this.py:0:0: missing: from __future__ import (absolute_import, division, print_function)
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/future-import-boilerplate.html
Running sanity test 'ignores'
WARNING: Skipping sanity test 'import' on Python 2.6 due to missing interpreter.
Running sanity test 'import' with Python 2.7
ERROR: Found 8 import issue(s) on python 2.7 which need to be resolved:
ERROR: plugins/module_utils/cv_api2019.py:39:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:99:0)
ERROR: plugins/module_utils/cv_client.py:99:0: traceback: ImportError: No module named requests
ERROR: plugins/modules/cv_configlet.py:95:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:99:0)
ERROR: plugins/modules/cv_container.py:111:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:99:0)
ERROR: plugins/modules/cv_device.py:107:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:99:0)
ERROR: plugins/modules/cv_facts.py:62:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:99:0)
ERROR: plugins/modules/cv_image.py:71:0: traceback: ImportError: No module named cvprac.cvp_client
ERROR: plugins/modules/cv_task.py:86:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:99:0)
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/import.html
WARNING: Skipping sanity test 'import' on Python 3.5 due to missing interpreter.
WARNING: Skipping sanity test 'import' on Python 3.6 due to missing interpreter.
Running sanity test 'import' with Python 3.7
ERROR: Found 6 import issue(s) on python 3.7 which need to be resolved:
ERROR: plugins/modules/cv_configlet.py:95:0: traceback: ImportError: cannot import name 'CvpClient' from 'ansible_collections.arista.cvp.plugins.module_utils.cv_client' (/Users/tgrimonet/Projects/ansible-devel/github/aristanetworks/upstream-ansible-cvp/ansible_collections/arista/cvp/plugins/module_utils/cv_client.py)
ERROR: plugins/modules/cv_container.py:111:0: traceback: ImportError: cannot import name 'CvpClient' from 'ansible_collections.arista.cvp.plugins.module_utils.cv_client' (/Users/tgrimonet/Projects/ansible-devel/github/aristanetworks/upstream-ansible-cvp/ansible_collections/arista/cvp/plugins/module_utils/cv_client.py)
ERROR: plugins/modules/cv_device.py:130:25: traceback: SyntaxError: invalid syntax
ERROR: plugins/modules/cv_facts.py:62:0: traceback: ImportError: cannot import name 'CvpClient' from 'ansible_collections.arista.cvp.plugins.module_utils.cv_client' (/Users/tgrimonet/Projects/ansible-devel/github/aristanetworks/upstream-ansible-cvp/ansible_collections/arista/cvp/plugins/module_utils/cv_client.py)
ERROR: plugins/modules/cv_image.py:93:25: traceback: SyntaxError: invalid syntax
ERROR: plugins/modules/cv_task.py:86:0: traceback: ImportError: cannot import name 'CvpClient' from 'ansible_collections.arista.cvp.plugins.module_utils.cv_client' (/Users/tgrimonet/Projects/ansible-devel/github/aristanetworks/upstream-ansible-cvp/ansible_collections/arista/cvp/plugins/module_utils/cv_client.py)
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/import.html
WARNING: Skipping sanity test 'import' on Python 3.8 due to missing interpreter.
Running sanity test 'line-endings' with Python 3.7
ERROR: Found 1 line-endings issue(s) which need to be resolved:
ERROR: plugins/modules/cv_container.py:0:0: use "\n" for line endings instead of "\r\n"
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/line-endings.html
Running sanity test 'metaclass-boilerplate' with Python 3.7
ERROR: Found 11 metaclass-boilerplate issue(s) which need to be resolved:
ERROR: plugins/module_utils/cv_api2018.py:0:0: missing: __metaclass__ = type
ERROR: plugins/module_utils/cv_api2019.py:0:0: missing: __metaclass__ = type
ERROR: plugins/module_utils/cv_client.py:0:0: missing: __metaclass__ = type
ERROR: plugins/module_utils/cv_client_errors.py:0:0: missing: __metaclass__ = type
ERROR: plugins/modules/cv_configlet.py:0:0: missing: __metaclass__ = type
ERROR: plugins/modules/cv_container.py:0:0: missing: __metaclass__ = type
ERROR: plugins/modules/cv_device.py:0:0: missing: __metaclass__ = type
ERROR: plugins/modules/cv_facts.py:0:0: missing: __metaclass__ = type
ERROR: plugins/modules/cv_image.py:0:0: missing: __metaclass__ = type
ERROR: plugins/modules/cv_task.py:0:0: missing: __metaclass__ = type
ERROR: tests/output/.tmp/sanity/import/minimal-py27/bin/activate_this.py:0:0: missing: __metaclass__ = type
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/metaclass-boilerplate.html
Running sanity test 'no-assert' with Python 3.7
Running sanity test 'no-basestring' with Python 3.7
ERROR: Found 1 no-basestring issue(s) which need to be resolved:
ERROR: plugins/modules/cv_container.py:163:10: do not use `isinstance(s, basestring)`
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/no-basestring.html
Running sanity test 'no-dict-iteritems' with Python 3.7
Running sanity test 'no-dict-iterkeys' with Python 3.7
Running sanity test 'no-dict-itervalues' with Python 3.7
Running sanity test 'no-get-exception' with Python 3.7
Running sanity test 'no-illegal-filenames' with Python 3.7
Running sanity test 'no-main-display' with Python 3.7
Running sanity test 'no-smart-quotes' with Python 3.7
Running sanity test 'no-unicode-literals' with Python 3.7
Running sanity test 'pep8' with Python 3.7
ERROR: Command "/usr/local/bin/python3.7 -m pycodestyle --max-line-length 160 --config /dev/null --ignore E402,E741,W503,W504 plugins/module_utils/__init__.py plugins/module_utils/cv_api2018.py plugins/module_utils/cv_api2019.py plugins/module_utils/cv_client.py plugins/module_utils/cv_client_errors.py plugins/modules/cv_configlet.py plugins/modules/cv_container.py plugins/modules/cv_device.py plugins/modules/cv_facts.py plugins/modules/cv_image.py plugins/modules/cv_task.py tests/output/.tmp/sanity/import/minimal-py27/bin/activate_this.py" returned exit status 1.
>>> Standard Error
/usr/local/opt/python/bin/python3.7: No module named pycodestyle
@titom73
Copy link
Author

titom73 commented Nov 5, 2019

cv_task

Command: ansible-test sanity --docker --requirements requirements.txt cv_task

Tests currently opened

Running sanity test 'import' with Python 2.7

ERROR: Found 1 import issue(s) on python 2.7 which need to be resolved:
ERROR: plugins/modules/cv_task.py:84:0: traceback: ImportError: No module named requests
$ ansible-test sanity cv_task --docker --python 2.7
Ignoring requests: markers \'python_version < \"2.7\"\' don\'t match your environment
[...]
Running sanity test 'compile' with Python 2.7
See documentation for help: https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/import.html
ERROR: Found 1 import issue(s) on python 2.7 which need to be resolved:
ERROR: plugins/modules/cv_task.py:34:0: traceback: ImportError: No module named requests (at plugins/module_utils/cv_client.py:97:0)

$ python --version
Python 2.7.16

$ pip list | grep requests
requests                      2.22.0

Running sanity test 'import' with Python 3.5 - 3.6

ERROR: Found 1 import issue(s) on python 3.5 which need to be resolved:
ERROR: plugins/modules/cv_task.py:84:0: traceback: ImportError: cannot import name 'CvpClient'

As per documentation (https://docs.ansible.com/ansible/2.9/dev_guide/testing/sanity/import.html) all import outside of lib/ansible/module_utils/ should have a try/except approach.

  • Try #1: print out a message if module_utils of the collection cannot be loaded
try:
    from ansible_collections.arista.cvp.plugins.module_utils.cv_client import CvpClient
    from ansible_collections.arista.cvp.plugins.module_utils.cv_client_errors import CvpLoginError, CvpApiError
except ImportError:
    print('Collection not defined')

ansible-test returns error like this:

ERROR: Found 1 import issue(s) on python 2.7 which need to be resolved:
ERROR: plugins/modules/cv_task.py:0:0: stdout: Collection not defined
  • Try #2: fallback to module approach for module_utils
try:
    from ansible_collections.arista.cvp.plugins.module_utils.cv_client import CvpClient
    from ansible_collections.arista.cvp.plugins.module_utils.cv_client_errors import CvpLoginError, CvpApiError
except ImportError:
    from ansible.module_utils.cv_client import CvpClient
    from ansible.module_utils.module_utils.cv_client_errors import CvpLoginError, CvpApiError

Create an ansible.cfg file with content like this:

module_utils = $PWD/plugins/modules/module_utils

ansible-test returns errors like this:

Running sanity test 'import' with Python 2.6
ERROR: Found 1 import issue(s) on python 2.6 which need to be resolved:
ERROR: plugins/modules/cv_task.py:38:0: traceback: ImportError: No module named cv_client

Running sanity test 'import' with Python 2.7
ERROR: Found 1 import issue(s) on python 2.7 which need to be resolved:
ERROR: plugins/modules/cv_task.py:38:0: traceback: ImportError: No module named cv_client

Running sanity test 'import' with Python 3.5
ERROR: Found 1 import issue(s) on python 3.5 which need to be resolved:
ERROR: plugins/modules/cv_task.py:38:0: traceback: ImportError: No module named 'ansible.module_utils.cv_client'

Running sanity test 'import' with Python 3.6
ERROR: Found 1 import issue(s) on python 3.6 which need to be resolved:
ERROR: plugins/modules/cv_task.py:38:0: traceback: ModuleNotFoundError: No module named 'ansible.module_utils.cv_client'

Running sanity test 'import' with Python 3.7
ERROR: Found 1 import issue(s) on python 3.7 which need to be resolved:
ERROR: plugins/modules/cv_task.py:38:0: traceback: ModuleNotFoundError: No module named 'ansible.module_utils.cv_client'

Running sanity test 'import' with Python 3.8
ERROR: Found 1 import issue(s) on python 3.8 which need to be resolved:
ERROR: plugins/modules/cv_task.py:38:0: traceback: ModuleNotFoundError: No module named 'ansible.module_utils.cv_client'

Running sanity test 'import' with Python 3.7 - 3.8

ERROR: Found 1 import issue(s) on python 3.7 which need to be resolved:
ERROR: plugins/modules/cv_task.py:34:0: traceback: ImportError: cannot import name 'CvpClient' from 'ansible_collections.arista.cvp.plugins.module_utils.cv_client' (/root/ansible/ansible_collections/arista/cvp/plugins/module_utils/cv_client.py)

Tests Fixed

  • Running sanity test 'metaclass-boilerplate' with Python 3.6: FIXED

  • Running sanity test 'pep8' with Python 3.6: FIXED

  • Running sanity test 'pylint' with Python 3.6: FIXED

  • Running sanity test 'shebang' with Python 3.6: FIXED

  • Running sanity test 'validate-modules' with Python 3.6: FIXED

  • Running sanity test 'yamllint' with Python 3.6: FIXED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment