diff options
author | jiasen.lin <jiasen.lin@easystack.cn> | 2017-03-19 21:22:43 +0800 |
---|---|---|
committer | jiasen.lin <jiasen.lin@easystack.cn> | 2017-03-22 04:23:33 +0000 |
commit | 378490d44da1e3b2fede1d868b5554d91f8c523d (patch) | |
tree | 0708d15b4b578669535a48313114e9aa3c541503 /saharaclient | |
parent | fb803225f3e7c48958acc86a9e9b747d598320ee (diff) | |
download | python-saharaclient-378490d44da1e3b2fede1d868b5554d91f8c523d.tar.gz |
Fix a bug in jobs.py
When I used command "dataprocessing job execute", the option
--input and --output must be defined otherwise I can't excute job.
Because it alwalys return error_code 404. Acutually, we can use
option --args to appoint input_url and output_url.So I think
--input and --output should be optional.
add:
test_job_execute_with_input_output_option()
Closes-Bug: #1670227
Change-Id: Ia2d3a19658ad78f7c07f444131dddf836bb8018e
Diffstat (limited to 'saharaclient')
-rw-r--r-- | saharaclient/osc/v1/jobs.py | 15 | ||||
-rw-r--r-- | saharaclient/tests/unit/osc/v1/test_jobs.py | 43 |
2 files changed, 53 insertions, 5 deletions
diff --git a/saharaclient/osc/v1/jobs.py b/saharaclient/osc/v1/jobs.py index 0301cc9..344b86c 100644 --- a/saharaclient/osc/v1/jobs.py +++ b/saharaclient/osc/v1/jobs.py @@ -174,11 +174,16 @@ class ExecuteJob(command.ShowOne): client.jobs, parsed_args.job_template) cluster_id = utils.get_resource_id( client.clusters, parsed_args.cluster) - - input_id = utils.get_resource_id( - client.data_sources, parsed_args.input) - output_id = utils.get_resource_id( - client.data_sources, parsed_args.output) + if parsed_args.input not in [None, "", "None"]: + input_id = utils.get_resource_id( + client.data_sources, parsed_args.input) + else: + input_id = None + if parsed_args.output not in [None, "", "None"]: + output_id = utils.get_resource_id( + client.data_sources, parsed_args.output) + else: + output_id = None data = client.job_executions.create( job_id=jt_id, cluster_id=cluster_id, input_id=input_id, diff --git a/saharaclient/tests/unit/osc/v1/test_jobs.py b/saharaclient/tests/unit/osc/v1/test_jobs.py index edbead9..6beaa15 100644 --- a/saharaclient/tests/unit/osc/v1/test_jobs.py +++ b/saharaclient/tests/unit/osc/v1/test_jobs.py @@ -89,10 +89,53 @@ class TestExecuteJob(TestJobs): # Check that correct arguments were passed self.je_mock.create.assert_called_once_with( + cluster_id='cluster_id', configs={}, input_id=None, + interface=None, is_protected=False, is_public=False, + job_id='job_id', output_id=None) + + def test_job_execute_with_input_output_option(self): + arglist = ['--job-template', 'job-template', '--cluster', 'cluster', + '--input', 'input', '--output', 'output'] + verifylist = [('job_template', 'job-template'), ('cluster', 'cluster'), + ('input', 'input'), ('output', 'output')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.je_mock.create.assert_called_once_with( cluster_id='cluster_id', configs={}, input_id='ds_id', interface=None, is_protected=False, is_public=False, job_id='job_id', output_id='ds_id') + # without option --output + arglist = ['--job-template', 'job-template', '--cluster', 'cluster', + '--input', 'input'] + verifylist = [('job_template', 'job-template'), ('cluster', 'cluster'), + ('input', 'input')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.je_mock.create.assert_called_with( + cluster_id='cluster_id', configs={}, input_id='ds_id', + interface=None, is_protected=False, is_public=False, + job_id='job_id', output_id=None) + + # without options --output and --input + arglist = ['--job-template', 'job-template', '--cluster', 'cluster'] + verifylist = [('job_template', 'job-template'), ('cluster', 'cluster')] + + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + self.cmd.take_action(parsed_args) + + self.je_mock.create.assert_called_with( + cluster_id='cluster_id', configs={}, input_id=None, + interface=None, is_protected=False, is_public=False, + job_id='job_id', output_id=None) + def test_job_execute_all_options(self): arglist = ['--job-template', 'job-template', '--cluster', 'cluster', '--input', 'input', '--output', 'output', '--params', |