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 a test against infinite prompt during cluster setup #1031

Merged
merged 4 commits into from Aug 23, 2017

Conversation

bamarni
Copy link
Contributor

@bamarni bamarni commented Aug 10, 2017

Prior to 1254a2f and when running
"dcos cluster setup" command as non-interactive, the process would run
and ask for user input forever.

This adds an integration test which fails if the process doesn't exit by
itself with an error within 30 seconds.

https://jira.mesosphere.com/browse/DCOS-15590

@bamarni bamarni changed the title Add a test against infinite prompt during cluster setup [WIP] Add a test against infinite prompt during cluster setup Aug 10, 2017
@bamarni bamarni force-pushed the DCOS-15590 branch 2 times, most recently from 885c37e to 26db8dc Compare August 11, 2017 09:16
@bamarni bamarni changed the title [WIP] Add a test against infinite prompt during cluster setup Add a test against infinite prompt during cluster setup Aug 11, 2017
@bamarni bamarni requested a review from klueska August 14, 2017 17:19

try:
returncode, stdout, _ = exec_command(
['dcos', 'cluster', 'setup',
Copy link
Contributor

Choose a reason for hiding this comment

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

All arguments at the same level should either be on the same line or split onto individual lines, e.g. not

returncode, stdout, _ = exec_command(
    ['dcos', 'cluster', 'setup',
        'https://dcos.snakeoil.mesosphere.com'],
    timeout=30, stdin=subprocess.DEVNULL)

but rather

returncode, stdout, _ = exec_command(
    ['dcos', 'cluster', 'setup', 'https://dcos.snakeoil.mesosphere.com'],
    timeout=30,
    stdin=subprocess.DEVNULL)

or

returncode, stdout, _ = exec_command(
    ['dcos',
     'cluster',
     'setup',
     'https://dcos.snakeoil.mesosphere.com'],
    timeout=30,
    stdin=subprocess.DEVNULL)

It makes it much easier to look at and understand without haveing to spend alot of time reading the code.

@@ -36,7 +36,7 @@ def exec_command(cmd, env=None, stdin=None):

# This is needed to get rid of '\r' from Windows's lines endings.
stdout, stderr = [std_stream.replace(b'\r', b'')
for std_stream in process.communicate()]
for std_stream in process.communicate(timeout=timeout)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, this would be split out into it's own separate commit. With the test change in its own commit as well.

This will make the subprocess getting killed if it doesn't terminate
within {timeout} seconds and an exception will be raised.
Prior to 1254a2f and when running
"dcos cluster setup" command as non-interactive, the process would run
and ask for user input forever.

This adds an integration test which fails if the process doesn't exit by
itself with an error within 15 seconds.

https://jira.mesosphere.com/browse/DCOS-15590
@bamarni
Copy link
Contributor Author

bamarni commented Aug 16, 2017

I've just updated the PR, I was missing a cleanup in the helper and added a link about this.

I just noticed that this test only passes if I use the cloud formation template for an EE cluster. However for an open source or custom cluster, the SHA256 fingerprint of cluster certificate bundle: message might not show up, and instead 3 tabs will get opened in the browser and the test will fail... All this noise can be very annoying, is there a way to avoid this? Maybe detect the kind of cluster, or I can make an integration test for another command which requires prompt but would fail more silently in such cases.

@bamarni bamarni closed this Aug 18, 2017
@bamarni bamarni reopened this Aug 18, 2017
@dcos dcos deleted a comment from mesosphere-ci Aug 22, 2017
@dcos dcos deleted a comment from mesosphere-ci Aug 22, 2017
@dcos dcos deleted a comment from mesosphere-ci Aug 22, 2017
@dcos dcos deleted a comment from mesosphere-ci Aug 22, 2017
@dcos dcos deleted a comment from mesosphere-ci Aug 22, 2017
@dcos dcos deleted a comment from mesosphere-ci Aug 22, 2017
@klueska
Copy link
Contributor

klueska commented Aug 23, 2017

ok to test

@@ -683,7 +697,8 @@ def test_install_no():
b'catalog-terms-conditions/#community-services\n'
b'A sample pre-installation message\n'
b'Continue installing? [yes/no] Exiting installation.\n'
)
),
returncode=1
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. At first I thought this seemed strange to return a 1 if the user supplied no as valid input. The reason being that the command exits cleanly, whether the user inputs yes or no (the only difference being whether the package was actually installed or not). I would have expected a 1 only if there was some internal error that made the command exit prematurely.

On thinking about it a bit more though, I agree with the semantics you have in place. Use a 0 to indicate that the command successfully carried out what you asked it to; use a 1 to indicate that it didn't.

An example demonstrating these semantics in a standard unix environment:

$ ls
foo        bar        baz
$ ls | grep foo
$ echo $?
0
$ ls | grep qux
$ echo $?
1

@klueska klueska merged commit 902f6a2 into dcos:master Aug 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants