Beispiel #1
0
class TestIngest(unittest.TestCase):

	def setUp(self) -> None:
		self.env = simpy.Environment()
		self.cluster = Cluster(env=self.env, spec=CLUSTER_CONFIG)
		self.observation = Observation(
			'planner_observation',
			OBS_START_TME,
			OBS_DURATION,
			OBS_DEMAND,
			OBS_WORKFLOW,
			type=None,
			data_rate=None
		)

	def testClusterCheckIngest(self):
		retval = self.cluster.check_ingest_capacity(pipeline_demand=5)
		self.assertTrue(retval)

	def testClusterProvisionIngest(self):
		duration = self.observation.duration
		pipeline_demand = 5
		self.env.process(self.cluster.run())
		peek = self.env.peek()
		self.env.process(self.cluster.provision_ingest_resources(
			pipeline_demand,
			duration)
		)
		self.env.run(until=1)
		self.assertEqual(1, self.env.now)
		# self.process(self.run_ingest(duration,pipeline_demand))
		# for task in self.cluster.running_tasks:
		#  	self.assertEqual(TaskStatus.RUNNING, task.task_status)
		self.assertEqual(5, len(self.cluster.available_resources))
		self.assertEqual(5, len(self.cluster.running_tasks))
		self.env.run(until=10)
		self.assertEqual(5, len(self.cluster.available_resources))
		self.env.run(until=20)
		self.assertEqual(10,len(self.cluster.available_resources))
		self.assertEqual(20,self.env.now)

	def run_ingest(self, duration,demand):
		retval = self.cluster.provision_ingest_resources(
			demand,
			duration
		)
		for task in self.cluster.running_tasks:
			self.assertEqual(TaskStatus.SCHEDULED, task.task_status)
Beispiel #2
0
class TestIngest(unittest.TestCase):
    def setUp(self) -> None:
        """
        Setup a cluster and a simulation environment to test ingest pipelines
        """
        self.env = simpy.Environment()
        config = Config(CONFIG)

        self.cluster = Cluster(env=self.env, config=config)
        self.telescope = Telescope(self.env,
                                   config,
                                   planner=None,
                                   scheduler=None)
        self.observation = self.telescope.observations[0]

    def testClusterCheckIngest(self):
        """
        Need to determine that the cluster is able to deal with the pipeline
        requirement

        in addition, need to check that we are not going over the maximum
        number of resources that can be feasibly allocated to ingest.
        Returns
        -------

        """
        max_ingest = 5
        retval = self.cluster.check_ingest_capacity(5, max_ingest)
        self.assertTrue(retval)

    def testClusterProvisionIngest(self):
        """

        Notes:

        When we run this test, we have the simulation run 'until time 10'.
        AS Far as the simulation is concerned, we this occurs 'before' 10
        seconds in simtime; however, the rest of the simulation is
        operating AT time = 10, which is when the tasks are "Due" to
        finish. Here we are running the tasks for "1 -timestep less" than
        is necessary, but within the simulation time this allows us to run
        "on time". I.e. at time = 10 (in the simulation), there _will_ be
        10 resources available, because it's the time period in which all
        ingest tasks will finish. However, in real terms, these tasks
        technically finished one timestep earlier.

        Returns
        -------

        """
        pipeline_demand = 5
        self.env.process(self.cluster.run())
        peek = self.env.peek()
        self.env.process(
            self.cluster.provision_ingest_resources(pipeline_demand,
                                                    self.observation))
        self.env.run(until=1)
        self.assertEqual(1, self.env.now)
        self.assertEqual(5, len(self.cluster._resources['available']))
        self.assertEqual(5, len(self.cluster._tasks['running']))
        self.assertEqual(5, len(self.cluster._resources['available']))
        self.env.run(until=11)
        self.assertEqual(10, len(self.cluster._resources['available']))

    def test_ingest_capacity_check(self):
        """
        Given a pipeline demand that is too great, return 'false' to ensure
        that we do not attempt to run observations.
        """

        pipeline_demand = 11
        max_ingest = 5
        self.assertFalse(
            self.cluster.check_ingest_capacity(pipeline_demand, max_ingest))

    def test_ingest_demand_exceeds_cluster_capacity_runtime(self):
        """
        If we have a pipeline that requests too many ingest pipelines then we
        need to reject its observation. If - for some unknown reasons - we
        do not call this check, make sure the simulation fails at runtime.

        Returns
        -------
        """
        pipeline_demand = 11
        self.env.process(
            self.cluster.provision_ingest_resources(pipeline_demand,
                                                    self.observation))
        self.assertRaises(RuntimeError, self.env.run, until=1)