Skip to content

Commit

Permalink
Add a test against infinite prompt during cluster setup
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bamarni committed Aug 10, 2017
1 parent e0b0726 commit 9e5911e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cli/tests/integrations/helpers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dcos import config, http


def exec_command(cmd, env=None, stdin=None):
def exec_command(cmd, env=None, stdin=None, timeout=None):
"""Execute CLI command
:param cmd: Program and arguments
Expand All @@ -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)]

# We should always print the stdout and stderr
print('STDOUT: {}'.format(_truncate(stdout.decode('utf-8'))))
Expand Down
14 changes: 14 additions & 0 deletions cli/tests/integrations/test_cluster.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import subprocess

from .helpers.common import assert_command, exec_command

Expand Down Expand Up @@ -43,3 +44,16 @@ def test_rename():

# rename back to original name
assert_command(['dcos', 'cluster', 'rename', new_name, name])


def test_setup_noninteractive():
"""
Run "dcos cluster setup" command as non-interactive with a 15 seconds timeout.
This makes sure the process doesn't prompt for input forever (DCOS-15590).
"""

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

assert returncode == 1
assert b"'' is not a valid response" in stdout

0 comments on commit 9e5911e

Please sign in to comment.