It seems that we have dropped unit testing of our dynamic_inventory
some time ago. This patch aims to setup zuul tests using tox
and restore test functionality to make it passing with current codebase
Change-Id: I8ccee779fd629e8696ec2e12397b148b52cd0c73
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead
Change-Id: Ie36f12a4a6dd3c06b9ffd9bfb7bbb0106311820f
With the changes to how to test-requirements are installed, some new
failures are showing. This patch corrects them.
Change-Id: I641b167f1b7f5bb283d73481ed6185e1ccbd8ed3
Move the playbooks/inventory folder, group_vars, and host_vars to
inventory/ in the root of the OpenStack-Ansible repo. This helps better
organize the repo structure since playbooks/ will now only contain
playbooks, shared task files, and included repo package var files.
group_vars and host_vars are moved alongside the inventory since that's
the default place that Ansible expects those folders and to help better
prepare for Ansible 2.4 where multiple inventories can be loaded,
automatically including relative group and host var files.
Effected docs, scripts, and variables have been updated with the new
paths.
Change-Id: If50e2412c3fd6575d7041deb8ecc9480b04184cc
Change Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7 restructured the python
inventory generation code so that it would be possible to install it
with pip. This change removes (most) of the import path hacks and
switches to using a pip-installed version of osa_toolkit.
Of note, the path hacks are left in place for the dynamic_inventory.py
file for now, as that file is really more of an endpoint, but is tested.
Also, the bootstrap-ansible.sh script was modified to install the code;
this is unnecessary with the tox environments because the tox directive
'usedevelop=True' does that already. Production environments still need
this, though.
Finally, to maintain usability when called directly, the interpreter for
dynamic_inventory.py was updated from `/usr/bin/env` to
`/opt/ansible-runime/python`. This change ensures that in a full
deployment the user is using the exact same code paths whether Ansible
invokes the script, or it is called directly. This also means that using
the script locally on a development machine, it must be invoked as an
argument to Python, unless the ansible-runtime directory exists.
Change-Id: Iafa573b1b144f98528d5e0aceb3f36e9de2a22a2
When running the inventory tests on a development machine, using ctrl-c
to send sigint should gracefully finish the current test and clean up
the workspace (tests/inventory).
While most of our tests are well-behaved, without the catchbreak=True
option, sometimes the code would be interrupted in between file creation
and cleanup. Additionally, tearDownModule was never called, leaving
behind inventory/openstack_user_config.yml
This change allows the current test to finish, it's teardown methods to
run, and finally the tearDownModule function to execute, leaving behind
a clean workspace. Only the tests that directly touch the filesystem
were changed.
While this is not impactful for gate tests, it improves quality of life
for developers.
Change-Id: I992e514e58958264d90faab7bc295d6d8e89f039
This change allows the currently existing modules to be imported from
the `osa_toolkit` package.
In order to install the python modules used by the inventory via
setup.py with pbr, we need to rename the lib directory to match the name
of the package we wish to install.
pbr doesn't allow for doing any kind of directory renaming within the
setup.{cfg,py} files, but we need to keep using it in order to consume
global requirements updates.
Change-Id: Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7
Source code should be licensed under the Apache 2.0 license.
All source files should have the licensing header.
Change-Id: Ib5d8c93f7a1078cd0aaf6a0c0a30247671bc3088
The use of SystemExit exceptions in what is effectively library code
has been eliminated. A new exception is introduced and it is handled
with a translation to a SystemExit within generate.py when
appropriate.
When attempting to load an existing inventory, a tuple is returned
instead of simply the inventory. The tuple includes the path used to
load the inventory, or an appropriate path. This facilitates saving
to the correct place with save_inventory later.
Use of dir_find within generate.py was also eliminated and the logic
around path to configuration should be simpler now.
One debug logging message was adjusted to only run when the desired
file is actually loaded, where it was always trying to log a message
even if not file was found previously.
The manage.py file had imports updated to replicate the pattern used
in generate.py
Change-Id: I9caecfa09517a508882ae491df9e3d2da9386012
Parent-Id: I577cdbf4aadfcce846412edd7e2a394c257c0243
Update some function docstrings for accuracy/completeness
Make some methods module-private as they are not required to be
available for external use.
Tests were updated to accomodate for the now private functions.
The affected tests were identified as filesystem-centric and
moved to their own testing file, which will run under the inventory
tox target as well.
Parent-Id: I4d52f7363e00bba62ed878fe8fa6e593eb21fdde
Change-Id: I0275eeeafeb2a4c89cd820d56dd0ad01d3124a80