Exemple #1
0
class TestWorkflowPlan(unittest.TestCase):
    def setUp(self):
        self.env = simpy.Environment()
        self.cluster = Cluster(self.env, CLUSTER_CONFIG)
        self.planner = Planner(self.env, PLAN_ALGORITHM, self.cluster)
        self.observation = Observation('planner_observation',
                                       OBS_START_TME,
                                       OBS_DURATION,
                                       OBS_DEMAND,
                                       OBS_WORKFLOW,
                                       type=None,
                                       data_rate=None)

    def tearDown(self):
        pass

    def testWorkflowPlanCreation(self):
        plan = self.planner.plan(self.observation.name,
                                 self.observation.workflow, 'heft')
        expected_exec_order = [0, 5, 3, 4, 2, 1, 6, 8, 7, 9]
        self.assertEqual(len(plan.tasks), len(expected_exec_order))
        for x in range(len(plan.tasks)):
            self.assertEqual(plan.tasks[x].id, expected_exec_order[x])
        # Get taskid 5
        task5_comp = plan.tasks[5].flops
        self.assertEqual(task5_comp, 92000)
Exemple #2
0
class TestPlanner(unittest.TestCase):
    def setUp(self):
        self.env = simpy.Environment()
        sched_algorithm = FifoAlgorithm()
        self.planner = Planner(self.env, PLAN_ALGORITHM, MACHINE_CONFIG)
        self.cluster = Cluster(self.env, CLUSTER_CONFIG)
        # self.buffer = Buffer(self.env, self.cluster)
        # self.algorithms = Scheduler(self.env,
        # sched_algorithm, self.buffer, self.cluster)
        self.observation = Observation('planner_observation', OBS_START_TME,
                                       OBS_DURATION, OBS_DEMAND, OBS_WORKFLOW)
        pass

    def tearDown(self):
        pass

    def testShadowIntegration(self):
        pass

    def testPlanReadsFromFile(self):
        # Return a "Plan" object for provided workflow/observation
        plan = self.planner.plan(self.observation.name,
                                 self.observation.workflow, PLAN_ALGORITHM)
        self.assertEqual(plan.id,
                         'planner_observation')  # Expected ID for the workflow
        self.assertEqual(plan.makespan,
                         98)  # Expected makespan for the given graph

    def testPlannerRun(self):
        next(self.planner.run(self.observation))
        # because run() is a generator (we call yield for simpy), we use(next()) to 'get the return value',
        # and thus run the rest of the code in run()
        # next(val)
        self.assertTrue(self.observation.plan is not None)

    def testGracefulExit(self):
        pass

    def testIncorrectParameters(self):
        pass