def testGetTaskHeaders(self): mr_spec = model.MapreduceSpec( name="foo", mapreduce_id="foo_id", mapper_spec=model.MapperSpec("foo", "foo", {}, 8).to_json() ) task = taskqueue.Task(url="/relative_url", headers=util._get_task_headers(mr_spec)) self.assertEqual("foo_id", task.headers[util._MR_ID_TASK_HEADER]) self.assertEqual("v7.foo-module.foo.appspot.com", task.headers["Host"]) self.assertEqual("v7.foo-module", task.target)
def testGetTaskHeaders(self): mr_spec = model.MapreduceSpec(name="foo", mapreduce_id="foo_id", mapper_spec=model.MapperSpec( "foo", "foo", {}, 8).to_json()) task = taskqueue.Task(url="/relative_url", headers=util._get_task_headers( mr_spec.mapreduce_id)) self.assertEqual("foo_id", task.headers[util._MR_ID_TASK_HEADER]) self.assertEqual("v7.foo-module.foo.appspot.com", task.headers["Host"]) self.assertEqual("v7.foo-module", task.target)
def __add_kickoff_task(cls, job_config, mapreduce_spec): """Add kickoff task to taskqueue. Args: job_config: map_job.JobConfig. mapreduce_spec: model.MapreduceSpec, """ params = {"mapreduce_id": job_config.job_id} # Task is not named so that it can be added within a transaction. kickoff_task = taskqueue.Task( # TODO(user): Perhaps make this url a computed field of job_config. url=job_config._base_path + "/kickoffjob_callback/" + job_config.job_id, headers=util._get_task_headers(job_config.job_id), params=params) if job_config._hooks_cls: hooks = job_config._hooks_cls(mapreduce_spec) try: hooks.enqueue_kickoff_task(kickoff_task, job_config.queue_name) return except NotImplementedError: pass kickoff_task.add(job_config.queue_name, transactional=True)