예제 #1
0
    def test_probe_load_estimates(self):
        server = simulation.Server("test", self.stats_manager, 1)
        simulation.set_param("load_metric", "estimate")
        # Ensure that estimates are being incorporated into load.
        self.assertEquals(0, server.probe_load(0, 0))
        self.assertEquals(1, server.probe_load(0, 2))
        self.assertEquals(2, server.probe_load(0, 14))
        self.assertEquals(2, server.probe_load(0, 20))

        # Now ensure that actual queue length is being incorporated as well.
        server.queued_tasks = 5
        self.assertEquals(7, server.probe_load(0, 25))
예제 #2
0
    def test_probe_load_per_user_weighted_incorporates_task_count(self):
        simulation.set_param("load_metric", "per_user_estimate")
        simulation.set_param("relative_weights", "2,2")
        server = simulation.Server("test", self.stats_manager, 2)
        server.current_user = 0
        server.task_count = 2
        server.queued_tasks = 2
        server.running_tasks = 1

        num_jobs_per_user = [1, 1]
        for user, num_jobs in enumerate(num_jobs_per_user):
            for i in range(num_jobs):
                server.queues[user].append("foo")

        current_time = 0
        self.assertEqual(3, server.probe_load(0, current_time))
        self.assertEqual(2, server.probe_load(1, current_time))
예제 #3
0
    def test_probe_load_per_user_weighted(self):
        simulation.set_param("load_metric", "per_user_estimate")
        simulation.set_param("relative_weights", "2,1,1,4,5")
        server = simulation.Server("test", self.stats_manager, 5)
        server.current_user = 3
        server.task_count = 2
        server.running_tasks = 1
        server.queued_tasks = 15

        # Add fake jobs to the queues on the server (ok to just use strings
        # in the queue, since probe load only looks at the queue length).
        num_jobs_per_user = [1, 3, 2, 5, 4]
        for user, num_jobs in enumerate(num_jobs_per_user):
            for i in range(num_jobs):
                server.queues[user].append("foo")

        current_time = 0
        self.assertEqual(8, server.probe_load(0, current_time))
        self.assertEqual(16, server.probe_load(1, current_time))
        self.assertEqual(16, server.probe_load(2, current_time))
        self.assertEqual(13, server.probe_load(3, current_time))
        self.assertEqual(7, server.probe_load(4, current_time))