From b728836ae7fe0766800582728f1afd9b00b92158 Mon Sep 17 00:00:00 2001 From: Imre Farkas Date: Mon, 6 Jul 2015 16:04:33 +0200 Subject: [PATCH] Add deployer-input option to overcloud validate ...to pass partial tempest configuration Partial-Bug: BZ #1230840 Change-Id: I7154f32c70edd8551ae1c0500aeb399f1f0c8a5b --- .../test_overcloud_validate.py | 18 ++++++------- rdomanager_oscplugin/v1/overcloud_validate.py | 25 +++++++++++++------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/rdomanager_oscplugin/tests/v1/overcloud_validate/test_overcloud_validate.py b/rdomanager_oscplugin/tests/v1/overcloud_validate/test_overcloud_validate.py index aca0876a0..ad2f07aa9 100644 --- a/rdomanager_oscplugin/tests/v1/overcloud_validate/test_overcloud_validate.py +++ b/rdomanager_oscplugin/tests/v1/overcloud_validate/test_overcloud_validate.py @@ -26,39 +26,37 @@ class TestOvercloudValidate(fakes.TestOvercloudValidate): # Get the command object to test self.cmd = overcloud_validate.ValidateOvercloud(self.app, None) + self.cmd.tempest_run_dir = '/home/user/tempest' + @mock.patch('rdomanager_oscplugin.v1.overcloud_validate.ValidateOvercloud.' + '_setup_dir') @mock.patch('os.chdir') - @mock.patch('os.mkdir') - @mock.patch('os.stat') - @mock.patch('os.path.expanduser') @mock.patch('rdomanager_oscplugin.utils.run_shell') - def test_validate_ok(self, mock_run_shell, mock_os_path_expanduser, - mock_os_stat, mock_os_mkdir, mock_os_chdir): - mock_os_stat.return_value = True - mock_os_path_expanduser.return_value = '/home/user' + def test_validate_ok(self, mock_run_shell, mock_os_chdir, mock_setup_dir): argslist = ['--overcloud-auth-url', 'http://foo', '--overcloud-admin-password', 'password', + '--deployer-input', 'partial_config_file', '--tempest-args', 'bar', '--skipfile', 'skip'] verifylist = [ ('overcloud_auth_url', 'http://foo'), ('overcloud_admin_password', 'password'), + ('deployer_input', 'partial_config_file'), ('tempest_args', 'bar'), ('skipfile', 'skip') ] parsed_args = self.check_parser(self.cmd, argslist, verifylist) - self.cmd.take_action(parsed_args) - mock_os_stat.assert_called_with('/home/user/tempest') - self.assertEqual(0, mock_os_mkdir.call_count) + mock_setup_dir.assert_called_once_with() mock_os_chdir.assert_called_with('/home/user/tempest') mock_run_shell.assert_has_calls([ mock.call('/usr/share/openstack-tempest-kilo/tools/' 'configure-tempest-directory'), mock.call('./tools/config_tempest.py --out etc/tempest.conf ' + '--deployer-input partial_config_file ' '--debug --create ' 'identity.uri http://foo ' 'compute.allow_tenant_isolation true ' diff --git a/rdomanager_oscplugin/v1/overcloud_validate.py b/rdomanager_oscplugin/v1/overcloud_validate.py index 132dcc1d0..9d3d9d030 100644 --- a/rdomanager_oscplugin/v1/overcloud_validate.py +++ b/rdomanager_oscplugin/v1/overcloud_validate.py @@ -26,20 +26,25 @@ class ValidateOvercloud(command.Command): auth_required = False log = logging.getLogger(__name__ + ".ValidateOvercloud") + tempest_run_dir = os.path.join(os.path.expanduser("~"), "tempest") + + def _setup_dir(self): + try: + os.stat(self.tempest_run_dir) + except OSError: + os.mkdir(self.tempest_run_dir) def _run_tempest(self, overcloud_auth_url, overcloud_admin_password, - tempest_args, skipfile): - tempest_run_dir = os.path.join(os.path.expanduser("~"), "tempest") - try: - os.stat(tempest_run_dir) - except OSError: - os.mkdir(tempest_run_dir) + deployer_input, tempest_args, skipfile): + os.chdir(self.tempest_run_dir) - os.chdir(tempest_run_dir) + if not deployer_input: + deployer_input = '/dev/null' utils.run_shell('/usr/share/openstack-tempest-kilo/tools/' 'configure-tempest-directory') utils.run_shell('./tools/config_tempest.py --out etc/tempest.conf ' + '--deployer-input %(partial_config_file)s ' '--debug --create ' 'identity.uri %(auth_url)s ' 'compute.allow_tenant_isolation true ' @@ -51,7 +56,8 @@ class ValidateOvercloud(command.Command): 'network.build_timeout 500 ' 'volume.build_timeout 500 ' 'scenario.ssh_user cirros' % - {'auth_url': overcloud_auth_url, + {'partial_config_file': deployer_input, + 'auth_url': overcloud_auth_url, 'admin_password': overcloud_admin_password}) args = ['./tools/run-tests.sh', ] @@ -68,6 +74,7 @@ class ValidateOvercloud(command.Command): parser.add_argument('--overcloud-auth-url', required=True) parser.add_argument('--overcloud-admin-password', required=True) + parser.add_argument('--deployer-input') parser.add_argument('--tempest-args') parser.add_argument('--skipfile') @@ -76,7 +83,9 @@ class ValidateOvercloud(command.Command): def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) + self._setup_dir() self._run_tempest(parsed_args.overcloud_auth_url, parsed_args.overcloud_admin_password, + parsed_args.deployer_input, parsed_args.tempest_args, parsed_args.skipfile)