Exemplo n.º 1
0
    def test_em(self):
        # Create an ensemble and a workflow
        e = ensembles.Ensemble(self.username, "foo")
        e.set_max_planning(1)
        e.set_max_running(1)
        db.session.add(e)
        db.session.flush()

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

        w2 = ensembles.EnsembleWorkflow(e.id, "baz")
        db.session.add(w2)
        db.session.flush()

        mgr = em.EnsembleManager()

        e.set_state(ensembles.EnsembleStates.PAUSED)
        db.session.flush()

        mgr.loop_once()
        self.assertEquals(w.state, ensembles.EnsembleWorkflowStates.READY,
                          "State should still be READY")
        self.assertEquals(w2.state, ensembles.EnsembleWorkflowStates.READY,
                          "State should still be READY")

        e.set_state(ensembles.EnsembleStates.ACTIVE)
        db.session.flush()

        mgr.loop_once()
        self.assertEquals(w.state, ensembles.EnsembleWorkflowStates.PLANNING,
                          "State should be PLANNING")
        self.assertEquals(w2.state, ensembles.EnsembleWorkflowStates.READY,
                          "State should be READY")

        mgr.loop_once()
        self.assertEquals(w.state, ensembles.EnsembleWorkflowStates.RUNNING,
                          "State should be RUNNING")
        self.assertEquals(w.submitdir, "submitdir", "Submitdir should be set")
        self.assertEquals(w.wf_uuid, "d8f8e15c-a55f-4ca0-8474-62bdb3310083",
                          "UUID should be set")
        self.assertEquals(w2.state, ensembles.EnsembleWorkflowStates.PLANNING,
                          "State should be PLANNING")

        mgr.loop_once()
        self.assertEquals(w.state, ensembles.EnsembleWorkflowStates.SUCCESSFUL,
                          "State should be SUCCESSFUL")
        self.assertEquals(w2.state, ensembles.EnsembleWorkflowStates.RUNNING,
                          "State should be RUNNING")

        mgr.loop_once()
        self.assertEquals(w2.state,
                          ensembles.EnsembleWorkflowStates.SUCCESSFUL,
                          "State should be SUCCESSFUL")
Exemplo n.º 2
0
    def test_hierarchical_workflow(self):
        subdax = """<?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>
        """

        subdaxfile = os.path.join(self.tmpdir, "subdax.xml")
        f = open(subdaxfile, "w")
        f.write(subdax)
        f.close()

        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">
                <file name="subdax.xml">
                    <pfn url="file://%s" site="local"/>
                </file>
                <dax id="ID0000001" file="subdax.xml">
                </dax>
            </adag>
        """ % subdaxfile)

        e, ew = self.create_test_workflow(dax)

        mgr = em.EnsembleManager()

        while ew.state not in self.endstates:
            mgr.loop_once()
            time.sleep(5)

        self.assertEquals(ew.state,
                          ensembles.EnsembleWorkflowStates.SUCCESSFUL)
Exemplo n.º 3
0
    def test_ensemble_failure_end_to_end(self):
        # This workflow should fail because of the argument to ls
        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 /some/non/existent/directory</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)

        mgr = em.EnsembleManager()

        while ew.state not in self.endstates:
            mgr.loop_once()
            time.sleep(5)

        self.assertEqual(ew.state, ensembles.EnsembleWorkflowStates.FAILED)