Ejemplo n.º 1
0
    def get_job_info(self, job_id):
        """Return a json-dict of the specific job.

        Args:
            job_id (String): id of the job
        Return:
            job_dict (dict): the info of job
        """
        job = self.db_manager.get_job_by_id(job_id)
        job_dict = Job.to_json(job, True)
        return job_dict
Ejemplo n.º 2
0
    def get_job_list(self):
        """Return a list of job objects in json format.

        Return:
            job_list (list of dict): info of all jobs in database
        """
        logger = Logger().get()
        logger.debug("start get_job_list")

        job_object_list = self.get_all_jobs_with_tasks()

        job_list = []
        for job in job_object_list:
            job_list.append(Job.to_json(job))

        return job_list
Ejemplo n.º 3
0
    def test_job_status(self):
        self.resource_manager.remove_all_jobs_and_tasks()

        # Create a job with two tasks
        task_json = {
            "Files": {},
            "Program_Name": "ooanalyzer",
            "Input_File_Args": {
                "-f": "oo.exe"
            },
            "Input_Text_Args": {
                "--timeout": "300"
            },
            "Input_Flag_Args": ["-v"],
            "Output_File_Args": {
                "-j": "output.json",
                "-F": "facts",
                "-R": "results"
            }
        }
        input_json = {
            "Job_Name": "dump_job",
            "Job_Comment": "this is the test json input for job manager",
            "Tasks": [task_json, task_json, task_json]
        }
        job = self.resource_manager.save_new_job_and_tasks(input_json)
        print(Job.to_json(job))
        job_id = job.job_id

        # Initialize the metadata in JM
        self.job_manager.initialize_job(job)
        job = self.resource_manager.get_job_by_id(job_id)
        self.assertEqual(job.status, Status.Running)

        # Finish all tasks
        for task in job.tasks:
            task_id = task.task_id
            self.resource_manager.update_task_status(task_id,
                                                     Status.Successful)
            self.job_manager.finish_task(task_id)

        job = self.resource_manager.get_job_by_id(job_id)
        self.assertEqual(job.status, Status.Finished)