Пример #1
0
    def test_failing_workflow_run(self):
        with TestAreaContext("python/job_queue/workflow") as work_area:
            WorkflowCommon.createExternalDumpJob()

            joblist = WorkflowJoblist()
            self.assertTrue(joblist.addJobFromFile("DUMP", "dump_job"))
            self.assertTrue("DUMP" in joblist)

            workflow = Workflow("undefined", joblist)
            context = SubstitutionList()

            self.assertFalse(workflow.run(None, verbose=True, context=context))
Пример #2
0
    def test_error_handling_external_job(self):

        with TestAreaContext("python/job_queue/workflow_job"):
            WorkflowCommon.createExternalDumpJob()

            config = self._alloc_config()
            job = self._alloc_from_file("DUMP", config, "dump_failing_job")

            self.assertFalse(job.isInternal())
            job.argumentTypes()
            self.assertIsNone(job.run(None, []))
            self.assertTrue(job.stderrdata().startswith("Traceback"))
Пример #3
0
    def test_run_external_job(self):

        with TestAreaContext("python/job_queue/workflow_job"):
            WorkflowCommon.createExternalDumpJob()

            config = self._alloc_config()
            job = self._alloc_from_file("DUMP", config, "dump_job")

            self.assertFalse(job.isInternal())
            argTypes = job.argumentTypes()
            self.assertEqual(argTypes, [str, str])
            self.assertIsNone(job.run(None, ["test", "text"]))
            self.assertEqual(job.stdoutdata(), "Hello World\n")

            with open("test", "r") as f:
                self.assertEqual(f.read(), "text")
Пример #4
0
    def test_workflow_failed_job(self):
        with TestAreaContext("python/job_queue/workflow_runner_fails"):
            WorkflowCommon.createExternalDumpJob()

            joblist = WorkflowJoblist()
            self.assertTrue(joblist.addJobFromFile("DUMP", "dump_failing_job"))
            workflow = Workflow("dump_workflow", joblist)
            self.assertEqual(len(workflow), 2)

            workflow_runner = WorkflowRunner(
                workflow, ert=None, context=SubstitutionList()
            )

            self.assertFalse(workflow_runner.isRunning())
            with patch.object(
                Workflow, "run", side_effect=Exception("mocked workflow error")
            ), workflow_runner:
                workflow_runner.wait()
                self.assertNotEqual(workflow_runner.exception(), None)
Пример #5
0
    def test_workflow_joblist_with_files(self):
        with TestAreaContext("python/job_queue/workflow_joblist") as work_area:
            WorkflowCommon.createErtScriptsJob()
            WorkflowCommon.createExternalDumpJob()
            WorkflowCommon.createInternalFunctionJob()

            joblist = WorkflowJoblist()

            joblist.addJobFromFile("DUMP_JOB", "dump_job")
            joblist.addJobFromFile("SELECT_CASE_JOB", "select_case_job")
            joblist.addJobFromFile("SUBTRACT_SCRIPT_JOB",
                                   "subtract_script_job")

            self.assertTrue("DUMP_JOB" in joblist)
            self.assertTrue("SELECT_CASE_JOB" in joblist)
            self.assertTrue("SUBTRACT_SCRIPT_JOB" in joblist)

            self.assertFalse((joblist["DUMP_JOB"]).isInternal())
            self.assertTrue((joblist["SELECT_CASE_JOB"]).isInternal())
            self.assertTrue((joblist["SUBTRACT_SCRIPT_JOB"]).isInternal())
Пример #6
0
    def test_workflow_run(self):
        with TestAreaContext("python/job_queue/workflow") as work_area:
            WorkflowCommon.createExternalDumpJob()

            joblist = WorkflowJoblist()
            self.assertTrue(joblist.addJobFromFile("DUMP", "dump_job"))
            self.assertTrue("DUMP" in joblist)

            workflow = Workflow("dump_workflow", joblist)

            self.assertTrue(len(workflow), 2)

            context = SubstitutionList()
            context.addItem("<PARAM>", "text")

            self.assertTrue(workflow.run(None, verbose=True, context=context))

            with open("dump1", "r") as f:
                self.assertEqual(f.read(), "dump_text_1")

            with open("dump2", "r") as f:
                self.assertEqual(f.read(), "dump_text_2")
Пример #7
0
    def test_workflow(self):
        with TestAreaContext("python/job_queue/workflow") as work_area:
            WorkflowCommon.createExternalDumpJob()

            joblist = WorkflowJoblist()
            self.assertTrue(joblist.addJobFromFile("DUMP", "dump_job"))

            with self.assertRaises(UserWarning):
                joblist.addJobFromFile("KNOCK", "knock_job")

            self.assertTrue("DUMP" in joblist)

            workflow = Workflow("dump_workflow", joblist)

            self.assertEqual(len(workflow), 2)

            job, args = workflow[0]
            self.assertEqual(job, joblist["DUMP"])
            self.assertEqual(args[0], "dump1")
            self.assertEqual(args[1], "dump_text_1")

            job, args = workflow[1]
            self.assertEqual(job, joblist["DUMP"])