def test_random_cluster_multi(self): urls = ['http://localhost:8529', 'http://localhost:8530'] cluster = RandomCluster(urls) seen = {} for i in range(100): url = cluster.select_next_url() self.assertIn(url, urls) seen[url] = True if len(seen) == 2: break self.assertEqual(len(seen), 2, seen)
def test_random_cluster_single(self): cluster = RandomCluster(urls=['http://localhost:8529']) self.assertIsNotNone(cluster) url = cluster.select_next_url() self.assertEqual(url, 'http://localhost:8529')