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

Config cleanup #3

Merged
merged 14 commits into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions conf/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@

This directory contains examples of configuration files required to run the
integration tests.

See full documentation of usmqe test configuration in `Test Configuration`_
document.

.. _`Test Configuraion`: https://github.com/Tendrl/usmqe-tests/blob/master/docs/test_configuration.rst
25 changes: 0 additions & 25 deletions conf/example_pytest.ini

This file was deleted.

File renamed without changes.
6 changes: 3 additions & 3 deletions conf/example_usm.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
log_level = DEBUG
username = <username>
password = <password>
url = https://example-usm3-server.usmqe.tendrl.org:10443
web_url = https://example-usm3-server.usmqe.tendrl.org
api_url = %(web_url):9393/api/1.0/
ca_cert = conf/tendrl_ca.crt

[raut]
SELENIUM_SERVER = None
[webstr]
77 changes: 74 additions & 3 deletions docs/test_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,78 @@
Test Configuraion
===================

USM QE Tests are executed under ``usmqe`` user account on QE Server
machine (see :ref:`qe-server-label` for more details).
USM QE integration tests are configurabe via these files:

TODO: include all the details here
* Main *pytest config file*: ``pytest.ini`` in root directory of ``usmqe-tests``
repository. This file contains main pytest configuration and default values
for main USMQE configuration options. Under normal cirsumstances one would
edit only ``USM_CONFIG`` and ``USM_HOST_CONFIG`` options, while all the
others usmqe default values should not be changed there.

* Ansible *host inventory file* (see an example in ``conf/example.hosts``),
which is used both by ansible and by USMQE inventory module to organize
machines into groups by it's role in test cluster.

* *usmqe config file* (see an example in ``conf/example_usm.ini``). You need
to provide mandatory values in this file to be able to run the tests.
Options configured there includes urls of web and api server, username and
password and so on.


Implementation Details
======================

Reading of both *usmqe config file* and *host inventory file* is implemented in
``plugin/usmqe_config.py`` module.

Management of *host inventory file* is handled by ``usmqe/inventory.py``
module. See an example of it's usage:

.. code-block:: python

import usmqe.inventory as inventory

for host in inventory.role2hosts("ceph_osd"):
print("check storage server {0}".format(host))


Example of test configuration
=============================

We assume that:

* *QE Server mahcine* has been configured as described in
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: "mahcine"

:ref:`qe-server-label`

* You have *host inventory file* for the test cluster, which has been already
deployed (our deployment automation should generate the inventory file
in the end of the process).

* You are logged as ``usmqe`` user on the QE Server

Now, you need to:

* Check that ``usmqe`` user has a private ssh key in ``~/.ssh/id_rsa`` file
(this is default location of ssh key specified in ``USM_KEYFILE`` option of
``pytest.ini``) and has it's public ssh key deployed on all machines of test
cluster.

* Store *host inventory file* in ``conf/clustername.hosts`` and specify this
path in ``USM_HOST_CONFIG`` option of ``pytest.ini``.

* Verify that ssh and ansible are configured so that one can reach all machines
from test cluster:

.. code-block:: console

[usmqe@qeserver ~]$ ansible -i conf/clustername.hosts -m ping -u root all

* Initiate new *usmqe config file*: ``cp conf/example_usm.ini conf/usm.ini``
and check that ``USM_CONFIG`` option of ``pytest.ini`` file points to this
file.

* Provide all mandatory options in *usm config file* initialized in a previous
step. This includes: ``username``, ``password``, ``web_url`` and ``api_url``.
The actuall list depends on the test suite you are going to run (eg. api
tests doesn't care about ``web_url`` while LDAP integration tests would need
to know address of the LDAP server).
26 changes: 9 additions & 17 deletions plugin/usmqe_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ def pytest_addoption(parser):
"""
Add ini options to be accepted by pytest.
"""
# defaults are specified in root pytest.ini file
parser.addini('USM_CONFIG', 'USM configuration')
parser.addini(
'USM_HOST_CONFIG', 'USM host configuration', default='sample.hosts')
parser.addini('USM_USERNAME', 'USM username for login', default='admin')
parser.addini('USM_HOST_CONFIG', 'USM host configuration')
parser.addini('USM_USERNAME', 'USM username for login')
parser.addini('USM_PASSWORD', 'USM password for login')
parser.addini('USM_URL', 'USM url')
parser.addini('USM_APIURL', 'USM url for api')
parser.addini(
'USM_LOG_LEVEL', 'USM log test level', default='logging.DEBUG')
parser.addini(
'USM_KEYFILE', 'USM key file for passwordless ssh',
default='~/.ssh/id_rsa')
parser.addini(
'USM_CA_CERT', 'USM use CA certificate', type='bool', default=False)
parser.addini('USM_WEB_URL', 'USM url for web')
parser.addini('USM_API_URL', 'USM url for api')
parser.addini('USM_LOG_LEVEL', 'USM log test level')
parser.addini('USM_KEYFILE', 'USM key file for passwordless ssh')
parser.addini('USM_CA_CERT', 'USM use CA certificate', type='bool')


@pytest.fixture(autouse=True, scope="session")
Expand Down Expand Up @@ -68,7 +64,7 @@ def load_config():
conf = ConfigParser()
conf.read(pytest.config.getini("USM_CONFIG"))

for section in ('raut', 'usm', 'ldap'):
for section in ('webstr', 'usm', 'ldap'):
if section in conf.sections():
for key, value in conf.items(section):
if section == 'usm':
Expand All @@ -83,7 +79,3 @@ def load_config():
pytest.config._inicache[name] = value
else:
pytest.config._inicache[name] = override_value

if not pytest.config.getini("USM_APIURL"):
pytest.config._inicache["USM_APIURL"] = \
"{}/api/v1/".format(pytest.config.getini("USM_URL"))
45 changes: 45 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[pytest]

#
# USM QE config section (see plugin/usmqe_config.py)
#

# Path to the main usmqe config file (that is the file one should edit to
# change configuration of usm qe tests).
USM_CONFIG = conf/usm.ini

# Path to the host inventory file (list of all machines of a test cluster
# grouped into roles). This file is used both by ansible and usm qe tests.
USM_HOST_CONFIG = conf/usm.hosts

# Predefined usmqe configuration values.
# You should not change them here, but edit ini file referenced in USM_CONFIG
#
# For add hoc changes, one can redefine the values from the command line:
#
# $ py.test -o USM_USERNAME=admin2

# usm config group
USM_LOG_LEVEL = logging.DEBUG
USM_USERNAME = admin
USM_PASSWORD =
USM_WEB_URL =
USM_API_URL =
USM_CA_CERT = False
USM_KEYFILE = "~/.ssh/id_rsa"

# webstr config group: webstr specific options
USM_WEBSTR_SELENIUM_SERVER =

# ldap config group: LDAP specific options
USM_LDAP_SERVER = None
USM_LDAP_PORT = 389
USM_LDAP_BASE = None
USM_LDAP_DOMAINADMIN = None
USM_LDAP_PASSWORD = None
USM_LDAP_UID = "cn"
USM_LDAP_FIRSTNAME = "displayName"
USM_LDAP_LASTNAME = "sn"
USM_LDAP_DISPLAYNAME = None
USM_LDAP_EMAIL = "mail"
USM_LDAP_USER_FILE = None