summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/.coveragerc15
-rw-r--r--utils/README.md41
-rw-r--r--utils/setup.cfg27
-rw-r--r--utils/setup.py6
-rw-r--r--utils/src/ooinstall/cli_installer.py20
-rw-r--r--utils/src/ooinstall/oo_config.py17
-rw-r--r--utils/test-requirements.txt3
-rw-r--r--utils/tox.ini5
8 files changed, 56 insertions, 78 deletions
diff --git a/utils/.coveragerc b/utils/.coveragerc
index e1d918755..551e13192 100644
--- a/utils/.coveragerc
+++ b/utils/.coveragerc
@@ -1,5 +1,18 @@
[run]
-omit=
+branch = True
+omit =
*/lib/python*/site-packages/*
*/lib/python*/*
/usr/*
+ setup.py
+ # TODO(rhcarvalho): this is used to ignore test files from coverage report.
+ # We can make this less generic when we stick with a single test pattern in
+ # the repo.
+ test_*.py
+ *_tests.py
+
+[report]
+fail_under = 73
+
+[html]
+directory = cover
diff --git a/utils/README.md b/utils/README.md
index c37ab41e6..7aa045ae4 100644
--- a/utils/README.md
+++ b/utils/README.md
@@ -1,56 +1,61 @@
-# Running Tests (NEW)
+# Running Tests
Run the command:
make ci
-to run an array of unittests locally.
+to run tests and linting tools.
Underneath the covers, we use [tox](http://readthedocs.org/docs/tox/) to manage virtualenvs and run
tests. Alternatively, tests can be run using [detox](https://pypi.python.org/pypi/detox/) which allows
-for running tests in parallel
-
+for running tests in parallel.
```
pip install tox detox
```
List the test environments available:
+
```
tox -l
```
Run all of the tests with:
+
```
tox
```
Run all of the tests in parallel with detox:
+
```
detox
```
-Running a particular test environment (python 2.7 flake8 tests in this case):
+Run a particular test environment:
+
```
-tox -e py27-ansible22-flake8
+tox -e py27-flake8
```
-Running a particular test environment in a clean virtualenv (python 3.5 pylint
-tests in this case):
+Run a particular test environment in a clean virtualenv:
+
```
-tox -r -e py35-ansible22-pylint
+tox -r -e py35-pylint
```
If you want to enter the virtualenv created by tox to do additional
-testing/debugging (py27-flake8 env in this case):
+testing/debugging:
+
```
-source .tox/py27-ansible22-flake8/bin/activate
+source .tox/py27-flake8/bin/activate
```
You will get errors if the log files already exist and can not be
written to by the current user (`/tmp/ansible.log` and
`/tmp/installer.txt`). *We're working on it.*
+
# Running From Source
You will need to setup a **virtualenv** to run from source:
@@ -66,17 +71,3 @@ The virtualenv `bin` directory should now be at the start of your
You can exit the virtualenv with:
$ deactivate
-
-# Testing (OLD)
-
-*This section is deprecated, but still works*
-
-First, run the **virtualenv setup steps** described above.
-
-Install some testing libraries: (we cannot do this via setuptools due to the version virtualenv bundles)
-
-$ pip install mock nose
-
-Then run the tests with:
-
-$ oo-install/bin/nosetests
diff --git a/utils/setup.cfg b/utils/setup.cfg
index 862dffd7b..d730cd3b4 100644
--- a/utils/setup.cfg
+++ b/utils/setup.cfg
@@ -4,15 +4,8 @@
# will need to generate wheels for each Python version that you support.
universal=1
-[nosetests]
-verbosity=2
-with-coverage=1
-cover-html=1
-cover-inclusive=1
-cover-min-percentage=70
-cover-erase=1
-detailed-errors=1
-cover-branches=1
+[aliases]
+test=pytest
[flake8]
max-line-length=120
@@ -21,3 +14,19 @@ ignore=E501
[lint]
lint_disable=fixme,locally-disabled,file-ignored,duplicate-code
+
+[tool:pytest]
+testpaths = test
+norecursedirs =
+ .*
+ __pycache__
+python_files =
+ # TODO(rhcarvalho): rename test files to follow a single pattern. "test*.py"
+ # is Python unittest's default, while pytest discovers both "test_*.py" and
+ # "*_test.py" by default.
+ test_*.py
+ *_tests.py
+addopts =
+ --cov=.
+ --cov-report=term
+ --cov-report=html
diff --git a/utils/setup.py b/utils/setup.py
index 3518581e7..238c64c19 100644
--- a/utils/setup.py
+++ b/utils/setup.py
@@ -40,7 +40,7 @@ setup(
# simple. Or you can use find_packages().
#packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
packages=['ooinstall'],
- package_dir={'ooinstall': 'src/ooinstall'},
+ package_dir={'': 'src'},
# List run-time dependencies here. These will be installed by pip when
@@ -65,10 +65,6 @@ setup(
'ooinstall': ['ansible.cfg', 'ansible-quiet.cfg', 'ansible_plugins/*'],
},
- tests_require=['nose'],
-
- test_suite='nose.collector',
-
# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
# pip to create the appropriate form of executable for the target platform.
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index b787741d7..a6d784dea 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -72,12 +72,6 @@ You might want to override the default subdomain used for exposed routes. If you
return click.prompt('New default subdomain (ENTER for none)', default='')
-def list_hosts(hosts):
- hosts_idx = range(len(hosts))
- for idx in hosts_idx:
- click.echo(' {}: {}'.format(idx, hosts[idx]))
-
-
def collect_hosts(oo_cfg, existing_env=False, masters_set=False, print_summary=True):
"""
Collect host information from user. This will later be filled in using
@@ -656,20 +650,6 @@ https://docs.openshift.com/enterprise/latest/admin_guide/install/prerequisites.h
return oo_cfg
-def get_role_variable(oo_cfg, role_name, variable_name):
- try:
- target_role = next(role for role in oo_cfg.deployment.roles if role.name is role_name)
- target_variable = target_role.variables[variable_name]
- return target_variable
- except (StopIteration, KeyError):
- return None
-
-
-def set_role_variable(oo_cfg, role_name, variable_name, variable_value):
- target_role = next(role for role in oo_cfg.deployment.roles if role.name is role_name)
- target_role[variable_name] = variable_value
-
-
def collect_new_nodes(oo_cfg):
click.clear()
click.echo('*** New Node Configuration ***')
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index cf14105af..c3501c018 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -126,15 +126,6 @@ class Host(object):
""" Does this host have the etcd role """
return 'etcd' in self.roles
- def is_etcd_member(self, all_hosts):
- """ Will this host be a member of a standalone etcd cluster. """
- if not self.is_master():
- return False
- masters = [host for host in all_hosts if host.is_master()]
- if len(masters) > 1:
- return True
- return False
-
def is_dedicated_node(self):
""" Will this host be a dedicated node. (not a master) """
return self.is_node() and not self.is_master()
@@ -185,7 +176,7 @@ class Deployment(object):
class OOConfig(object):
default_dir = os.path.normpath(
os.environ.get('XDG_CONFIG_HOME',
- os.environ['HOME'] + '/.config/') + '/openshift/')
+ os.environ.get('HOME', '') + '/.config/') + '/openshift/')
default_file = '/installer.cfg.yml'
def __init__(self, config_path):
@@ -436,12 +427,6 @@ class OOConfig(object):
def __str__(self):
return self.yaml()
- def get_host(self, name):
- for host in self.deployment.hosts:
- if host.connect_to == name:
- return host
- return None
-
def get_host_roles_set(self):
roles_set = set()
for host in self.deployment.hosts:
diff --git a/utils/test-requirements.txt b/utils/test-requirements.txt
index 699afc26a..b26e22a7e 100644
--- a/utils/test-requirements.txt
+++ b/utils/test-requirements.txt
@@ -2,7 +2,6 @@ ansible
# flake8 moved to before setuptools-lint to satisfy mccabe dependency issue
flake8
setuptools-lint
-nose
coverage
mock
PyYAML
@@ -12,3 +11,5 @@ pyOpenSSL
yamllint
tox
detox
+pytest
+pytest-cov
diff --git a/utils/tox.ini b/utils/tox.ini
index 1308f7505..2524923cb 100644
--- a/utils/tox.ini
+++ b/utils/tox.ini
@@ -11,6 +11,9 @@ deps =
-rtest-requirements.txt
py35-flake8: flake8-bugbear
commands =
+ # Needed to make detox work, since it ignores usedevelop
+ # https://github.com/tox-dev/tox/issues/180
+ unit: pip install -e .
+ unit: pytest {posargs}
flake8: python setup.py flake8
- unit: python setup.py nosetests
pylint: python setup.py lint