From 1d392df77f1b88edee17de89690414e5bf7681b3 Mon Sep 17 00:00:00 2001 From: cdiep Date: Wed, 18 Nov 2015 12:55:28 -0800 Subject: [PATCH] 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 --- refstack_client/refstack_client.py | 5 +++++ refstack_client/tests/unit/test_client.py | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/refstack_client/refstack_client.py b/refstack_client/refstack_client.py index fc0a684..9359ae1 100755 --- a/refstack_client/refstack_client.py +++ b/refstack_client/refstack_client.py @@ -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 " diff --git a/refstack_client/tests/unit/test_client.py b/refstack_client/tests/unit/test_client.py index 5314951..721e932 100755 --- a/refstack_client/tests/unit/test_client.py +++ b/refstack_client/tests/unit/test_client.py @@ -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)