clean up tests so they pass locally + in the CI (#704)

This commit is contained in:
tamarrow
2016-08-04 17:31:09 -07:00
committed by GitHub
parent 04f257e561
commit 1431a48daf
4 changed files with 68 additions and 54 deletions

View File

@@ -101,17 +101,37 @@ Running Tests
Setup
#####
Tox, our test runner, tests against both Python 2.7 and Python 3.4
environments. We have a set of tests in the :code:`dcos` package (root
directory) and in the :code:`dcoscli` package (:code:`cli` directory). When
running the tests describe below change directory to one of those two and
follow the instructions.
Tox, our test runner, tests against Python 3.4. We have a set of tests in
the :code:`dcos` package (root directory) and in the :code:`dcoscli` package
(:code:`cli` directory). When running the tests describe below change
directory to one of those two and follow the instructions.
Initialization
#######
The `config` integration tests use static config files. To run these tests
make sure you set owner only permissions on these files:
:code:`chmod 600 cli/tests/data/dcos.toml`
:code:`chmod 600 cli/tests/config/parse_error.toml`
The :code:`node` integration tests use :code:`CLI_TEST_SSH_KEY_PATH` for ssh
credentials to your cluster.
The :code:`ssl` integration tests resolve :code:`dcos.snakeoil.mesosphere.com`
to test SSL certs. To run this test suite be sure to add this resolution to your
:code:`/etc/hosts` file:
:code:`echo "dcos/cluster/url dcos.snakeoil.mesosphere.com" >> /etc/hosts`
Running
#######
Tox will run unit and integration tests in both Python environments using a
temporarily created virtualenv.
Tox will run unit and integration tests in Python 3.4 using a temporarily
created virtualenv.
You can set :code:`DCOS_CONFIG` to a config file that points to a DC/OS
cluster you want to use for integration tests. This defaults to

View File

@@ -10,4 +10,7 @@ else
fi
echo "Virtualenv activated."
chmod 600 $BASEDIR/tests/data/dcos.toml
chmod 600 $BASEDIR/tests/data/config/parse_error.toml
tox

View File

@@ -1,5 +1,5 @@
[core]
timeout = 5
reporting = false
dcos_url = "http://dcos.snakeoil.mesosphere.com"
ssl_verify = "false"
timeout = 5
reporting = false

View File

@@ -75,20 +75,14 @@ def test_invalid_dcos_url(env):
def test_get_top_property(env):
stderr = (
b"Property 'core' doesn't fully specify a value - "
b"possible properties are:\n"
b"core.dcos_acs_token\n"
b"core.dcos_url\n"
b"core.reporting\n"
b"core.ssl_verify\n"
b"core.timeout\n"
)
returncode, stdout, stderr = exec_command(
['dcos', 'config', 'show', 'core'], env=env)
assert_command(['dcos', 'config', 'show', 'core'],
stderr=stderr,
returncode=1,
env=env)
assert returncode == 1
assert stdout == b''
assert stderr.startswith(
b"Property 'core' doesn't fully specify a value - "
b"possible properties are:\n")
def test_set_package_sources_property():
@@ -179,21 +173,14 @@ def test_unset_output(env):
def test_unset_top_property(env):
stderr = (
b"Property 'core' doesn't fully specify a value - "
b"possible properties are:\n"
b"core.dcos_acs_token\n"
b"core.dcos_url\n"
b"core.reporting\n"
b"core.ssl_verify\n"
b"core.timeout\n"
)
returncode, stdout, stderr = exec_command(
['dcos', 'config', 'unset', 'core'], env=env)
assert_command(
['dcos', 'config', 'unset', 'core'],
returncode=1,
stderr=stderr,
env=env)
assert returncode == 1
assert stdout == b''
assert stderr.startswith(
b"Property 'core' doesn't fully specify a value - "
b"possible properties are:\n")
def test_validate(env):
@@ -266,26 +253,30 @@ def test_bad_port_fail_url_validation(env):
'http://localhost:bad_port/', env)
def test_dcos_acs_token_env_var(env):
env['DCOS_ACS_TOKEN'] = 'foobar'
msg = (b'Your core.dcos_acs_token is invalid. '
b'Please run: `dcos auth login`\n')
assert_command(['dcos', 'package', 'list'],
returncode=1,
stderr=msg,
env=env)
env.pop('DCOS_ACS_TOKEN')
def test_dcos_url_env_var(env):
env['DCOS_URL'] = 'http://foobar'
returncode, stdout, stderr = exec_command(
['dcos', 'service'], env=env)
assert returncode == 1
assert stdout == b''
assert stderr.startswith(
b'URL [http://foobar/mesos/master/state.json] is unreachable')
env.pop('DCOS_URL')
def test_dcos_dcos_acs_token_env_var(env):
env['DCOS_DCOS_ACS_TOKEN'] = 'foobar'
msg = (b'Your core.dcos_acs_token is invalid. '
b'Please run: `dcos auth login`\n')
assert_command(['dcos', 'package', 'list'],
returncode=1,
stderr=msg,
env=env)
env.pop('DCOS_DCOS_ACS_TOKEN')
def test_dcos_dcos_url_env_var(env):
env['DCOS_DCOS_URL'] = 'http://foobar'
returncode, stdout, stderr = exec_command(
['dcos', 'service'], env=env)
assert returncode == 1
assert stdout == b''
assert stderr.startswith(
b'URL [http://foobar/mesos/master/state.json] is unreachable')
env.pop('DCOS_DCOS_URL')
@pytest.mark.skipif(