Skip to content

Commit 04308b5

Browse files
authored
Fix tests for new markAsLocallyAborted method (#75021)
Two test fixes following on from #74115 Fixes #75004 Fixes #75012
1 parent 60c2838 commit 04308b5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

server/src/internalClusterTest/java/org/elasticsearch/persistent/PersistentTasksExecutorIT.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package org.elasticsearch.persistent;
1010

11-
import org.apache.lucene.util.LuceneTestCase;
1211
import org.elasticsearch.ResourceAlreadyExistsException;
1312
import org.elasticsearch.ResourceNotFoundException;
1413
import org.elasticsearch.action.support.PlainActionFuture;
@@ -34,6 +33,7 @@
3433
import java.util.Objects;
3534

3635
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFutureThrows;
36+
import static org.hamcrest.Matchers.either;
3737
import static org.hamcrest.Matchers.empty;
3838
import static org.hamcrest.Matchers.equalTo;
3939
import static org.hamcrest.Matchers.hasSize;
@@ -42,7 +42,6 @@
4242
import static org.hamcrest.Matchers.nullValue;
4343
import static org.hamcrest.core.Is.is;
4444

45-
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/75012")
4645
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, minNumDataNodes = 2)
4746
public class PersistentTasksExecutorIT extends ESIntegTestCase {
4847

@@ -363,7 +362,13 @@ public void testAbortLocally() throws Exception {
363362
// Verify that the task is STILL in internal cluster state, unassigned, with a reason indicating local abort
364363
PersistentTask<?> task = assertClusterStateHasTask(taskId);
365364
assertThat(task.getAssignment().getExecutorNode(), nullValue());
366-
assertThat(task.getAssignment().getExplanation(), equalTo("Simulating local abort"));
365+
// Although the assignment explanation is initially set to "Simulating local abort", because
366+
// of the way we prevent reassignment to the same node in this test it may quickly change to
367+
// "non cluster state condition prevents assignment" - either proves the unassignment worked
368+
assertThat(task.getAssignment().getExplanation(),
369+
either(equalTo("Simulating local abort"))
370+
.or(equalTo("non cluster state condition prevents assignment"))
371+
);
367372
});
368373

369374
// Allow it to be reassigned again

server/src/test/java/org/elasticsearch/persistent/PersistentTasksNodeServiceTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ public boolean isLocalAbortSupported() {
318318
assertThat(taskManager.getTasks().values(), empty());
319319
}
320320

321-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/75004")
322321
public void testTaskLocalAbort() {
323322
AtomicReference<String> capturedTaskId = new AtomicReference<>();
324323
AtomicReference<ActionListener<PersistentTask<?>>> capturedListener = new AtomicReference<>();
@@ -407,7 +406,10 @@ public boolean isLocalAbortSupported() {
407406
equalTo("attempt to fail task [test] with id [" + persistentId + "] which has been locally aborted"));
408407
break;
409408
case 2:
410-
runningTask.markAsLocallyAborted("second local abort");
409+
IllegalStateException e2 = expectThrows(IllegalStateException.class,
410+
() -> runningTask.markAsLocallyAborted("second local abort"));
411+
assertThat(e2.getMessage(),
412+
equalTo("attempt to locally abort task [test] with id [" + persistentId + "] which has already been locally aborted"));
411413
break;
412414
}
413415

0 commit comments

Comments
 (0)