Fix refstack-client testing with test-list option failure.

With the test-list option, refstack-client will first normalize the
user input test list to the test list from the currently installed
Tempest.  There seems to be some non RefStack updates in the recent
releases that "testr list-tests" would now require a valid
tempest.conf for test listing.  The path of the tempest.conf file
is determined by the .tempest/tempest/config.py module.  If a
tempest.conf file is not found, then the failsafe file is used,
namely "/etc/tempest/tempest.conf" which does not exist in
refstack-client.

This patch initialzes the tempest conf related environment variables
with the user passes in information before starting the test run.

Closes-Bug: #1516458

Change-Id: Ic2cdbdcdf575e23cb0fc59c5478ceda5807c06fb
This commit is contained in:
cdiep 2015-11-18 12:55:28 -08:00
parent e04a06b106
commit 1d392df77f
2 changed files with 18 additions and 0 deletions

View File

@ -91,6 +91,11 @@ class RefstackClient:
self.logger.error("Conf file not valid: %s" % self.args.conf_file)
exit(1)
# Initialize environment variables with config file info
os.environ["TEMPEST_CONFIG_DIR"] = os.path.abspath(
os.path.dirname(self.args.conf_file))
os.environ["TEMPEST_CONFIG"] = os.path.basename(self.args.conf_file)
# Check that the Tempest directory is an existing directory.
if not os.path.isdir(self.tempest_dir):
self.logger.error("Tempest directory given is not a directory or "

View File

@ -841,3 +841,16 @@ class TestRefstackClient(unittest.TestCase):
pubkey, signature = client._sign_pubkey()
self.assertTrue(pubkey.startswith('ssh-rsa AAAA'))
self.assertTrue(signature.startswith('413cb954'))
def test_set_env_params(self):
"""
Test that the environment variables are correctly set.
"""
args = rc.parse_cli_args(self.mock_argv())
client = rc.RefstackClient(args)
client.tempest_dir = self.test_path
client._prep_test()
conf_dir = os.path.abspath(os.path.dirname(self.conf_file_name))
conf_file = os.path.basename(self.conf_file_name)
self.assertEqual(os.environ.get('TEMPEST_CONFIG_DIR'), conf_dir)
self.assertEqual(os.environ.get('TEMPEST_CONFIG'), conf_file)