Ejemplo n.º 1
0
    def test_workflow_processor(self):
        "Simple tests to make sure the WorkflowProcessor works"

        wf_uuid = "d8f8e15c-a55f-4ca0-8474-62bdb3310083"
        e = ensembles.Ensemble(self.username, "foo")
        db.session.add(e)
        db.session.flush()

        ew = ensembles.EnsembleWorkflow(e.id, "bar")
        ew.wf_uuid = wf_uuid
        db.session.add(ew)
        db.session.flush()

        p = em.WorkflowProcessor(ew)
        self.assertRaises(em.EMException, p.run)

        ew.submitdir = "/some/path/not/existing"
        db.session.flush()

        self.assertRaises(em.EMException, p.run)

        p = em.WorkflowProcessor(ew)
        self.assertTrue(p.pending())
        self.assertRaises(em.EMException, p.running)
        self.assertRaises(em.EMException, p.running_successful)

        dw = dash.DashboardWorkflow()
        dw.wf_uuid = wf_uuid
        db.session.add(dw)
        db.session.flush()

        ws = dash.DashboardWorkflowstate()
        ws.wf_id = dw.wf_id
        ws.state = 'WORKFLOW_STARTED'
        ws.restart_count = 0
        ws.status = 0
        db.session.add(ws)
        db.session.flush()

        p = em.WorkflowProcessor(ew)
        self.assertTrue(p.running())
        self.assertRaises(em.EMException, p.running_successful)

        ws.state = 'WORKFLOW_TERMINATED'
        ws.status = 0
        db.session.flush()

        self.assertFalse(p.running())
        self.assertTrue(p.running_successful())

        ws.status = 1
        db.session.flush()

        self.assertFalse(p.running_successful())
Ejemplo n.º 2
0
    def test_failed_workflow(self):
        # This workflow should fail because the argument to the ls job is invalid
        dax = StringIO("""<?xml version="1.0" encoding="UTF-8"?>
            <adag xmlns="http://pegasus.isi.edu/schema/DAX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://pegasus.isi.edu/schema/DAX http://pegasus.isi.edu/schema/dax-3.4.xsd"
                  version="3.4" name="process">
                <job id="ID0000001" name="ls">
                    <argument>-l /path/that/does/not/exist</argument>
                    <stdout name="listing.txt" link="output"/>
                    <uses name="listing.txt" link="output" register="false" transfer="true"/>
                </job>
            </adag>
        """)

        e, ew = self.create_test_workflow(dax)

        p = em.WorkflowProcessor(ew)

        p.plan()
        while p.planning():
            time.sleep(1)

        self.assertTrue(p.planning_successful(), "Planning should succeed")

        submitdir = p.get_submitdir()
        self.assertTrue(os.path.isdir(submitdir), "Submit dir should exist")

        wf_uuid = p.get_wf_uuid()
        self.assertTrue(wf_uuid is not None, "wf_uuid should exist")

        # The ensemble processor normally does this
        ew.set_submitdir(submitdir)
        ew.set_wf_uuid(wf_uuid)
        db.session.flush()
        db.session.commit()

        p.run()

        while p.pending() or p.running():
            time.sleep(5)

        self.assertFalse(p.running_successful(),
                         "The workflow should fail to run")
Ejemplo n.º 3
0
    def test_successful_workflow(self):
        # This workflow should succeed
        dax = StringIO("""<?xml version="1.0" encoding="UTF-8"?>
            <adag xmlns="http://pegasus.isi.edu/schema/DAX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://pegasus.isi.edu/schema/DAX http://pegasus.isi.edu/schema/dax-3.4.xsd"
                  version="3.4" name="process">
                <job id="ID0000001" name="ls">
                    <argument>-l /</argument>
                    <stdout name="listing.txt" link="output"/>
                    <uses name="listing.txt" link="output" register="false" transfer="true"/>
                </job>
            </adag>
        """)

        e, ew = self.create_test_workflow(dax)

        p = em.WorkflowProcessor(ew)

        p.plan()
        while p.planning():
            time.sleep(1)

        self.assertTrue(p.planning_successful())

        submitdir = p.get_submitdir()
        self.assertTrue(os.path.isdir(submitdir))

        wf_uuid = p.get_wf_uuid()
        self.assertTrue(wf_uuid is not None)

        ew.set_submitdir(submitdir)
        ew.set_wf_uuid(wf_uuid)
        db.session.flush()

        db.session.commit()

        p.run()

        while p.pending() or p.running():
            time.sleep(5)

        self.assertTrue(p.running_successful())
Ejemplo n.º 4
0
    def test_planner_fails(self):
        # This should fail to plan because the dax has an unknown transformation
        dax = StringIO("""<?xml version="1.0" encoding="UTF-8"?>
            <adag xmlns="http://pegasus.isi.edu/schema/DAX" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://pegasus.isi.edu/schema/DAX http://pegasus.isi.edu/schema/dax-3.4.xsd"
                  version="3.4" name="process">
                <job id="ID0000001" name="FROOB">
                    <argument>-l /</argument>
                    <stdout name="listing.txt" link="output"/>
                    <uses name="listing.txt" link="output" register="false" transfer="true"/>
                </job>
            </adag>
        """)

        e, ew = self.create_test_workflow(dax)

        p = em.WorkflowProcessor(ew)

        p.plan()
        while p.planning():
            time.sleep(1)

        self.assertFalse(p.planning_successful(),
                         "Workflow should fail to plan")