YARN-8605. TestDominantResourceFairnessPolicy.testModWhileSorting is flaky. (Wilfred Spiegelenburg via Haibo Chen)
This commit is contained in:
parent
9fea5c9ee7
commit
8aa93a575e
@ -24,7 +24,6 @@ import static org.mockito.Mockito.mock;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -458,33 +457,20 @@ public class TestDominantResourceFairnessPolicy {
|
|||||||
}
|
}
|
||||||
Comparator DRFComparator = createComparator(100000, 50000);
|
Comparator DRFComparator = createComparator(100000, 50000);
|
||||||
|
|
||||||
// To simulate unallocated resource changes
|
/*
|
||||||
Thread modThread = modificationThread(schedulableList);
|
* The old sort should fail, but timing it makes testing to flaky.
|
||||||
modThread.start();
|
* TimSort which is used does not handle the concurrent modification of
|
||||||
|
* objects it is sorting. This is the test that should fail:
|
||||||
|
* modThread.start();
|
||||||
|
* try {
|
||||||
|
* Collections.sort(schedulableList, DRFComparator);
|
||||||
|
* } catch (IllegalArgumentException iae) {
|
||||||
|
* // failed sort
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
|
||||||
// This should fail: make sure that we do test correctly
|
|
||||||
// TimSort which is used does not handle the concurrent modification of
|
|
||||||
// objects it is sorting.
|
|
||||||
try {
|
|
||||||
Collections.sort(schedulableList, DRFComparator);
|
|
||||||
fail("Sorting should have failed and did not");
|
|
||||||
} catch (IllegalArgumentException iae) {
|
|
||||||
assertEquals(iae.getMessage(), "Comparison method violates its general contract!");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
modThread.join();
|
|
||||||
} catch (InterruptedException ie) {
|
|
||||||
fail("ModThread join failed: " + ie.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean up and try again using TreeSet which should work
|
|
||||||
schedulableList.clear();
|
|
||||||
for (int i=0; i<10000; i++) {
|
|
||||||
schedulableList.add(
|
|
||||||
(FakeSchedulable)createSchedulable((i%10)*100, (i%3)*2));
|
|
||||||
}
|
|
||||||
TreeSet<Schedulable> sortedSchedulable = new TreeSet<>(DRFComparator);
|
TreeSet<Schedulable> sortedSchedulable = new TreeSet<>(DRFComparator);
|
||||||
modThread = modificationThread(schedulableList);
|
Thread modThread = modificationThread(schedulableList);
|
||||||
modThread.start();
|
modThread.start();
|
||||||
sortedSchedulable.addAll(schedulableList);
|
sortedSchedulable.addAll(schedulableList);
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user