-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Fix ctrl+c in pause module and make other improvements #40134
Conversation
now ctrl+c works in most scenarios: - naked: - pause: - with prompt - pause: prompt=hi - time wait - pause: seconds=60 - time wait with prompt - pause: seconds=60 prompt=hi removed redundant seconds if fixes ansible#35372
The test
The test
|
|
||
export ANSIBLE_ROLES_PATH=./roles | ||
|
||
python runme.py -i ../../inventory "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need a runme.sh
just to run runme.py
, since ansible-test will execute runme.py
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, to avoid having to install pexpect
for every integration test run via integration.txt
, it may be better to keep this for now and install pexepect
via pip here rather than using integration.txt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for answering that! I was going to ask you about that today but you beat me to it.
PEP8 fixes in test-pause.py
@mattclay One thing I've noticed is that inside the container I don't have a tty to query for the appropriate
|
The test
|
Use six from ansible.module_utils.six Use try except when trying to determien erase sequence to account for lack of TTY in containers
@samdoran I'll try adding |
@mattclay I was able to work around that with a The last test problem I need to solve is that I am testing aborting the play interactively, which causes the tests to report failure (well, unstable actually). I thought I put the correct string in the task name, but that doesn't seem to fix it. This may be different than other tests in that I am actually aborting the play, but I'm not sure. |
@samdoran Your latest changes to use |
It's good that you have a work around, because both |
Thanks for looking into it. |
Accept two digit precision for pause length in test Check for seconds when seconds is specificed, minutes when minutes is specified
* Fix all cases with pause and ctrl+c - naked: - pause: - with prompt - pause: prompt=hi - time wait - pause: seconds=60 - time wait with prompt - pause: seconds=60 prompt=hi Fixes ansible#35372 * Use curses to control stdout * Use curses to clear lines on interactive input * Validate input for echo parameter and fail nicely if invalid * Add integration tests for pause module using pexpect * Use try except when trying to determine erase sequence to account for lack of TTY in containers in tests * Improve output validation for regular paus test * Accept two digit precision for pause length in test * Check for seconds when seconds is specificed, minutes when minutes is specified * Add test for no TTY mode Co-authored by: Toshio Kuratomi <a.badger@gmail.com> Co-authored by: Brian Coca <brian.coca+git@gmail.com> (cherry picked from commit 1c20029)
* Fix all cases with pause and ctrl+c - naked: - pause: - with prompt - pause: prompt=hi - time wait - pause: seconds=60 - time wait with prompt - pause: seconds=60 prompt=hi Fixes ansible#35372 * Use curses to control stdout * Use curses to clear lines on interactive input * Validate input for echo parameter and fail nicely if invalid * Add integration tests for pause module using pexpect * Use try except when trying to determine erase sequence to account for lack of TTY in containers in tests * Improve output validation for regular paus test * Accept two digit precision for pause length in test * Check for seconds when seconds is specificed, minutes when minutes is specified * Add test for no TTY mode Co-authored by: Toshio Kuratomi <a.badger@gmail.com> Co-authored by: Brian Coca <brian.coca+git@gmail.com>
* Fix all cases with pause and ctrl+c - naked: - pause: - with prompt - pause: prompt=hi - time wait - pause: seconds=60 - time wait with prompt - pause: seconds=60 prompt=hi Fixes ansible#35372 * Use curses to control stdout * Use curses to clear lines on interactive input * Validate input for echo parameter and fail nicely if invalid * Add integration tests for pause module using pexpect * Use try except when trying to determine erase sequence to account for lack of TTY in containers in tests * Improve output validation for regular paus test * Accept two digit precision for pause length in test * Check for seconds when seconds is specificed, minutes when minutes is specified * Add test for no TTY mode Co-authored by: Toshio Kuratomi <a.badger@gmail.com> Co-authored by: Brian Coca <brian.coca+git@gmail.com>
* Fix all cases with pause and ctrl+c - naked: - pause: - with prompt - pause: prompt=hi - time wait - pause: seconds=60 - time wait with prompt - pause: seconds=60 prompt=hi Fixes ansible#35372 * Use curses to control stdout * Use curses to clear lines on interactive input * Validate input for echo parameter and fail nicely if invalid * Add integration tests for pause module using pexpect * Use try except when trying to determine erase sequence to account for lack of TTY in containers in tests * Improve output validation for regular paus test * Accept two digit precision for pause length in test * Check for seconds when seconds is specificed, minutes when minutes is specified * Add test for no TTY mode Co-authored by: Toshio Kuratomi <a.badger@gmail.com> Co-authored by: Brian Coca <brian.coca+git@gmail.com>
SUMMARY
Fixes #35372
Ctrl + C works in all scenarios.
Use
curses
to control stdout to avoid displaying control characters on screen and make interactive input more user friendly.Validate the
echo
parameter and ensure it is always cast as abool
.Add integration tests using
pexpect
.Supercedes #38049
ISSUE TYPE
COMPONENT NAME
pause.py
ANSIBLE VERSION