tempest verify config only works with config files in etc/ relative to source tree

Bug #1683809 reported by Matthew Treinish
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
Undecided
Martin Kopec

Bug Description

The tempest verify config command only works with an input config file hard coded based on a relative path to the source code for the command:

https://github.com/openstack/tempest/blob/master/tempest/cmd/verify_tempest_config.py#L41-L50

This doesn't work in the real world, especially if you're using workspaces or passing the config in via the CLI or env variables.

The command should have a CLI argument for the input config file as well as being made to be workspace aware.

Tags: api
Martin Kopec (mkopec)
Changed in tempest:
status: New → Confirmed
tags: added: api
Martin Kopec (mkopec)
Changed in tempest:
assignee: nobody → Martin Kopec (mkopec)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tempest (master)

Fix proposed to branch: master
Review: https://review.openstack.org/478787

Changed in tempest:
status: Confirmed → In Progress
Revision history for this message
Martin Kopec (mkopec) wrote :

Hard coded relative path to the source code was changed, so it's possible to use the tool in different workspaces.

I don't think it's needed to implement CLI argument for the input config file. There are two environment variables which can do that:
TEMPEST_CONFIG_DIR - path to the directory where tempest.conf is saved
TEMPEST_CONFIG - name of a tempest.conf file

If the environment variables are set, path to the ./etc/tempest.conf in workspace is overridden by them.

Revision history for this message
Masayuki Igawa (igawa) wrote :

yeah, there are the environment variables. However, there's no documentation for that now. Users can't know the environment variables..

And I think having CLI argument is better because it's very explicitly and easy to use.

Revision history for this message
Martin Kopec (mkopec) wrote :

So I've added some documentation for the env variables and the tool itself (patch set 2).

I've examined possibilities how to add the CLI argument, but there is a few problems.
TempestConfigProxy [1] is instantiated when modules in tempest_verify_config are loaded [2]. During this first call of the TempestConfigProxy the path is set [3]. There is a method which should be able to change the path [4], but it changes the path only in this object, however, the object we are interested in is this [5] - TempestConfigPrivate. This object is created when the TempestConfigProxy is called for the first time, as I mentioned above. Because the first call happens during loading of modules, the path is set to None, which means that inside of TempestConfigPrivate are used default values - env. variables [6].

I've tried to manually instantiate the TempestConfigProxy again (override the existing one), but it didn't work, because of registration of service clients [7][8], because they were already registered. It seems there is some kind of magic in the global space.
If we wrap registrations [7][8] to try block, so that, we would ignore reregistration of the clients, it will work, but that solution would be really hacky and probably would break something else.

Therefor I've added at least the documentation for the env variables. If you see any other, safer and simple option or idea how to solve this, please share. Otherwise it would be maybe easier to document the env variables and use them instead of CLI argument.

[1] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1236
[2] https://github.com/openstack/tempest/blob/master/tempest/cmd/verify_tempest_config.py#L29
[3] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1251
[4] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1274
[5] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1255
[6] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1198
[7] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1264
[8] https://github.com/openstack/tempest/blob/master/tempest/config.py#L1270

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tempest (master)

Reviewed: https://review.openstack.org/478787
Committed: https://git.openstack.org/cgit/openstack/tempest/commit/?id=bd9dd8e2cd5d38139f66b58ac6fe6fb4f43d3610
Submitter: Jenkins
Branch: master

commit bd9dd8e2cd5d38139f66b58ac6fe6fb4f43d3610
Author: Martin Kopec <email address hidden>
Date: Wed Jun 28 20:52:18 2017 +0000

    Make verify_tempest_config workspace aware

    Hard coded relative path to the source code is changed, so that
    the tool is workspace aware.
    Edited help for -o argument. When -u is defined and -o not, description of -o
    argument was misleading because the new config file was not printed to STDOUT.
    The patch adds documentation of tool's options. Environment variables are
    documented as well.

    Change-Id: I31fef80fb98f22711638908bef3a17bf18d63772
    Closes-Bug: #1683809

Changed in tempest:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tempest 17.0.0

This issue was fixed in the openstack/tempest 17.0.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.