Esempio n. 1
0
    def test_update_status_can_be_roundtripped_40214(self):
        complete_job_xml = pkg_resources.resource_string(
            'bkr.inttest', 'job_40214.xml')
        xmljob = XmlJob(xmltramp.parse(complete_job_xml))

        data_setup.create_tasks(xmljob)
        session.flush()

        # Import the job xml
        job = self.controller.process_xmljob(xmljob, self.user)
        session.flush()

        # Mark job waiting
        data_setup.mark_job_waiting(job)
        session.flush()

        # watchdog's should exist
        self.assertNotEqual(len(watchdogs_for_job(job)), 0)

        # Play back the original jobs results and status
        data_setup.playback_job_results(job, xmljob)
        session.flush()

        # Verify that the original status and results match
        self.assertEquals(TaskStatus.from_string(xmljob.wrappedEl('status')),
                          job.status)
        self.assertEquals(TaskResult.from_string(xmljob.wrappedEl('result')),
                          job.result)
        for i, recipeset in enumerate(xmljob.iter_recipeSets()):
            for j, recipe in enumerate(recipeset.iter_recipes()):
                self.assertEquals(
                    TaskStatus.from_string(recipe.wrappedEl('status')),
                    job.recipesets[i].recipes[j].status)
                self.assertEquals(
                    TaskResult.from_string(recipe.wrappedEl('result')),
                    job.recipesets[i].recipes[j].result)
                for k, task in enumerate(recipe.iter_tasks()):
                    self.assertEquals(
                        TaskStatus.from_string(task.status),
                        job.recipesets[i].recipes[j].tasks[k].status)
                    self.assertEquals(
                        TaskResult.from_string(task.result),
                        job.recipesets[i].recipes[j].tasks[k].result)

        # No watchdog's should exist when the job is complete
        self.assertEquals(len(watchdogs_for_job(job)), 0)
    def test_finished_recipe_with_unstarted_guests(self):
        # host completes, but guest never started
        job = data_setup.create_job(num_recipes=1, num_guestrecipes=1)
        data_setup.mark_job_waiting(job)
        data_setup.mark_recipe_running(job.recipesets[0].recipes[0], only=True)
        job.recipesets[0].recipes[0].tasks[-1].stop()
        job.update_status()
        self.assertEquals(job.recipesets[0].recipes[0].status, TaskStatus.completed)
        self.assertEquals(job.recipesets[0].recipes[0].guests[0].status, TaskStatus.aborted)

        # host aborts, but guest never started
        job = data_setup.create_job(num_recipes=1, num_guestrecipes=1)
        data_setup.mark_job_waiting(job)
        job.recipesets[0].recipes[0].abort(msg="blorf")
        job.update_status()
        self.assertEquals(job.recipesets[0].recipes[0].status, TaskStatus.aborted)
        self.assertEquals(job.recipesets[0].recipes[0].guests[0].status, TaskStatus.aborted)
Esempio n. 3
0
    def test_finished_recipe_with_unstarted_guests(self):
        # host completes, but guest never started
        job = data_setup.create_job(num_recipes=1, num_guestrecipes=1)
        data_setup.mark_job_waiting(job)
        data_setup.mark_recipe_running(job.recipesets[0].recipes[0], only=True)
        job.recipesets[0].recipes[0].tasks[-1].stop()
        job.update_status()
        self.assertEquals(job.recipesets[0].recipes[0].status,
                          TaskStatus.completed)
        self.assertEquals(job.recipesets[0].recipes[0].guests[0].status,
                          TaskStatus.aborted)

        # host aborts, but guest never started
        job = data_setup.create_job(num_recipes=1, num_guestrecipes=1)
        data_setup.mark_job_waiting(job)
        job.recipesets[0].recipes[0].abort(msg='blorf')
        job.update_status()
        self.assertEquals(job.recipesets[0].recipes[0].status,
                          TaskStatus.aborted)
        self.assertEquals(job.recipesets[0].recipes[0].guests[0].status,
                          TaskStatus.aborted)
Esempio n. 4
0
    def test_update_status_can_be_roundtripped_40214(self):
        complete_job_xml = pkg_resources.resource_string('bkr.inttest', 'job_40214.xml')
        xmljob = XmlJob(xmltramp.parse(complete_job_xml))

        data_setup.create_tasks(xmljob)
        session.flush()
        
        # Import the job xml
        job = self.controller.process_xmljob(xmljob, self.user)
        session.flush()

        # Mark job waiting
        data_setup.mark_job_waiting(job)
        session.flush()

        # watchdog's should exist 
        self.assertNotEqual(len(watchdogs_for_job(job)), 0)

        # Play back the original jobs results and status
        data_setup.playback_job_results(job, xmljob)
        session.flush()
        
        # Verify that the original status and results match
        self.assertEquals(TaskStatus.from_string(xmljob.wrappedEl('status')), job.status)
        self.assertEquals(TaskResult.from_string(xmljob.wrappedEl('result')), job.result)
        for i, recipeset in enumerate(xmljob.iter_recipeSets()):
            for j, recipe in enumerate(recipeset.iter_recipes()):
                self.assertEquals(TaskStatus.from_string(recipe.wrappedEl('status')),
                        job.recipesets[i].recipes[j].status)
                self.assertEquals(TaskResult.from_string(recipe.wrappedEl('result')),
                        job.recipesets[i].recipes[j].result)
                for k, task in enumerate(recipe.iter_tasks()):
                    self.assertEquals(TaskStatus.from_string(task.status),
                            job.recipesets[i].recipes[j].tasks[k].status)
                    self.assertEquals(TaskResult.from_string(task.result),
                            job.recipesets[i].recipes[j].tasks[k].result)

        # No watchdog's should exist when the job is complete
        self.assertEquals(len(watchdogs_for_job(job)), 0)
    def test_update_status_can_be_roundtripped_40214(self):
        complete_job_xml = pkg_resources.resource_string("bkr.inttest", "job_40214.xml")
        xmljob = lxml.etree.fromstring(complete_job_xml)

        data_setup.create_tasks(xmljob)
        session.flush()

        # Import the job xml
        job = self.controller.process_xmljob(xmljob, self.user)
        session.flush()

        # Mark job waiting
        data_setup.mark_job_waiting(job)
        session.flush()

        # watchdog's should exist
        self.assertNotEqual(len(watchdogs_for_job(job)), 0)

        # Play back the original jobs results and status
        data_setup.playback_job_results(job, xmljob)
        session.flush()

        # Verify that the original status and results match
        self.assertEquals(TaskStatus.from_string(xmljob.get("status")), job.status)
        self.assertEquals(TaskResult.from_string(xmljob.get("result")), job.result)
        for i, recipeset in enumerate(xmljob.xpath("recipeSet")):
            for j, recipe in enumerate(recipeset.xpath("recipes")):
                self.assertEquals(TaskStatus.from_string(recipe.get("status")), job.recipesets[i].recipes[j].status)
                self.assertEquals(TaskResult.from_string(recipe.get("result")), job.recipesets[i].recipes[j].result)
                for k, task in enumerate(recipe.xpath("task")):
                    self.assertEquals(
                        TaskStatus.from_string(task.get("status")), job.recipesets[i].recipes[j].tasks[k].status
                    )
                    self.assertEquals(
                        TaskResult.from_string(task.get("result")), job.recipesets[i].recipes[j].tasks[k].result
                    )

        # No watchdog's should exist when the job is complete
        self.assertEquals(len(watchdogs_for_job(job)), 0)