Clean up after test failure
If the test fails we properly clean up. Also add a toString implementation so we get useful results on failure.
This commit is contained in:
parent
2ebc5c342b
commit
c8931768ba
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
package org.elasticsearch.action.support.replication;
|
package org.elasticsearch.action.support.replication;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -89,6 +90,11 @@ public class ReplicationTask extends Task {
|
||||||
out.writeString(phase);
|
out.writeString(phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return Strings.toString(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Implements equals and hashcode for testing
|
// Implements equals and hashcode for testing
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
|
|
|
@ -338,6 +338,8 @@ public class TasksIT extends ESIntegTestCase {
|
||||||
*/
|
*/
|
||||||
ReentrantLock taskFinishLock = new ReentrantLock();
|
ReentrantLock taskFinishLock = new ReentrantLock();
|
||||||
taskFinishLock.lock();
|
taskFinishLock.lock();
|
||||||
|
ListenableActionFuture<?> indexFuture = null;
|
||||||
|
try {
|
||||||
CountDownLatch taskRegistered = new CountDownLatch(1);
|
CountDownLatch taskRegistered = new CountDownLatch(1);
|
||||||
for (TransportService transportService : internalCluster().getInstances(TransportService.class)) {
|
for (TransportService transportService : internalCluster().getInstances(TransportService.class)) {
|
||||||
((MockTaskManager) transportService.getTaskManager()).addListener(new MockTaskManagerListener() {
|
((MockTaskManager) transportService.getTaskManager()).addListener(new MockTaskManagerListener() {
|
||||||
|
@ -363,7 +365,7 @@ public class TasksIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ListenableActionFuture<?> indexFuture = client().prepareIndex("test", "test").setSource("test", "test").execute();
|
indexFuture = client().prepareIndex("test", "test").setSource("test", "test").execute();
|
||||||
taskRegistered.await(10, TimeUnit.SECONDS); // waiting for at least one task to be registered
|
taskRegistered.await(10, TimeUnit.SECONDS); // waiting for at least one task to be registered
|
||||||
|
|
||||||
ListTasksResponse listResponse = client().admin().cluster().prepareListTasks().setActions("indices:data/write/index*")
|
ListTasksResponse listResponse = client().admin().cluster().prepareListTasks().setActions("indices:data/write/index*")
|
||||||
|
@ -384,10 +386,13 @@ public class TasksIT extends ESIntegTestCase {
|
||||||
assertEquals(task.isCancellable(), fetchedWithGet.isCancellable());
|
assertEquals(task.isCancellable(), fetchedWithGet.isCancellable());
|
||||||
assertEquals(task.getParentTaskId(), fetchedWithGet.getParentTaskId());
|
assertEquals(task.getParentTaskId(), fetchedWithGet.getParentTaskId());
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
taskFinishLock.unlock();
|
taskFinishLock.unlock();
|
||||||
|
if (indexFuture != null) {
|
||||||
indexFuture.get();
|
indexFuture.get();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testTasksCancellation() throws Exception {
|
public void testTasksCancellation() throws Exception {
|
||||||
// Start blocking test task
|
// Start blocking test task
|
||||||
|
|
Loading…
Reference in New Issue