From 6eb0585f707e73d7a707b651265531840016c0f4 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Tue, 26 Nov 2013 15:28:12 +0000 Subject: [PATCH] Improve the UX around sample config generation This commit just adds some documentation around using the sample config generator. It also adds a wrapper script that sets the env variable for running the oslo generator script with tempest. Change-Id: I860b17defeeb85174e68b1e8b046b0e43c30683b --- HACKING.rst | 6 ++++++ README.rst | 3 +++ tempest/common/generate_sample_tempest.py | 9 +++++++++ tools/config/check_uptodate.sh | 2 +- tools/generate_sample.sh | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 tools/generate_sample.sh diff --git a/HACKING.rst b/HACKING.rst index 377c64784c..a74ff73349 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -186,3 +186,9 @@ Good candidates for stress tests are: - Scenario tests - API tests that have a wide focus + +Sample Configuration File +------------------------- +The sample config file is autogenerated using a script. If any changes are made +to the config variables in tempest then the sample config file must be +regenerated. This can be done running the script: tools/generate_sample.sh diff --git a/README.rst b/README.rst index 099602213f..96f6e4c337 100644 --- a/README.rst +++ b/README.rst @@ -79,6 +79,9 @@ Detailed configuration of tempest is beyond the scope of this document. The etc/tempest.conf.sample attempts to be a self documenting version of the configuration. +The sample config file is auto generated using the script: +tools/generate_sample.sh + The most important pieces that are needed are the user ids, openstack endpoints, and basic flavors and images needed to run tests. diff --git a/tempest/common/generate_sample_tempest.py b/tempest/common/generate_sample_tempest.py index 3811088738..545703bf3b 100644 --- a/tempest/common/generate_sample_tempest.py +++ b/tempest/common/generate_sample_tempest.py @@ -21,6 +21,15 @@ import sys from tempest import config from tempest.openstack.common.config import generator +# NOTE(mtreinish): This hack is needed because of how oslo config is used in +# tempest. Tempest is run from inside a test runner and so we can't rely on the +# global CONF object being fully populated when we run a test. (test runners +# don't init every file for running a test) So to get around that we manually +# load the config file in tempest for each test class to ensure that every +# config option is set. However, the tool expects the CONF object to be fully +# populated when it inits all the files in the project. This just works around +# the issue by manually loading the config file (which may or may not exist) +# which will populate all the options before running the generator. config.TempestConfig() generator.generate(sys.argv[1:]) diff --git a/tools/config/check_uptodate.sh b/tools/config/check_uptodate.sh index 9882ab6ae1..45c8629c86 100755 --- a/tools/config/check_uptodate.sh +++ b/tools/config/check_uptodate.sh @@ -5,6 +5,6 @@ tools/config/generate_sample.sh -b ./ -p tempest -o $TEMPDIR if ! diff $TEMPDIR/$CFGFILE etc/$CFGFILE then echo "E: tempest.conf.sample is not up to date, please run:" - echo "MODULEPATH=tempest.common.generate_sample_tempest tools/config/generate_sample.sh" + echo "tools/generate_sample.sh" exit 42 fi diff --git a/tools/generate_sample.sh b/tools/generate_sample.sh new file mode 100755 index 0000000000..9b312c9ba1 --- /dev/null +++ b/tools/generate_sample.sh @@ -0,0 +1,2 @@ +#!/bin/sh +MODULEPATH=tempest.common.generate_sample_tempest tools/config/generate_sample.sh $@