Skip to content

Commit

Permalink
resolve flakiness
Browse files Browse the repository at this point in the history
Signed-off-by: Kiran Prakash <[email protected]>
  • Loading branch information
kiranprakash154 committed Jul 15, 2024
1 parent 2a9adf1 commit 4c649b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class DefaultTaskCancellationTests extends OpenSearchTestCase {

private class TestTaskCancellationImpl extends DefaultTaskCancellation {
private static class TestTaskCancellationImpl extends DefaultTaskCancellation {

public TestTaskCancellationImpl(
TaskSelectionStrategy taskSelectionStrategy,
Expand Down Expand Up @@ -75,8 +75,8 @@ public void testGetCancellableTasksFrom_returnsTasksWhenBreachingThreshold() {

List<TaskCancellation> cancellableTasksFrom = taskCancellation.getCancellableTasksFrom(sandbox1);
assertEquals(2, cancellableTasksFrom.size());
assertEquals(4321, cancellableTasksFrom.get(0).getTask().getId());
assertEquals(1234, cancellableTasksFrom.get(1).getTask().getId());
assertEquals(1234, cancellableTasksFrom.get(0).getTask().getId());
assertEquals(4321, cancellableTasksFrom.get(1).getTask().getId());
}

public void testGetCancellableTasksFrom_returnsNoTasksWhenBreachingThreshold() {
Expand Down Expand Up @@ -115,8 +115,8 @@ public void testCancelTasks_cancelsGivenTasks() {

List<TaskCancellation> cancellableTasksFrom = taskCancellation.getAllCancellableTasks();
assertEquals(2, cancellableTasksFrom.size());
assertEquals(4321, cancellableTasksFrom.get(0).getTask().getId());
assertEquals(1234, cancellableTasksFrom.get(1).getTask().getId());
assertEquals(1234, cancellableTasksFrom.get(0).getTask().getId());
assertEquals(4321, cancellableTasksFrom.get(1).getTask().getId());

taskCancellation.cancelTasks();
assertTrue(cancellableTasksFrom.get(0).getTask().isCancelled());
Expand Down Expand Up @@ -153,8 +153,8 @@ public void testGetAllCancellableTasks_ReturnsTasksWhenBreachingThresholds() {

List<TaskCancellation> allCancellableTasks = taskCancellation.getAllCancellableTasks();
assertEquals(2, allCancellableTasks.size());
assertEquals(4321, allCancellableTasks.get(0).getTask().getId());
assertEquals(1234, allCancellableTasks.get(1).getTask().getId());
assertEquals(1234, allCancellableTasks.get(0).getTask().getId());
assertEquals(4321, allCancellableTasks.get(1).getTask().getId());
}

public void testGetCancellableTasksFrom_returnsTasksEvenWhenSandboxIdNotFound() {
Expand All @@ -174,7 +174,7 @@ public void testGetCancellableTasksFrom_returnsTasksEvenWhenSandboxIdNotFound()

List<TaskCancellation> cancellableTasksFrom = taskCancellation.getCancellableTasksFrom(sandbox1);
assertEquals(2, cancellableTasksFrom.size());
assertEquals(4321, cancellableTasksFrom.get(0).getTask().getId());
assertEquals(1234, cancellableTasksFrom.get(1).getTask().getId());
assertEquals(1234, cancellableTasksFrom.get(0).getTask().getId());
assertEquals(4321, cancellableTasksFrom.get(1).getTask().getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public void testSortingCondition() {
List<Task> tasks = Arrays.asList(task1, task3, task2);
tasks.sort(new ShortestRunningTaskFirstStrategy().sortingCondition());

assertEquals(Arrays.asList(task1, task2, task3), tasks);
assertEquals(Arrays.asList(task3, task2, task1), tasks);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TaskSelectionStrategyTests extends OpenSearchTestCase {
public static class TestTaskSelectionStrategy extends AbstractTaskSelectionStrategy {
@Override
public Comparator<Task> sortingCondition() {
return Comparator.comparingLong(Task::getStartTime).reversed();
return Comparator.comparingLong(Task::getId);
}
}

Expand Down

0 comments on commit 4c649b7

Please sign in to comment.