Add deployer-input option to overcloud validate

...to pass partial tempest configuration

Partial-Bug: BZ #1230840
Change-Id: I7154f32c70edd8551ae1c0500aeb399f1f0c8a5b
This commit is contained in:
Imre Farkas 2015-07-06 16:04:33 +02:00
parent a064fac2a7
commit b728836ae7
2 changed files with 25 additions and 18 deletions

View File

@ -26,39 +26,37 @@ class TestOvercloudValidate(fakes.TestOvercloudValidate):
# Get the command object to test # Get the command object to test
self.cmd = overcloud_validate.ValidateOvercloud(self.app, None) 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.chdir')
@mock.patch('os.mkdir')
@mock.patch('os.stat')
@mock.patch('os.path.expanduser')
@mock.patch('rdomanager_oscplugin.utils.run_shell') @mock.patch('rdomanager_oscplugin.utils.run_shell')
def test_validate_ok(self, mock_run_shell, mock_os_path_expanduser, def test_validate_ok(self, mock_run_shell, mock_os_chdir, mock_setup_dir):
mock_os_stat, mock_os_mkdir, mock_os_chdir):
mock_os_stat.return_value = True
mock_os_path_expanduser.return_value = '/home/user'
argslist = ['--overcloud-auth-url', 'http://foo', argslist = ['--overcloud-auth-url', 'http://foo',
'--overcloud-admin-password', 'password', '--overcloud-admin-password', 'password',
'--deployer-input', 'partial_config_file',
'--tempest-args', 'bar', '--tempest-args', 'bar',
'--skipfile', 'skip'] '--skipfile', 'skip']
verifylist = [ verifylist = [
('overcloud_auth_url', 'http://foo'), ('overcloud_auth_url', 'http://foo'),
('overcloud_admin_password', 'password'), ('overcloud_admin_password', 'password'),
('deployer_input', 'partial_config_file'),
('tempest_args', 'bar'), ('tempest_args', 'bar'),
('skipfile', 'skip') ('skipfile', 'skip')
] ]
parsed_args = self.check_parser(self.cmd, argslist, verifylist) parsed_args = self.check_parser(self.cmd, argslist, verifylist)
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
mock_os_stat.assert_called_with('/home/user/tempest') mock_setup_dir.assert_called_once_with()
self.assertEqual(0, mock_os_mkdir.call_count)
mock_os_chdir.assert_called_with('/home/user/tempest') mock_os_chdir.assert_called_with('/home/user/tempest')
mock_run_shell.assert_has_calls([ mock_run_shell.assert_has_calls([
mock.call('/usr/share/openstack-tempest-kilo/tools/' mock.call('/usr/share/openstack-tempest-kilo/tools/'
'configure-tempest-directory'), 'configure-tempest-directory'),
mock.call('./tools/config_tempest.py --out etc/tempest.conf ' mock.call('./tools/config_tempest.py --out etc/tempest.conf '
'--deployer-input partial_config_file '
'--debug --create ' '--debug --create '
'identity.uri http://foo ' 'identity.uri http://foo '
'compute.allow_tenant_isolation true ' 'compute.allow_tenant_isolation true '

View File

@ -26,20 +26,25 @@ class ValidateOvercloud(command.Command):
auth_required = False auth_required = False
log = logging.getLogger(__name__ + ".ValidateOvercloud") 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, def _run_tempest(self, overcloud_auth_url, overcloud_admin_password,
tempest_args, skipfile): deployer_input, tempest_args, skipfile):
tempest_run_dir = os.path.join(os.path.expanduser("~"), "tempest") os.chdir(self.tempest_run_dir)
try:
os.stat(tempest_run_dir)
except OSError:
os.mkdir(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/' utils.run_shell('/usr/share/openstack-tempest-kilo/tools/'
'configure-tempest-directory') 'configure-tempest-directory')
utils.run_shell('./tools/config_tempest.py --out etc/tempest.conf ' utils.run_shell('./tools/config_tempest.py --out etc/tempest.conf '
'--deployer-input %(partial_config_file)s '
'--debug --create ' '--debug --create '
'identity.uri %(auth_url)s ' 'identity.uri %(auth_url)s '
'compute.allow_tenant_isolation true ' 'compute.allow_tenant_isolation true '
@ -51,7 +56,8 @@ class ValidateOvercloud(command.Command):
'network.build_timeout 500 ' 'network.build_timeout 500 '
'volume.build_timeout 500 ' 'volume.build_timeout 500 '
'scenario.ssh_user cirros' % 'scenario.ssh_user cirros' %
{'auth_url': overcloud_auth_url, {'partial_config_file': deployer_input,
'auth_url': overcloud_auth_url,
'admin_password': overcloud_admin_password}) 'admin_password': overcloud_admin_password})
args = ['./tools/run-tests.sh', ] 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-auth-url', required=True)
parser.add_argument('--overcloud-admin-password', required=True) parser.add_argument('--overcloud-admin-password', required=True)
parser.add_argument('--deployer-input')
parser.add_argument('--tempest-args') parser.add_argument('--tempest-args')
parser.add_argument('--skipfile') parser.add_argument('--skipfile')
@ -76,7 +83,9 @@ class ValidateOvercloud(command.Command):
def take_action(self, parsed_args): def take_action(self, parsed_args):
self.log.debug("take_action(%s)" % parsed_args) self.log.debug("take_action(%s)" % parsed_args)
self._setup_dir()
self._run_tempest(parsed_args.overcloud_auth_url, self._run_tempest(parsed_args.overcloud_auth_url,
parsed_args.overcloud_admin_password, parsed_args.overcloud_admin_password,
parsed_args.deployer_input,
parsed_args.tempest_args, parsed_args.tempest_args,
parsed_args.skipfile) parsed_args.skipfile)