def test_create_proxy_user_for_job_execution(self, proxy_user, trustor, trustee, trust, job_execution_update, context_current, passwd): job_execution = mock.Mock(id=1, output_id=2, job_id=3, job_configs=None) job_execution.job_configs = mock.Mock(to_dict=mock.Mock( return_value={})) proxy_user.return_value = "proxy_user" passwd.return_value = "test_password" trustor.return_value = "test_trustor" trustee.return_value = "test_trustee" trust.return_value = "123456" ctx = mock.Mock() context_current.return_value = ctx p.create_proxy_user_for_job_execution(job_execution) update = {'job_configs': {'proxy_configs': None}} update['job_configs']['proxy_configs'] = { 'proxy_username': '******', 'proxy_password': '******', 'proxy_trust_id': '123456' } job_execution_update.assert_called_with(ctx, job_execution, update)
def execute_job(job_id, data): # Elements common to all job types cluster_id = data['cluster_id'] configs = data.get('job_configs', {}) # Not in Java job types but present for all others input_id = data.get('input_id', None) output_id = data.get('output_id', None) # Since we will use a unified class in the database, we pass # a superset for all job types job_ex_dict = {'input_id': input_id, 'output_id': output_id, 'job_id': job_id, 'cluster_id': cluster_id, 'info': {'status': edp.JOB_STATUS_PENDING}, 'job_configs': configs, 'extra': {}} job_execution = conductor.job_execution_create(context.ctx(), job_ex_dict) # check to use proxy user if p.job_execution_requires_proxy_user(job_execution): try: p.create_proxy_user_for_job_execution(job_execution) except ex.SaharaException as e: LOG.exception(_LE("Can't run job execution '{0}' " "(reasons: {1})").format(job_execution.id, e)) conductor.job_execution_destroy(context.ctx(), job_execution) raise e OPS.run_edp_job(job_execution.id) return job_execution
def execute_job(job_id, data): # Elements common to all job types cluster_id = data['cluster_id'] configs = data.get('job_configs', {}) interface = data.get('interface', {}) # Not in Java job types but present for all others input_id = data.get('input_id', None) output_id = data.get('output_id', None) # Since we will use a unified class in the database, we pass # a superset for all job types job_ex_dict = {'input_id': input_id, 'output_id': output_id, 'job_id': job_id, 'cluster_id': cluster_id, 'info': {'status': edp.JOB_STATUS_PENDING}, 'job_configs': configs, 'extra': {}, 'interface': interface} job_execution = conductor.job_execution_create(context.ctx(), job_ex_dict) context.set_current_job_execution_id(job_execution.id) # check to use proxy user if p.job_execution_requires_proxy_user(job_execution): try: p.create_proxy_user_for_job_execution(job_execution) except ex.SaharaException as e: LOG.error(_LE("Can't run job execution. " "(Reasons: {reason})").format(reason=e)) conductor.job_execution_destroy(context.ctx(), job_execution) raise e OPS.run_edp_job(job_execution.id) return job_execution
def test_create_proxy_user_for_job_execution(self, proxy_user, trustor, trustee, trust, job_execution_update, context_current, passwd): job_execution = mock.Mock(id=1, output_id=2, job_id=3, job_configs=None) job_execution.job_configs = mock.Mock(to_dict=mock.Mock( return_value={} )) proxy_user.return_value = "proxy_user" passwd.return_value = "test_password" trustor.return_value = "test_trustor" trustee.return_value = "test_trustee" trust.return_value = "123456" ctx = mock.Mock() context_current.return_value = ctx p.create_proxy_user_for_job_execution(job_execution) update = {'job_configs': {'proxy_configs': None}} update['job_configs']['proxy_configs'] = { 'proxy_username': '******', 'proxy_password': '******', 'proxy_trust_id': '123456' } job_execution_update.assert_called_with(ctx, job_execution, update)
def execute_job(data): # Elements common to all job types job_templates_id = data['job_templates_id'] cluster_id = data['cluster_id'] configs = data.get('job_configs', {}) interface = data.get('interface', {}) # Not in Java job types but present for all others input_id = data.get('input_id', None) output_id = data.get('output_id', None) # Since we will use a unified class in the database, we pass # a superset for all job types # example configs['start'] = '2015-05-12T08:55Z' frequency = 5 mins # the job will starts from 2015-05-12T08:55Z, runs every 5 mins job_execution_info = data.get('job_execution_info', {}) configs['job_execution_info'] = job_execution_info job_ex_dict = { 'input_id': input_id, 'output_id': output_id, 'job_id': job_templates_id, 'cluster_id': cluster_id, 'info': { 'status': edp.JOB_STATUS_PENDING }, 'job_configs': configs, 'extra': {}, 'interface': interface } job_execution = conductor.job_execution_create(context.ctx(), job_ex_dict) context.set_current_job_execution_id(job_execution.id) # check to use proxy user if p.job_execution_requires_proxy_user(job_execution): try: p.create_proxy_user_for_job_execution(job_execution) except ex.SaharaException as e: LOG.error("Can't run job execution. " "(Reasons: {reason})".format(reason=e)) conductor.job_execution_destroy(context.ctx(), job_execution) raise e api.OPS.run_edp_job(job_execution.id) return job_execution