def test_distribute_error(self): solver = MaxFlowSolver.from_nodes(self.cluster.nodes, self.new_nodes[:2]) dist = solver.get_distribution() self.assertEqual(len(sum(dist["masters"], [])), 3) self.assertEqual(len(sum(dist["slaves"], [])), 0) self.assertEqual(len(sum(dist["frees"], [])), 2) with self.assertRaises(DistributionError): solver.distribute_slaves()
def test_distribute(self): solver = MaxFlowSolver.from_nodes(self.cluster.nodes, self.new_nodes) dist = solver.get_distribution() self.assertEqual(len(sum(dist['masters'], [])), 3) self.assertEqual(len(sum(dist['slaves'], [])), 0) self.assertEqual(len(sum(dist['frees'], [])), 3) result, frees = solver.distribute_slaves() self.assertEqual(len(frees), 0) self.assertEqual(len(result), 3)
def test_distribute_error(self): solver = MaxFlowSolver.from_nodes(self.cluster.nodes, self.new_nodes[:2]) dist = solver.get_distribution() self.assertEqual(len(sum(dist['masters'], [])), 3) self.assertEqual(len(sum(dist['slaves'], [])), 0) self.assertEqual(len(sum(dist['frees'], [])), 2) with self.assertRaises(DistributionError): solver.distribute_slaves()
def test_distribute(self): solver = MaxFlowSolver.from_nodes(self.cluster.nodes, self.new_nodes) dist = solver.get_distribution() self.assertEqual(len(sum(dist["masters"], [])), 3) self.assertEqual(len(sum(dist["slaves"], [])), 0) self.assertEqual(len(sum(dist["frees"], [])), 3) result, frees = solver.distribute_slaves() self.assertEqual(len(frees), 0) self.assertEqual(len(result), 3)