def test_random_lb_with_lite_members(self):
        cluster = _MockClusterService(0, 3)
        lb = RandomLB()
        lb.init(cluster)

        for _ in range(10):
            self.assertTrue(0 <= lb.next().id <= 2)
            self.assertIsNone(lb.next_data_member())
    def test_random_lb_with_mixed_members(self):
        cluster = _MockClusterService(3, 3)
        lb = RandomLB()
        lb.init(cluster)

        for _ in range(20):
            self.assertTrue(0 <= lb.next().id < 6)
            self.assertTrue(0 <= lb.next_data_member().id < 3)
 def test_random_lb_with_data_members(self):
     cluster = _MockClusterService(3, 0)
     lb = RandomLB()
     lb.init(cluster)
     self.assertTrue(lb.can_get_next_data_member())
     for _ in range(10):
         self.assertTrue(0 <= lb.next().id <= 2)
         self.assertTrue(0 <= lb.next_data_member().id <= 2)
 def test_random_lb_with_members(self):
     cluster = _MockClusterService([0, 1, 2])
     lb = RandomLB()
     lb.init(cluster)
     for _ in range(10):
         self.assertTrue(0 <= lb.next() <= 2)
 def test_random_lb_with_no_members(self):
     cluster = _MockClusterService([])
     lb = RandomLB()
     lb.init(cluster)
     self.assertIsNone(lb.next())