Wipe snapshot repos after and before tests
On windows tests sometimes fail since files can not be deleted due to existing repos still holding on to the files. The test framework is picky about that since it could be a bug and fails the test if a temp file can not be deleted.
This commit is contained in:
parent
7d9154b8b5
commit
a305fb08d6
|
@ -26,6 +26,7 @@ import org.elasticsearch.repositories.RepositoriesService;
|
|||
import org.elasticsearch.repositories.RepositoryMissingException;
|
||||
import org.elasticsearch.snapshots.mockstore.MockRepository;
|
||||
import org.elasticsearch.test.ElasticsearchIntegrationTest;
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -37,6 +38,18 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
*/
|
||||
@Ignore
|
||||
public abstract class AbstractSnapshotTests extends ElasticsearchIntegrationTest {
|
||||
|
||||
|
||||
@After
|
||||
public final void wipeAfter() {
|
||||
wipeRepositories();
|
||||
}
|
||||
|
||||
@After
|
||||
public final void wipeBefore() {
|
||||
wipeRepositories();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes repositories, supports wildcard notation.
|
||||
*/
|
||||
|
|
|
@ -49,8 +49,6 @@ public class DedicatedClusterSnapshotRestoreTests extends AbstractSnapshotTests
|
|||
logger.info("--> start node");
|
||||
cluster().startNode(settingsBuilder().put("gateway.type", "local"));
|
||||
Client client = cluster().client();
|
||||
wipeIndices();
|
||||
wipeRepositories();
|
||||
|
||||
// Add dummy persistent setting
|
||||
logger.info("--> set test persistent setting");
|
||||
|
@ -88,8 +86,6 @@ public class DedicatedClusterSnapshotRestoreTests extends AbstractSnapshotTests
|
|||
nodes.add(cluster().startNode());
|
||||
nodes.add(cluster().startNode());
|
||||
Client client = cluster().client();
|
||||
wipeIndices();
|
||||
wipeRepositories();
|
||||
|
||||
assertAcked(prepareCreate("test-idx", 2, settingsBuilder().put("number_of_shards", 2).put("number_of_replicas", 0).put(MockDirectoryHelper.RANDOM_NO_DELETE_OPEN_FILE, false)));
|
||||
ensureGreen();
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.cluster.metadata.RepositoriesMetaData;
|
|||
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.repositories.RepositoryException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -40,11 +39,6 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
*/
|
||||
public class RepositoriesTests extends AbstractSnapshotTests {
|
||||
|
||||
@Before
|
||||
public final void beforeSnapshots() {
|
||||
wipeRepositories();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepositoryCreation() throws Exception {
|
||||
Client client = client();
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.carrotsearch.randomizedtesting.LifecycleScope;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import org.elasticsearch.ExceptionsHelper;
|
||||
import org.elasticsearch.action.ListenableActionFuture;
|
||||
import org.elasticsearch.action.admin.cluster.repositories.delete.DeleteRepositoryResponse;
|
||||
import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryResponse;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
|
||||
|
@ -41,7 +40,6 @@ import org.elasticsearch.indices.InvalidIndexNameException;
|
|||
import org.elasticsearch.snapshots.mockstore.MockRepositoryModule;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.elasticsearch.test.store.MockDirectoryHelper;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -53,10 +51,6 @@ import static org.hamcrest.Matchers.*;
|
|||
*/
|
||||
public class SharedClusterSnapshotRestoreTests extends AbstractSnapshotTests {
|
||||
|
||||
@Before
|
||||
public final void beforeSnapshots() {
|
||||
wipeRepositories();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings getSettings() {
|
||||
|
|
|
@ -164,7 +164,7 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
|||
}
|
||||
|
||||
@After
|
||||
public void after() throws IOException {
|
||||
public final void after() throws IOException {
|
||||
try {
|
||||
logger.info("[{}#{}]: cleaning up after test", getTestClass().getSimpleName(), getTestName());
|
||||
Scope currentClusterScope = getCurrentClusterScope();
|
||||
|
|
Loading…
Reference in New Issue