def test_get_idle_host(self): top = make_topology(1) state = State(top, None, {}, True, True) self.assertEqual(set(state.get_idle()), set(state.original_topology)) state.progress.running = set(state.original_topology) self.assertEqual(set(state.get_idle()), set())
def test_is_healthy_is_true_when_running_jobs_take_down_host(self): top = make_topology(3, True) state = State(top, None, {}, True, True, progress=Progress(running=set(top.get_down()))) self.assertEqual(state.is_healthy(), True)
def test_healthy_cluster(self): top = make_topology(2, True) down = set(top.get_down()) state = State(top, None, {}, True, True, progress=Progress(running=down)) self.assertEqual(state.is_healthy(), True)
def test_down_host(self): top = make_topology(2, True) state = State(top, None, {}, True, True) self.assertEqual( state.current_topology.get_down(), Topology((Host("a0", "1.2.3.0", "eu", "cluster1", 0, False), Host("a1", "1.2.3.1", "eu", "cluster1", 100, False))))
def test_one(self): top = make_topology(size=3) state = State(top, Strategy.ONE, None, False, False) state = add_work(state) self.assertEqual(len(state.progress.running), 1) state = finish_work(state) state = add_work(state) self.assertEqual(len(state.progress.running), 1)
def test_all_per_cluster(self): top = make_topology(size=3) state = State(top, Strategy.ALL, None, False, True) state = add_work(state) self.assertEqual(len(state.progress.running), 6) state = finish_work(state) state = add_work(state) self.assertEqual(len(state.progress.running), 6)
def test_topology_all_serial(self): top = make_topology(size=12) mapping = make_mapping(top) state = State(top, Strategy.TOPOLOGY, mapping, False, False) laps = 0 while True: state = add_work(state) if len(state.progress.running) == 0: break laps = laps + 1 self.assertEqual(len(state.progress.running), 4) state = finish_work(state) self.assertEqual(12, laps)
def test_max_concurrency(self): top = make_topology(size=3) state = State(top, Strategy.ALL, None, True, True, 10) state = add_work(state) self.assertEqual(len(state.progress.running), 10)
def test_unhealthy_cluster(self): top = make_topology(2, True) state = State(top, None, {}, True, True) self.assertEqual(state.is_healthy(), False)
def test_is_healthy_false(self): top = make_topology(3, True) state = State(top, None, {}, True, True) self.assertEqual(state.is_healthy(), False)