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

AWS SSM Connection Plugin Unit Tests #53320

Open
wants to merge 29 commits into
base: devel
from

Conversation

Projects
None yet
7 participants
@deepsvc
Copy link

deepsvc commented Mar 5, 2019

SUMMARY

This Pull Request covers the unit tests for AWS SSM Connection Plugin, introduced in the PR #49652

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

connection/aws_ssm

ADDITIONAL INFORMATION

This PR adds Unit Tests for AWS SSM Connection Plugin.

For execution following command can be used:

test/runner/ansible-test units --tox --python 2.7 test/units/plugins/connection/test_aws_ssm.py```
@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 5, 2019

The test ansible-test sanity --test pylint [explain] failed with 10 errors:

test/units/plugins/connection/test_aws_ssm.py:51:35: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                    ^
test/units/plugins/connection/test_aws_ssm.py:51:39: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                        ^
test/units/plugins/connection/test_aws_ssm.py:51:43: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                            ^
test/units/plugins/connection/test_aws_ssm.py:51:47: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                                ^
test/units/plugins/connection/test_aws_ssm.py:51:51: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                                    ^
test/units/plugins/connection/test_aws_ssm.py:51:55: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                                        ^
test/units/plugins/connection/test_aws_ssm.py:51:59: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                                            ^
test/units/plugins/connection/test_aws_ssm.py:51:63: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                                                ^
test/units/plugins/connection/test_aws_ssm.py:51:67: bad-whitespace Exactly one space required after comma         r_choice.side_effect = ['a','a','a','a','a','b','b','b','b','b']                                                                    ^
test/units/plugins/connection/test_aws_ssm.py:120:48: bad-whitespace Exactly one space required after comma         conn.get_option.side_effect = ["i-12345","/abc", "pqr"]                                                 ^

The test ansible-test sanity --test pep8 [explain] failed with 14 errors:

test/units/plugins/connection/test_aws_ssm.py:19:1: E303 too many blank lines (4)
test/units/plugins/connection/test_aws_ssm.py:45:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:51:36: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:40: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:44: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:48: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:52: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:56: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:60: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:64: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:51:68: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:95:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:111:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:120:49: E231 missing whitespace after ','

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 5, 2019

The test ansible-test sanity --test pep8 [explain] failed with 4 errors:

test/units/plugins/connection/test_aws_ssm.py:16:1: E302 expected 2 blank lines, found 1
test/units/plugins/connection/test_aws_ssm.py:42:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:92:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:108:5: E303 too many blank lines (2)

click here for bot help

@mattclay

This comment has been minimized.

Copy link
Member

mattclay commented Mar 6, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 7, 2019

@deepsvc this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@deepsvc

This comment has been minimized.

Copy link
Author

deepsvc commented Mar 7, 2019

@mattclay Hi, I fixed that import issue, and the current issue is with Python 2.6 version. As plugin only has support for Python 2.7. Unit tests also only supports for that. Can you please advise for this?

psharkey and others added some commits Dec 10, 2018

new connection plugin aws_ssm
new connection plugin aws_ssm

Return code may be at the end of the last command output line.

Marking regex.
Adding timeout parameter - aws_ssm_timeout
Default 10 second timeout (https://docs.ansible.com/ansible/2.4/intro_configuration.html#timeout) is marginal.
This avoids changing this default and allowing the SSM timeout to be controlled via inventory.
This change wraps commands so commands which may never return do timeout.
Removing unused code, cleanup logic.
Reduce mark length - 52^26 should be plenty
Be explicit about subprocess.Popen options
Simplify if/else for mark end
_stdin_readline is not used now

@deepsvc deepsvc force-pushed the Flux7Labs:aws_ssm-connection-plugin-unit-test branch from 2cb9f8a to e882253 Mar 7, 2019

@mattclay

This comment has been minimized.

Copy link
Member

mattclay commented Mar 7, 2019

@deepsvc You can use skipif to skip tests on Python 2.6.

See: https://docs.pytest.org/en/latest/skipping.html#id1

@ansibot ansibot removed the ci_verified label Mar 13, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 13, 2019

The test ansible-test sanity --test pylint [explain] failed with 13 errors:

test/units/plugins/connection/test_aws_ssm.py:33:40: bad-whitespace Exactly one space required around assignment         boto3.client('ssm').return_value=MagicMock()                                         ^
test/units/plugins/connection/test_aws_ssm.py:34:26: bad-whitespace Exactly one space required before assignment         conn.start_session= MagicMock()                           ^
test/units/plugins/connection/test_aws_ssm.py:35:24: bad-whitespace Exactly one space required before assignment         conn._session_id= MagicMock()                         ^
test/units/plugins/connection/test_aws_ssm.py:36:37: bad-whitespace Exactly one space required around assignment         conn._session_id.return_value='s1'                                      ^
test/units/plugins/connection/test_aws_ssm.py:106:42: bad-whitespace Exactly one space required after comma         conn.get_option.side_effect = ['1','2','3','4','5']                                           ^
test/units/plugins/connection/test_aws_ssm.py:106:46: bad-whitespace Exactly one space required after comma         conn.get_option.side_effect = ['1','2','3','4','5']                                               ^
test/units/plugins/connection/test_aws_ssm.py:106:50: bad-whitespace Exactly one space required after comma         conn.get_option.side_effect = ['1','2','3','4','5']                                                   ^
test/units/plugins/connection/test_aws_ssm.py:106:54: bad-whitespace Exactly one space required after comma         conn.get_option.side_effect = ['1','2','3','4','5']                                                       ^
test/units/plugins/connection/test_aws_ssm.py:108:43: bad-whitespace Exactly one space required after comma         conn._get_url.side_effect = ['url1','url2']                                            ^
test/units/plugins/connection/test_aws_ssm.py:110:39: bad-whitespace Exactly one space required before assignment         boto3.client('s3').return_value= MagicMock()                                        ^
test/units/plugins/connection/test_aws_ssm.py:122:0: trailing-whitespace Trailing whitespace
test/units/plugins/connection/test_aws_ssm.py:138:44: bad-whitespace Exactly one space required around assignment         conn._terminate_session.return_value=''                                             ^
test/units/plugins/connection/test_aws_ssm.py:140:37: bad-whitespace Exactly one space required before assignment         conn._session_id.return_value= 'a'                                      ^

The test ansible-test sanity --test pep8 [explain] failed with 14 errors:

test/units/plugins/connection/test_aws_ssm.py:33:41: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:34:27: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:35:25: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:36:38: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:106:43: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:106:47: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:106:51: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:106:55: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:108:44: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:110:40: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:122:1: W293 blank line contains whitespace
test/units/plugins/connection/test_aws_ssm.py:123:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:138:45: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:140:38: E225 missing whitespace around operator

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 13, 2019

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

test/units/plugins/connection/test_aws_ssm.py:108:43: bad-whitespace Exactly one space required after comma         conn._get_url.side_effect = ['url1','url2']                                            ^
test/units/plugins/connection/test_aws_ssm.py:121:0: trailing-whitespace Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

test/units/plugins/connection/test_aws_ssm.py:108:44: E231 missing whitespace after ','
test/units/plugins/connection/test_aws_ssm.py:121:1: W293 blank line contains whitespace

click here for bot help

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 14, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:0: syntax-error unexpected indent (<unknown>, line 1)

The test ansible-test sanity --test compile --python 2.6 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:4: SyntaxError: from io import StringIO

The test ansible-test sanity --test compile --python 2.7 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:4: SyntaxError: from io import StringIO

The test ansible-test sanity --test compile --python 3.5 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:4: SyntaxError: from io import StringIO

The test ansible-test sanity --test compile --python 3.6 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:4: SyntaxError: from io import StringIO

The test ansible-test sanity --test compile --python 3.7 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:4: SyntaxError: from io import StringIO

The test ansible-test sanity --test compile --python 3.8 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:1:4: SyntaxError: from io import StringIO

The test ansible-test sanity --test pep8 [explain] failed with 6 errors:

test/units/plugins/connection/test_aws_ssm.py:1:5: E113 unexpected indentation
test/units/plugins/connection/test_aws_ssm.py:17:5: E303 too many blank lines (2)
test/units/plugins/connection/test_aws_ssm.py:75:16: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:76:23: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:77:19: E225 missing whitespace around operator
test/units/plugins/connection/test_aws_ssm.py:126:1: W293 blank line contains whitespace

click here for bot help

agaur123 added some commits Mar 14, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 14, 2019

The test ansible-test sanity --test pylint [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:123:0: trailing-whitespace Trailing whitespace

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

test/units/plugins/connection/test_aws_ssm.py:123:1: W293 blank line contains whitespace

click here for bot help

agaur123 added some commits Mar 14, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Mar 14, 2019

The test ansible-test sanity --test pylint [explain] failed with 2 errors:

test/units/plugins/connection/test_aws_ssm.py:16:41: bad-whitespace Exactly one space required after comma @pytest.mark.skipif(sys.version_info < (2,7), reason="requires python 2.7 or higher")                                          ^
test/units/plugins/connection/test_aws_ssm.py:84:8: undefined-variable Undefined variable 'skipif'

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

test/units/plugins/connection/test_aws_ssm.py:16:1: E302 expected 2 blank lines, found 1
test/units/plugins/connection/test_aws_ssm.py:16:42: E231 missing whitespace after ','

click here for bot help

agaur123 added some commits Mar 14, 2019

@ansibot ansibot added core_review and removed needs_revision labels Mar 14, 2019

@agaur123

This comment has been minimized.

Copy link

agaur123 commented Mar 18, 2019

Hey @mattclay, we have reviewed all the test cases and they are running absolutely fine. About the issue with Python 2.6, so that we also have fixed. Can you please review it.

@mattclay

This comment has been minimized.

Copy link
Member

mattclay commented Mar 20, 2019

These tests should be in the same PR as the connection plugin since it hasn't been merged yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.