Fix test assignment for repeated tests

If a test with higher prio comes in, the worker might never swap off their current test
This commit is contained in:
andrew committed 2023-09-28 17:47:50 -04:00
1 parent 8e0aa6a26b
commit f35961e054
1 file changed
+3 -2
+3 -2
View File
@@ -94,9 +94,10 @@ def select_workload(machine):
total_throughput = sum([x.throughput for x in tests])
fair_ratio = total_threads / total_throughput
# Repeat the same test if the distribution is still fair
# Repeat the same test if the distribution is fair, and has the previous test
if min(ratios) / fair_ratio > 0.75:
return Test.objects.get(id=machine.workload)
if (test := Test.objects.get(id=machine.workload)) in tests:
return test
# Fallback to simply doing the least attention given test
return tests[random.choice(lowest_indices)]