Skip to content

Commit

Permalink
Fix unreliable actor test. (ray-project#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertnishihara authored and pcmoritz committed Feb 18, 2017
1 parent 67c591c commit abd9987
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/actor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,21 @@ def get_location(self):

# Create a bunch of actors.
num_actors = 30
actors = [Actor1() for _ in range(num_actors)]
num_attempts = 20
minimum_count = 5

# Make sure that actors are spread between the local schedulers.
locations = ray.get([actor.get_location() for actor in actors])
names = set(locations)
self.assertEqual(len(names), num_local_schedulers)
self.assertTrue(all([locations.count(name) > 5 for name in names]))
attempts = 0
while attempts < num_attempts:
actors = [Actor1() for _ in range(num_actors)]
locations = ray.get([actor.get_location() for actor in actors])
names = set(locations)
counts = [locations.count(name) for name in names]
print("Counts are {}.".format(counts))
if len(names) == num_local_schedulers and all([count >= minimum_count for count in counts]):
break
attempts += 1
self.assertLess(attempts, num_attempts)

# Make sure we can get the results of a bunch of tasks.
results = []
Expand Down

0 comments on commit abd9987

Please sign in to comment.