mirror of
https://github.com/vale981/ray
synced 2025-03-06 10:31:39 -05:00
Fix unreliable actor test. (#295)
This commit is contained in:
parent
67c591c33b
commit
abd9987e3b
1 changed files with 13 additions and 5 deletions
|
@ -454,13 +454,21 @@ class ActorsOnMultipleNodes(unittest.TestCase):
|
|||
|
||||
# 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.
|
||||
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)
|
||||
self.assertEqual(len(names), num_local_schedulers)
|
||||
self.assertTrue(all([locations.count(name) > 5 for name in names]))
|
||||
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 = []
|
||||
|
|
Loading…
Add table
Reference in a new issue