New optional param for log path
Signed-off-by: Jiri Podivin <jpodivin@redhat.com> Change-Id: Id31a7ce2dfc4d9a132fea7d600e8beb8adc0739b
This commit is contained in:
parent
0dca003674
commit
2e3b5bd6fc
|
@ -79,6 +79,15 @@ class Run(Command):
|
||||||
"will override the other(s)")
|
"will override the other(s)")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
'--validation-log-dir',
|
||||||
|
dest='log_path',
|
||||||
|
default=constants.VALIDATIONS_LOG_BASEDIR,
|
||||||
|
help=(
|
||||||
|
"Path where the log files and artifacts will be located. "),
|
||||||
|
metavar='<LOG-DIR>'
|
||||||
|
)
|
||||||
|
|
||||||
extra_vars_group = parser.add_mutually_exclusive_group(required=False)
|
extra_vars_group = parser.add_mutually_exclusive_group(required=False)
|
||||||
extra_vars_group.add_argument(
|
extra_vars_group.add_argument(
|
||||||
'--extra-vars',
|
'--extra-vars',
|
||||||
|
@ -158,7 +167,8 @@ class Run(Command):
|
||||||
validation_name=parsed_args.validation_name,
|
validation_name=parsed_args.validation_name,
|
||||||
extra_env_vars=parsed_args.extra_env_vars,
|
extra_env_vars=parsed_args.extra_env_vars,
|
||||||
quiet=True,
|
quiet=True,
|
||||||
ssh_user=parsed_args.ssh_user)
|
ssh_user=parsed_args.ssh_user,
|
||||||
|
log_path=parsed_args.log_path)
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
raise RuntimeError(e)
|
raise RuntimeError(e)
|
||||||
|
|
||||||
|
|
|
@ -56,13 +56,15 @@ class TestRun(BaseCommand):
|
||||||
self.assertRaises(Exception, self.check_parser, self.cmd,
|
self.assertRaises(Exception, self.check_parser, self.cmd,
|
||||||
arglist, verifylist)
|
arglist, verifylist)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.constants.VALIDATIONS_LOG_BASEDIR')
|
||||||
@mock.patch('validations_libs.cli.common.print_dict')
|
@mock.patch('validations_libs.cli.common.print_dict')
|
||||||
@mock.patch('getpass.getuser',
|
@mock.patch('getpass.getuser',
|
||||||
return_value='doe')
|
return_value='doe')
|
||||||
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
||||||
'run_validations',
|
'run_validations',
|
||||||
return_value=fakes.FAKE_SUCCESS_RUN)
|
return_value=fakes.FAKE_SUCCESS_RUN)
|
||||||
def test_run_command_extra_vars(self, mock_run, mock_user, mock_print):
|
def test_run_command_extra_vars(self, mock_run, mock_user, mock_print,
|
||||||
|
mock_log_dir):
|
||||||
run_called_args = {
|
run_called_args = {
|
||||||
'inventory': 'localhost',
|
'inventory': 'localhost',
|
||||||
'limit_hosts': None,
|
'limit_hosts': None,
|
||||||
|
@ -73,7 +75,8 @@ class TestRun(BaseCommand):
|
||||||
'validation_name': ['foo'],
|
'validation_name': ['foo'],
|
||||||
'extra_env_vars': None,
|
'extra_env_vars': None,
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ssh_user': 'doe'}
|
'ssh_user': 'doe',
|
||||||
|
'log_path': mock_log_dir}
|
||||||
|
|
||||||
arglist = ['--validation', 'foo',
|
arglist = ['--validation', 'foo',
|
||||||
'--extra-vars', 'key=value']
|
'--extra-vars', 'key=value']
|
||||||
|
@ -84,6 +87,7 @@ class TestRun(BaseCommand):
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
mock_run.assert_called_with(**run_called_args)
|
mock_run.assert_called_with(**run_called_args)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.constants.VALIDATIONS_LOG_BASEDIR')
|
||||||
@mock.patch('validations_libs.cli.common.print_dict')
|
@mock.patch('validations_libs.cli.common.print_dict')
|
||||||
@mock.patch('getpass.getuser',
|
@mock.patch('getpass.getuser',
|
||||||
return_value='doe')
|
return_value='doe')
|
||||||
|
@ -91,7 +95,7 @@ class TestRun(BaseCommand):
|
||||||
'run_validations',
|
'run_validations',
|
||||||
return_value=fakes.FAKE_SUCCESS_RUN)
|
return_value=fakes.FAKE_SUCCESS_RUN)
|
||||||
def test_run_command_extra_vars_twice(self, mock_run, mock_user,
|
def test_run_command_extra_vars_twice(self, mock_run, mock_user,
|
||||||
mock_print):
|
mock_print, mock_log_dir):
|
||||||
run_called_args = {
|
run_called_args = {
|
||||||
'inventory': 'localhost',
|
'inventory': 'localhost',
|
||||||
'limit_hosts': None,
|
'limit_hosts': None,
|
||||||
|
@ -102,7 +106,8 @@ class TestRun(BaseCommand):
|
||||||
'validation_name': ['foo'],
|
'validation_name': ['foo'],
|
||||||
'extra_env_vars': None,
|
'extra_env_vars': None,
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ssh_user': 'doe'}
|
'ssh_user': 'doe',
|
||||||
|
'log_path': mock_log_dir}
|
||||||
|
|
||||||
arglist = ['--validation', 'foo',
|
arglist = ['--validation', 'foo',
|
||||||
'--extra-vars', 'key=value1',
|
'--extra-vars', 'key=value1',
|
||||||
|
@ -124,6 +129,7 @@ class TestRun(BaseCommand):
|
||||||
self.assertRaises(Exception, self.check_parser, self.cmd,
|
self.assertRaises(Exception, self.check_parser, self.cmd,
|
||||||
arglist, verifylist)
|
arglist, verifylist)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.constants.VALIDATIONS_LOG_BASEDIR')
|
||||||
@mock.patch('yaml.safe_load', return_value={'key': 'value'})
|
@mock.patch('yaml.safe_load', return_value={'key': 'value'})
|
||||||
@mock.patch('six.moves.builtins.open')
|
@mock.patch('six.moves.builtins.open')
|
||||||
@mock.patch('getpass.getuser',
|
@mock.patch('getpass.getuser',
|
||||||
|
@ -132,7 +138,8 @@ class TestRun(BaseCommand):
|
||||||
'run_validations',
|
'run_validations',
|
||||||
return_value=fakes.FAKE_SUCCESS_RUN)
|
return_value=fakes.FAKE_SUCCESS_RUN)
|
||||||
def test_run_command_extra_vars_file(self, mock_run, mock_user, mock_open,
|
def test_run_command_extra_vars_file(self, mock_run, mock_user, mock_open,
|
||||||
mock_yaml):
|
mock_yaml, mock_log_dir):
|
||||||
|
|
||||||
run_called_args = {
|
run_called_args = {
|
||||||
'inventory': 'localhost',
|
'inventory': 'localhost',
|
||||||
'limit_hosts': None,
|
'limit_hosts': None,
|
||||||
|
@ -143,7 +150,8 @@ class TestRun(BaseCommand):
|
||||||
'validation_name': ['foo'],
|
'validation_name': ['foo'],
|
||||||
'extra_env_vars': None,
|
'extra_env_vars': None,
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ssh_user': 'doe'}
|
'ssh_user': 'doe',
|
||||||
|
'log_path': mock_log_dir}
|
||||||
|
|
||||||
arglist = ['--validation', 'foo',
|
arglist = ['--validation', 'foo',
|
||||||
'--extra-vars-file', '/foo/vars.yaml']
|
'--extra-vars-file', '/foo/vars.yaml']
|
||||||
|
@ -154,12 +162,13 @@ class TestRun(BaseCommand):
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
mock_run.assert_called_with(**run_called_args)
|
mock_run.assert_called_with(**run_called_args)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.constants.VALIDATIONS_LOG_BASEDIR')
|
||||||
@mock.patch('getpass.getuser',
|
@mock.patch('getpass.getuser',
|
||||||
return_value='doe')
|
return_value='doe')
|
||||||
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
||||||
'run_validations',
|
'run_validations',
|
||||||
return_value=fakes.FAKE_SUCCESS_RUN)
|
return_value=fakes.FAKE_SUCCESS_RUN)
|
||||||
def test_run_command_extra_env_vars(self, mock_run, mock_user):
|
def test_run_command_extra_env_vars(self, mock_run, mock_user, mock_log_dir):
|
||||||
run_called_args = {
|
run_called_args = {
|
||||||
'inventory': 'localhost',
|
'inventory': 'localhost',
|
||||||
'limit_hosts': None,
|
'limit_hosts': None,
|
||||||
|
@ -170,7 +179,8 @@ class TestRun(BaseCommand):
|
||||||
'validation_name': ['foo'],
|
'validation_name': ['foo'],
|
||||||
'extra_env_vars': {'key': 'value'},
|
'extra_env_vars': {'key': 'value'},
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ssh_user': 'doe'}
|
'ssh_user': 'doe',
|
||||||
|
'log_path': mock_log_dir}
|
||||||
|
|
||||||
arglist = ['--validation', 'foo',
|
arglist = ['--validation', 'foo',
|
||||||
'--extra-env-vars', 'key=value']
|
'--extra-env-vars', 'key=value']
|
||||||
|
@ -181,12 +191,13 @@ class TestRun(BaseCommand):
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
mock_run.assert_called_with(**run_called_args)
|
mock_run.assert_called_with(**run_called_args)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.constants.VALIDATIONS_LOG_BASEDIR')
|
||||||
@mock.patch('getpass.getuser',
|
@mock.patch('getpass.getuser',
|
||||||
return_value='doe')
|
return_value='doe')
|
||||||
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
||||||
'run_validations',
|
'run_validations',
|
||||||
return_value=fakes.FAKE_SUCCESS_RUN)
|
return_value=fakes.FAKE_SUCCESS_RUN)
|
||||||
def test_run_command_extra_env_vars_twice(self, mock_run, mock_user):
|
def test_run_command_extra_env_vars_twice(self, mock_run, mock_user, mock_log_dir):
|
||||||
run_called_args = {
|
run_called_args = {
|
||||||
'inventory': 'localhost',
|
'inventory': 'localhost',
|
||||||
'limit_hosts': None,
|
'limit_hosts': None,
|
||||||
|
@ -197,7 +208,8 @@ class TestRun(BaseCommand):
|
||||||
'validation_name': ['foo'],
|
'validation_name': ['foo'],
|
||||||
'extra_env_vars': {'key': 'value2'},
|
'extra_env_vars': {'key': 'value2'},
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ssh_user': 'doe'}
|
'ssh_user': 'doe',
|
||||||
|
'log_path': mock_log_dir}
|
||||||
|
|
||||||
arglist = ['--validation', 'foo',
|
arglist = ['--validation', 'foo',
|
||||||
'--extra-env-vars', 'key=value1',
|
'--extra-env-vars', 'key=value1',
|
||||||
|
@ -209,13 +221,16 @@ class TestRun(BaseCommand):
|
||||||
self.cmd.take_action(parsed_args)
|
self.cmd.take_action(parsed_args)
|
||||||
mock_run.assert_called_with(**run_called_args)
|
mock_run.assert_called_with(**run_called_args)
|
||||||
|
|
||||||
|
@mock.patch('validations_libs.constants.VALIDATIONS_LOG_BASEDIR')
|
||||||
@mock.patch('getpass.getuser',
|
@mock.patch('getpass.getuser',
|
||||||
return_value='doe')
|
return_value='doe')
|
||||||
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
@mock.patch('validations_libs.validation_actions.ValidationActions.'
|
||||||
'run_validations',
|
'run_validations',
|
||||||
return_value=fakes.FAKE_SUCCESS_RUN)
|
return_value=fakes.FAKE_SUCCESS_RUN)
|
||||||
def test_run_command_extra_env_vars_and_extra_vars(self, mock_run,
|
def test_run_command_extra_env_vars_and_extra_vars(self,
|
||||||
mock_user):
|
mock_run,
|
||||||
|
mock_user,
|
||||||
|
mock_log_dir):
|
||||||
run_called_args = {
|
run_called_args = {
|
||||||
'inventory': 'localhost',
|
'inventory': 'localhost',
|
||||||
'limit_hosts': None,
|
'limit_hosts': None,
|
||||||
|
@ -226,7 +241,8 @@ class TestRun(BaseCommand):
|
||||||
'validation_name': ['foo'],
|
'validation_name': ['foo'],
|
||||||
'extra_env_vars': {'key2': 'value2'},
|
'extra_env_vars': {'key2': 'value2'},
|
||||||
'quiet': True,
|
'quiet': True,
|
||||||
'ssh_user': 'doe'}
|
'ssh_user': 'doe',
|
||||||
|
'log_path': mock_log_dir}
|
||||||
|
|
||||||
arglist = ['--validation', 'foo',
|
arglist = ['--validation', 'foo',
|
||||||
'--extra-vars', 'key=value',
|
'--extra-vars', 'key=value',
|
||||||
|
|
Loading…
Reference in New Issue