Just a few spots where we can dry up these tests using the snapshot test infrastructure in core that I found while studying the existing searchable snapshot tests.
This commit is contained in:
parent
82096d3971
commit
2aa80f9ee3
|
@ -1196,8 +1196,7 @@ public class ConcurrentSnapshotsIT extends AbstractSnapshotIntegTestCase {
|
||||||
final String indexFast = "index-fast";
|
final String indexFast = "index-fast";
|
||||||
createIndexWithContent(indexFast, dataNode2, dataNode);
|
createIndexWithContent(indexFast, dataNode2, dataNode);
|
||||||
|
|
||||||
final ActionFuture<CreateSnapshotResponse> createFastSnapshot =
|
final ActionFuture<CreateSnapshotResponse> createFastSnapshot = startFullSnapshot(repoName, "fast-snapshot");
|
||||||
client().admin().cluster().prepareCreateSnapshot(repoName, "fast-snapshot").setWaitForCompletion(true).execute();
|
|
||||||
|
|
||||||
assertThat(createSlowFuture.isDone(), is(false));
|
assertThat(createSlowFuture.isDone(), is(false));
|
||||||
unblockNode(repoName, dataNode);
|
unblockNode(repoName, dataNode);
|
||||||
|
|
|
@ -580,10 +580,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
|
||||||
|
|
||||||
indexRandomDocs("test-idx", 100);
|
indexRandomDocs("test-idx", 100);
|
||||||
|
|
||||||
logger.info("--> start snapshot");
|
createSnapshot("test-repo", "test-snap-1", Collections.singletonList("test-idx"));
|
||||||
assertThat(clusterAdmin().prepareCreateSnapshot("test-repo", "test-snap-1").setIndices("test-idx")
|
|
||||||
.setWaitForCompletion(true).get().getSnapshotInfo().state(),
|
|
||||||
equalTo(SnapshotState.SUCCESS));
|
|
||||||
|
|
||||||
logger.info("--> close the index");
|
logger.info("--> close the index");
|
||||||
assertAcked(client().admin().indices().prepareClose("test-idx"));
|
assertAcked(client().admin().indices().prepareClose("test-idx"));
|
||||||
|
@ -796,9 +793,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
|
||||||
assertAcked(client().admin().indices().prepareResizeIndex(sourceIdx, shrunkIdx).get());
|
assertAcked(client().admin().indices().prepareResizeIndex(sourceIdx, shrunkIdx).get());
|
||||||
|
|
||||||
logger.info("--> snapshot the shrunk index");
|
logger.info("--> snapshot the shrunk index");
|
||||||
assertSuccessful(clusterAdmin()
|
createSnapshot(repo, snapshot, Collections.singletonList(shrunkIdx));
|
||||||
.prepareCreateSnapshot(repo, snapshot)
|
|
||||||
.setWaitForCompletion(true).setIndices(shrunkIdx).execute());
|
|
||||||
|
|
||||||
logger.info("--> delete index and stop the data node");
|
logger.info("--> delete index and stop the data node");
|
||||||
assertAcked(client().admin().indices().prepareDelete(sourceIdx).get());
|
assertAcked(client().admin().indices().prepareDelete(sourceIdx).get());
|
||||||
|
@ -1095,11 +1090,7 @@ public class DedicatedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTest
|
||||||
assertTrue(shardStats + ": " + retentionLeases, retentionLeases.contains(leaseId));
|
assertTrue(shardStats + ": " + retentionLeases, retentionLeases.contains(leaseId));
|
||||||
|
|
||||||
final String snapshotName = "snapshot-retention-leases";
|
final String snapshotName = "snapshot-retention-leases";
|
||||||
logger.debug("--> create snapshot {}:{}", repoName, snapshotName);
|
createSnapshot(repoName, snapshotName, Collections.singletonList(indexName));
|
||||||
CreateSnapshotResponse createResponse = clusterAdmin().prepareCreateSnapshot(repoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true).setIndices(indexName).get();
|
|
||||||
assertThat(createResponse.getSnapshotInfo().successfulShards(), equalTo(shardCount));
|
|
||||||
assertThat(createResponse.getSnapshotInfo().failedShards(), equalTo(0));
|
|
||||||
|
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
final int extraDocCount = iterations(10, 1000);
|
final int extraDocCount = iterations(10, 1000);
|
||||||
|
|
|
@ -76,6 +76,7 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -259,16 +260,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
index(indexName, typeName, docId, "value", expectedValue);
|
index(indexName, typeName, docId, "value", expectedValue);
|
||||||
|
|
||||||
createRepository(repoName, "fs", absolutePath);
|
createRepository(repoName, "fs", absolutePath);
|
||||||
|
createSnapshot(repoName, snapshotName, Collections.singletonList(indexName));
|
||||||
logger.info("--> snapshot");
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot(repoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.setIndices(indexName)
|
|
||||||
.get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
||||||
|
|
||||||
RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName)
|
RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName)
|
||||||
.setWaitForCompletion(true)
|
.setWaitForCompletion(true)
|
||||||
|
@ -289,11 +281,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
assertTrue(originalIndexUUID, originalIndexUUID != null);
|
assertTrue(originalIndexUUID, originalIndexUUID != null);
|
||||||
assertFalse(originalIndexUUID, originalIndexUUID.equals(IndexMetadata.INDEX_UUID_NA_VALUE));
|
assertFalse(originalIndexUUID, originalIndexUUID.equals(IndexMetadata.INDEX_UUID_NA_VALUE));
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot("test-repo", "test-snap")
|
createSnapshot("test-repo", "test-snap", Collections.singletonList("test"));
|
||||||
.setWaitForCompletion(true).setIndices("test").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
||||||
NumShards numShards = getNumShards("test");
|
NumShards numShards = getNumShards("test");
|
||||||
|
|
||||||
cluster().wipeIndices("test");
|
cluster().wipeIndices("test");
|
||||||
|
@ -456,12 +444,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
|
|
||||||
indexRandomDocs("test-idx", 100);
|
indexRandomDocs("test-idx", 100);
|
||||||
|
|
||||||
logger.info("--> snapshot");
|
createSnapshot("test-repo", "test-snap", Collections.singletonList("test-idx"));
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
||||||
.setWaitForCompletion(true).setIndices("test-idx").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
||||||
|
|
||||||
createRepository("test-repo", "mock",
|
createRepository("test-repo", "mock",
|
||||||
Settings.builder().put("location", repositoryLocation).put("random", randomAlphaOfLength(10))
|
Settings.builder().put("location", repositoryLocation).put("random", randomAlphaOfLength(10))
|
||||||
|
@ -505,12 +488,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
createRepository("test-repo", "fs", repositoryLocation);
|
createRepository("test-repo", "fs", repositoryLocation);
|
||||||
createIndexWithRandomDocs("test-idx", 100);
|
createIndexWithRandomDocs("test-idx", 100);
|
||||||
|
|
||||||
logger.info("--> snapshot");
|
createSnapshot("test-repo", "test-snap", Collections.singletonList("test-idx"));
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster()
|
|
||||||
.prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
||||||
|
|
||||||
createRepository("test-repo", "mock",
|
createRepository("test-repo", "mock",
|
||||||
Settings.builder().put("location", repositoryLocation).put("random", randomAlphaOfLength(10))
|
Settings.builder().put("location", repositoryLocation).put("random", randomAlphaOfLength(10))
|
||||||
|
@ -602,14 +580,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
|
|
||||||
// create a snapshot
|
// create a snapshot
|
||||||
final NumShards numShards = getNumShards(indexName);
|
final NumShards numShards = getNumShards(indexName);
|
||||||
CreateSnapshotResponse snapshotResponse = clusterAdmin().prepareCreateSnapshot("test-repo", "test-snap")
|
final SnapshotInfo snapshotInfo = createSnapshot("test-repo", "test-snap", Collections.singletonList(indexName));
|
||||||
.setWaitForCompletion(true)
|
assertThat(snapshotInfo.successfulShards(), equalTo(numShards.numPrimaries));
|
||||||
.setIndices(indexName)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
assertThat(snapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
||||||
assertThat(snapshotResponse.getSnapshotInfo().successfulShards(), equalTo(numShards.numPrimaries));
|
|
||||||
assertThat(snapshotResponse.getSnapshotInfo().failedShards(), equalTo(0));
|
|
||||||
|
|
||||||
// delete the test index
|
// delete the test index
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
@ -681,12 +653,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
|
|
||||||
createIndexWithRandomDocs("test-idx", 100);
|
createIndexWithRandomDocs("test-idx", 100);
|
||||||
|
|
||||||
logger.info("--> snapshot");
|
createSnapshot("test-repo", "test-snap", Collections.singletonList("test-idx"));
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
||||||
.setWaitForCompletion(true).setIndices("test-idx").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
||||||
|
|
||||||
logger.info("--> update repository with mock version");
|
logger.info("--> update repository with mock version");
|
||||||
createRepository("test-repo", "mock", Settings.builder()
|
createRepository("test-repo", "mock", Settings.builder()
|
||||||
|
@ -760,12 +727,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
index("test-idx", "_doc", Integer.toString(i * 10 + j), "foo", "bar" + i * 10 + j);
|
index("test-idx", "_doc", Integer.toString(i * 10 + j), "foo", "bar" + i * 10 + j);
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
logger.info("--> snapshot {}", i);
|
createSnapshot("test-repo", "test-snap-" + i, Collections.singletonList("test-idx"));
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-" + i)
|
|
||||||
.setWaitForCompletion(true).setIndices("test-idx").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
||||||
// Store number of files after each snapshot
|
// Store number of files after each snapshot
|
||||||
numberOfFiles[i] = numberOfFiles(repo);
|
numberOfFiles[i] = numberOfFiles(repo);
|
||||||
}
|
}
|
||||||
|
@ -948,12 +910,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
|
|
||||||
createIndexWithRandomDocs("test-idx", 100);
|
createIndexWithRandomDocs("test-idx", 100);
|
||||||
|
|
||||||
logger.info("--> snapshot");
|
createSnapshot("test-repo", "test-snap", Collections.singletonList("test-idx"));
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
||||||
.setWaitForCompletion(true).setIndices("test-idx").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
||||||
|
|
||||||
assertThat(getSnapshot("test-repo", "test-snap").state(), equalTo(SnapshotState.SUCCESS));
|
assertThat(getSnapshot("test-repo", "test-snap").state(), equalTo(SnapshotState.SUCCESS));
|
||||||
|
|
||||||
|
@ -1002,13 +959,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
.put("max_snapshot_bytes_per_sec", throttleSnapshot ? "10k" : "0"));
|
.put("max_snapshot_bytes_per_sec", throttleSnapshot ? "10k" : "0"));
|
||||||
|
|
||||||
createIndexWithRandomDocs("test-idx", 100);
|
createIndexWithRandomDocs("test-idx", 100);
|
||||||
|
createSnapshot("test-repo", "test-snap", Collections.singletonList("test-idx"));
|
||||||
logger.info("--> snapshot");
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
||||||
.setWaitForCompletion(true).setIndices("test-idx").get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
||||||
|
|
||||||
logger.info("--> delete index");
|
logger.info("--> delete index");
|
||||||
cluster().wipeIndices("test-idx");
|
cluster().wipeIndices("test-idx");
|
||||||
|
@ -1195,11 +1146,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
indexRandomDocs("test", randomIntBetween(10, 100));
|
indexRandomDocs("test", randomIntBetween(10, 100));
|
||||||
assertNoFailures(client().admin().indices().prepareForceMerge("test").setFlush(true).setMaxNumSegments(1).get());
|
assertNoFailures(client().admin().indices().prepareForceMerge("test").setFlush(true).setMaxNumSegments(1).get());
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponseFirst = client.admin().cluster().prepareCreateSnapshot("test-repo", "test")
|
createSnapshot("test-repo", "test", Collections.singletonList("test"));
|
||||||
.setWaitForCompletion(true).setIndices("test").get();
|
|
||||||
assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponseFirst.getSnapshotInfo().totalShards()));
|
|
||||||
assertThat(getSnapshot("test-repo", "test").state(), equalTo(SnapshotState.SUCCESS));
|
assertThat(getSnapshot("test-repo", "test").state(), equalTo(SnapshotState.SUCCESS));
|
||||||
{
|
{
|
||||||
SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
||||||
|
@ -1210,11 +1157,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponseSecond = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-1")
|
createSnapshot("test-repo", "test-1", Collections.singletonList("test"));
|
||||||
.setWaitForCompletion(true).setIndices("test").get();
|
|
||||||
assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponseSecond.getSnapshotInfo().totalShards()));
|
|
||||||
assertThat(getSnapshot("test-repo", "test-1").state(), equalTo(SnapshotState.SUCCESS));
|
assertThat(getSnapshot("test-repo", "test-1").state(), equalTo(SnapshotState.SUCCESS));
|
||||||
{
|
{
|
||||||
SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
||||||
|
@ -1226,11 +1169,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
}
|
}
|
||||||
|
|
||||||
client().prepareDelete("test", "_doc", "1").get();
|
client().prepareDelete("test", "_doc", "1").get();
|
||||||
CreateSnapshotResponse createSnapshotResponseThird = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-2")
|
createSnapshot("test-repo", "test-2", Collections.singletonList("test"));
|
||||||
.setWaitForCompletion(true).setIndices("test").get();
|
|
||||||
assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponseThird.getSnapshotInfo().totalShards()));
|
|
||||||
assertThat(getSnapshot("test-repo", "test-2").state(), equalTo(SnapshotState.SUCCESS));
|
assertThat(getSnapshot("test-repo", "test-2").state(), equalTo(SnapshotState.SUCCESS));
|
||||||
{
|
{
|
||||||
SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
||||||
|
@ -1791,11 +1730,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
}
|
}
|
||||||
final String snapshotName = "test-snap-" + i;
|
final String snapshotName = "test-snap-" + i;
|
||||||
indicesPerSnapshot.put(snapshotName, indices);
|
indicesPerSnapshot.put(snapshotName, indices);
|
||||||
client.admin().cluster()
|
createSnapshot("test-repo", snapshotName, indices);
|
||||||
.prepareCreateSnapshot("test-repo", snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.setIndices(indices.toArray(new String[indices.size()]))
|
|
||||||
.get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> verify _all returns snapshot info");
|
logger.info("--> verify _all returns snapshot info");
|
||||||
|
@ -1855,12 +1790,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
logger.info("--> snapshot");
|
createSnapshot(repositoryName, snapshotName, Collections.singletonList(indexName));
|
||||||
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repositoryName, snapshotName)
|
|
||||||
.setWaitForCompletion(true).setIndices(indexName).get();
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
||||||
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
||||||
equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
||||||
|
|
||||||
logger.info("--> delete indices");
|
logger.info("--> delete indices");
|
||||||
assertAcked(client.admin().indices().prepareDelete(indexName));
|
assertAcked(client.admin().indices().prepareDelete(indexName));
|
||||||
|
|
|
@ -83,6 +83,8 @@ import java.util.function.Predicate;
|
||||||
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.hamcrest.Matchers.empty;
|
import static org.hamcrest.Matchers.empty;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.greaterThan;
|
||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
|
@ -386,6 +388,22 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase {
|
||||||
return snapshotInfo;
|
return snapshotInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SnapshotInfo createSnapshot(String repositoryName, String snapshot, List<String> indices) {
|
||||||
|
logger.info("--> creating snapshot [{}] of {} in [{}]", snapshot, indices, repositoryName);
|
||||||
|
final CreateSnapshotResponse response = client().admin()
|
||||||
|
.cluster()
|
||||||
|
.prepareCreateSnapshot(repositoryName, snapshot)
|
||||||
|
.setIndices(indices.toArray(Strings.EMPTY_ARRAY))
|
||||||
|
.setWaitForCompletion(true)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
final SnapshotInfo snapshotInfo = response.getSnapshotInfo();
|
||||||
|
assertThat(snapshotInfo.state(), is(SnapshotState.SUCCESS));
|
||||||
|
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
||||||
|
assertThat(snapshotInfo.failedShards(), equalTo(0));
|
||||||
|
return snapshotInfo;
|
||||||
|
}
|
||||||
|
|
||||||
protected void createIndexWithRandomDocs(String indexName, int docCount) throws InterruptedException {
|
protected void createIndexWithRandomDocs(String indexName, int docCount) throws InterruptedException {
|
||||||
createIndex(indexName);
|
createIndex(indexName);
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
|
@ -50,6 +50,7 @@ import java.nio.file.SimpleFileVisitor;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -118,9 +119,9 @@ public class SearchableSnapshotsBlobStoreCacheIntegTests extends BaseSearchableS
|
||||||
|
|
||||||
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final Path repositoryLocation = randomRepoPath();
|
final Path repositoryLocation = randomRepoPath();
|
||||||
createFsRepository(repositoryName, repositoryLocation);
|
createRepository(repositoryName, "fs", repositoryLocation);
|
||||||
|
|
||||||
final SnapshotId snapshot = createSnapshot(repositoryName, org.elasticsearch.common.collect.List.of(indexName));
|
final SnapshotId snapshot = createSnapshot(repositoryName, "test-snapshot", Collections.singletonList(indexName)).snapshotId();
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
|
||||||
// extract the list of blobs per shard from the snapshot directory on disk
|
// extract the list of blobs per shard from the snapshot directory on disk
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.searchablesnapshots;
|
package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
@ -33,28 +32,22 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.repositories.fs.FsRepository;
|
|
||||||
import org.elasticsearch.snapshots.SnapshotId;
|
|
||||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
|
||||||
import org.elasticsearch.xpack.core.XPackSettings;
|
import org.elasticsearch.xpack.core.XPackSettings;
|
||||||
|
import org.elasticsearch.snapshots.AbstractSnapshotIntegTestCase;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
||||||
import org.elasticsearch.xpack.searchablesnapshots.cache.CacheService;
|
import org.elasticsearch.xpack.searchablesnapshots.cache.CacheService;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING;
|
|
||||||
import static org.elasticsearch.license.LicenseService.SELF_GENERATED_LICENSE_TYPE;
|
import static org.elasticsearch.license.LicenseService.SELF_GENERATED_LICENSE_TYPE;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
|
||||||
|
|
||||||
public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCase {
|
public abstract class BaseSearchableSnapshotsIntegTestCase extends AbstractSnapshotIntegTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected boolean addMockInternalEngine() {
|
protected boolean addMockInternalEngine() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,8 +67,7 @@ public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCa
|
||||||
protected Settings nodeSettings(int nodeOrdinal) {
|
protected Settings nodeSettings(int nodeOrdinal) {
|
||||||
final Settings.Builder builder = Settings.builder()
|
final Settings.Builder builder = Settings.builder()
|
||||||
.put(super.nodeSettings(nodeOrdinal))
|
.put(super.nodeSettings(nodeOrdinal))
|
||||||
.put(SELF_GENERATED_LICENSE_TYPE.getKey(), "trial")
|
.put(SELF_GENERATED_LICENSE_TYPE.getKey(), "trial");
|
||||||
.put(CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none");
|
|
||||||
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
|
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
builder.put(
|
builder.put(
|
||||||
|
@ -105,40 +97,6 @@ public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCa
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createFsRepository(String repositoryName, Path location) {
|
|
||||||
createRepository(
|
|
||||||
repositoryName,
|
|
||||||
FsRepository.TYPE,
|
|
||||||
Settings.builder().put(FsRepository.LOCATION_SETTING.getKey(), location).build(),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createRepository(String repositoryName, String repositoryType, Settings repositorySettings, boolean verify) {
|
|
||||||
assertAcked(
|
|
||||||
client().admin()
|
|
||||||
.cluster()
|
|
||||||
.preparePutRepository(repositoryName)
|
|
||||||
.setType(repositoryType)
|
|
||||||
.setSettings(repositorySettings)
|
|
||||||
.setVerify(verify)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected SnapshotId createSnapshot(String repositoryName, List<String> indices) {
|
|
||||||
final CreateSnapshotResponse response = client().admin()
|
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(repositoryName, randomAlphaOfLength(10).toLowerCase(Locale.ROOT))
|
|
||||||
.setIndices(indices.toArray(Strings.EMPTY_ARRAY))
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
final SnapshotInfo snapshotInfo = response.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.failedShards(), equalTo(0));
|
|
||||||
return snapshotInfo.snapshotId();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String mountSnapshot(String repositoryName, String snapshotName, String indexName, Settings restoredIndexSettings)
|
protected String mountSnapshot(String repositoryName, String snapshotName, String indexName, Settings restoredIndexSettings)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
@ -171,13 +129,6 @@ public abstract class BaseSearchableSnapshotsIntegTestCase extends ESIntegTestCa
|
||||||
assertThat(restoreResponse.getRestoreInfo().failedShards(), equalTo(0));
|
assertThat(restoreResponse.getRestoreInfo().failedShards(), equalTo(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createRepo(String fsRepoName) {
|
|
||||||
final Path repo = randomRepoPath();
|
|
||||||
assertAcked(
|
|
||||||
client().admin().cluster().preparePutRepository(fsRepoName).setType("fs").setSettings(Settings.builder().put("location", repo))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createAndPopulateIndex(String indexName, Settings.Builder settings) throws InterruptedException {
|
protected void createAndPopulateIndex(String indexName, Settings.Builder settings) throws InterruptedException {
|
||||||
assertAcked(prepareCreate(indexName, settings));
|
assertAcked(prepareCreate(indexName, settings));
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.xpack.searchablesnapshots;
|
package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||||
|
@ -44,7 +43,7 @@ public class ClusterStateApplierOrderingTests extends BaseSearchableSnapshotsInt
|
||||||
final String indexName = "test-index";
|
final String indexName = "test-index";
|
||||||
final String restoredIndexName = "restored-index";
|
final String restoredIndexName = "restored-index";
|
||||||
|
|
||||||
createRepo(fsRepoName);
|
createRepository(fsRepoName, "fs");
|
||||||
|
|
||||||
// Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but
|
// Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but
|
||||||
// we can bypass this by forcing soft deletes to be used. TODO this restriction can be lifted when #55142 is resolved.
|
// we can bypass this by forcing soft deletes to be used. TODO this restriction can be lifted when #55142 is resolved.
|
||||||
|
@ -57,12 +56,7 @@ public class ClusterStateApplierOrderingTests extends BaseSearchableSnapshotsInt
|
||||||
indexRandom(true, true, indexRequestBuilders);
|
indexRandom(true, true, indexRequestBuilders);
|
||||||
refresh(indexName);
|
refresh(indexName);
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
final SnapshotInfo snapshotInfo = createFullSnapshot(fsRepoName, "snapshot");
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, "snapshot")
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.elasticsearch.xpack.searchablesnapshots;
|
package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
|
|
||||||
import com.carrotsearch.hppc.ObjectContainer;
|
import com.carrotsearch.hppc.ObjectContainer;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
import org.elasticsearch.action.admin.indices.recovery.RecoveryResponse;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||||
|
@ -41,7 +40,6 @@ import java.util.stream.Stream;
|
||||||
import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_SETTING;
|
import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_SETTING;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
|
||||||
|
|
||||||
@ESIntegTestCase.ClusterScope(numDataNodes = 1)
|
@ESIntegTestCase.ClusterScope(numDataNodes = 1)
|
||||||
public class SearchableSnapshotRecoveryStateIntegrationTests extends BaseSearchableSnapshotsIntegTestCase {
|
public class SearchableSnapshotRecoveryStateIntegrationTests extends BaseSearchableSnapshotsIntegTestCase {
|
||||||
|
@ -60,7 +58,7 @@ public class SearchableSnapshotRecoveryStateIntegrationTests extends BaseSearcha
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
createRepo(fsRepoName);
|
createRepository(fsRepoName, "fs");
|
||||||
|
|
||||||
final Settings.Builder originalIndexSettings = Settings.builder();
|
final Settings.Builder originalIndexSettings = Settings.builder();
|
||||||
originalIndexSettings.put(INDEX_SOFT_DELETES_SETTING.getKey(), true);
|
originalIndexSettings.put(INDEX_SOFT_DELETES_SETTING.getKey(), true);
|
||||||
|
@ -68,15 +66,7 @@ public class SearchableSnapshotRecoveryStateIntegrationTests extends BaseSearcha
|
||||||
|
|
||||||
createAndPopulateIndex(indexName, originalIndexSettings);
|
createAndPopulateIndex(indexName, originalIndexSettings);
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
final SnapshotInfo snapshotInfo = createFullSnapshot(fsRepoName, snapshotName);
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.elasticsearch.xpack.searchablesnapshots;
|
package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
|
|
||||||
import org.apache.lucene.mockfile.FilterFileSystemProvider;
|
import org.apache.lucene.mockfile.FilterFileSystemProvider;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||||
|
@ -103,19 +102,14 @@ public class SearchableSnapshotsCacheClearingIntegTests extends BaseSearchableSn
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
createRepo(fsRepoName);
|
createRepository(fsRepoName, "fs");
|
||||||
|
|
||||||
final Settings.Builder originalIndexSettings = Settings.builder()
|
final Settings.Builder originalIndexSettings = Settings.builder()
|
||||||
.put(INDEX_SOFT_DELETES_SETTING.getKey(), true)
|
.put(INDEX_SOFT_DELETES_SETTING.getKey(), true)
|
||||||
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1);
|
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1);
|
||||||
createAndPopulateIndex(indexName, originalIndexSettings);
|
createAndPopulateIndex(indexName, originalIndexSettings);
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
final SnapshotInfo snapshotInfo = createFullSnapshot(fsRepoName, snapshotName);
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
|
|
@ -9,7 +9,6 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||||
import org.apache.lucene.index.IndexFileNames;
|
import org.apache.lucene.index.IndexFileNames;
|
||||||
import org.apache.lucene.search.TotalHits;
|
import org.apache.lucene.search.TotalHits;
|
||||||
import org.elasticsearch.ResourceNotFoundException;
|
import org.elasticsearch.ResourceNotFoundException;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
|
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
|
||||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||||
|
@ -39,7 +38,6 @@ import org.elasticsearch.index.shard.ShardPath;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.indices.recovery.RecoveryState;
|
import org.elasticsearch.indices.recovery.RecoveryState;
|
||||||
import org.elasticsearch.repositories.RepositoriesService;
|
import org.elasticsearch.repositories.RepositoriesService;
|
||||||
import org.elasticsearch.repositories.fs.FsRepository;
|
|
||||||
import org.elasticsearch.snapshots.SnapshotId;
|
import org.elasticsearch.snapshots.SnapshotId;
|
||||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
import org.elasticsearch.snapshots.SnapshotInfo;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
||||||
|
@ -92,13 +90,10 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
final Path repo = randomRepoPath();
|
createRepository(
|
||||||
assertAcked(
|
fsRepoName,
|
||||||
client().admin()
|
"fs",
|
||||||
.cluster()
|
Settings.builder().put("location", randomRepoPath()).put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
|
||||||
.preparePutRepository(fsRepoName)
|
|
||||||
.setType("fs")
|
|
||||||
.setSettings(Settings.builder().put("location", repo).put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but
|
// Peer recovery always copies .liv files but we do not permit writing to searchable snapshot directories so this doesn't work, but
|
||||||
|
@ -129,14 +124,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
() -> client().execute(SearchableSnapshotsStatsAction.INSTANCE, new SearchableSnapshotsStatsRequest()).actionGet()
|
() -> client().execute(SearchableSnapshotsStatsAction.INSTANCE, new SearchableSnapshotsStatsRequest()).actionGet()
|
||||||
);
|
);
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
final SnapshotInfo snapshotInfo = createFullSnapshot(fsRepoName, snapshotName);
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
|
|
||||||
assertShardFolders(indexName, false);
|
assertShardFolders(indexName, false);
|
||||||
|
@ -354,13 +342,10 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
final Path repo = randomRepoPath();
|
createRepository(
|
||||||
assertAcked(
|
fsRepoName,
|
||||||
client().admin()
|
"fs",
|
||||||
.cluster()
|
Settings.builder().put("location", randomRepoPath()).put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)
|
||||||
.preparePutRepository(fsRepoName)
|
|
||||||
.setType("fs")
|
|
||||||
.setSettings(Settings.builder().put("location", repo).put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assertAcked(prepareCreate(indexName, Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true)));
|
assertAcked(prepareCreate(indexName, Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true)));
|
||||||
|
@ -391,14 +376,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
} catch (InterruptedException | BrokenBarrierException e) {
|
} catch (InterruptedException | BrokenBarrierException e) {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
}
|
}
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
createFullSnapshot(fsRepoName, snapshotName);
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
indexingThead.start();
|
indexingThead.start();
|
||||||
|
@ -434,15 +412,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
assertAcked(
|
assertAcked(prepareCreate(indexName, indexSettingsNoReplicas(between(1, 3)).put(INDEX_SOFT_DELETES_SETTING.getKey(), true)));
|
||||||
prepareCreate(
|
|
||||||
indexName,
|
|
||||||
Settings.builder()
|
|
||||||
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, between(1, 3))
|
|
||||||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
||||||
.put(INDEX_SOFT_DELETES_SETTING.getKey(), true)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
final int nbDocs = between(10, 50);
|
final int nbDocs = between(10, 50);
|
||||||
indexRandom(
|
indexRandom(
|
||||||
true,
|
true,
|
||||||
|
@ -465,18 +435,11 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
} else {
|
} else {
|
||||||
repositorySettings.put("max_restore_bytes_per_sec", ByteSizeValue.ZERO);
|
repositorySettings.put("max_restore_bytes_per_sec", ByteSizeValue.ZERO);
|
||||||
}
|
}
|
||||||
assertAcked(
|
createRepository(repositoryName, "fs", repositorySettings);
|
||||||
client().admin().cluster().preparePutRepository(repositoryName).setType(FsRepository.TYPE).setSettings(repositorySettings)
|
|
||||||
);
|
|
||||||
|
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
final SnapshotInfo snapshotInfo = createFullSnapshot(repositoryName, snapshotName);
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(repositoryName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
||||||
|
|
||||||
|
@ -537,7 +500,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomBoolean() ? indexName : randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
createRepo(fsRepoName);
|
createRepository(fsRepoName, "fs");
|
||||||
|
|
||||||
final int dataNodesCount = internalCluster().numDataNodes();
|
final int dataNodesCount = internalCluster().numDataNodes();
|
||||||
final Settings.Builder originalIndexSettings = Settings.builder();
|
final Settings.Builder originalIndexSettings = Settings.builder();
|
||||||
|
@ -554,14 +517,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
}
|
}
|
||||||
createAndPopulateIndex(indexName, originalIndexSettings);
|
createAndPopulateIndex(indexName, originalIndexSettings);
|
||||||
|
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
createFullSnapshot(fsRepoName, snapshotName);
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
|
||||||
|
@ -665,21 +621,14 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
public void testSnapshotMountedIndexLeavesBlobsUntouched() throws Exception {
|
public void testSnapshotMountedIndexLeavesBlobsUntouched() throws Exception {
|
||||||
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String indexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final int numShards = between(1, 3);
|
final int numShards = between(1, 3);
|
||||||
createAndPopulateIndex(
|
createAndPopulateIndex(indexName, indexSettingsNoReplicas(numShards).put(INDEX_SOFT_DELETES_SETTING.getKey(), true));
|
||||||
indexName,
|
|
||||||
Settings.builder()
|
|
||||||
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numShards)
|
|
||||||
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
||||||
.put(INDEX_SOFT_DELETES_SETTING.getKey(), true)
|
|
||||||
);
|
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
forceMerge();
|
forceMerge();
|
||||||
|
|
||||||
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final Path repositoryLocation = randomRepoPath();
|
createRepository(repositoryName, "fs");
|
||||||
createFsRepository(repositoryName, repositoryLocation);
|
|
||||||
|
|
||||||
final SnapshotId snapshotOne = createSnapshot(repositoryName, Collections.singletonList(indexName));
|
final SnapshotId snapshotOne = createSnapshot(repositoryName, "snapshot-1", Collections.singletonList(indexName)).snapshotId();
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
|
||||||
final SnapshotStatus snapshotOneStatus = client().admin()
|
final SnapshotStatus snapshotOneStatus = client().admin()
|
||||||
|
@ -695,7 +644,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT
|
||||||
mountSnapshot(repositoryName, snapshotOne.getName(), indexName, indexName, Settings.EMPTY);
|
mountSnapshot(repositoryName, snapshotOne.getName(), indexName, indexName, Settings.EMPTY);
|
||||||
ensureGreen(indexName);
|
ensureGreen(indexName);
|
||||||
|
|
||||||
final SnapshotId snapshotTwo = createSnapshot(repositoryName, Collections.singletonList(indexName));
|
final SnapshotId snapshotTwo = createSnapshot(repositoryName, "snapshot-2", Collections.singletonList(indexName)).snapshotId();
|
||||||
final SnapshotStatus snapshotTwoStatus = client().admin()
|
final SnapshotStatus snapshotTwoStatus = client().admin()
|
||||||
.cluster()
|
.cluster()
|
||||||
.prepareSnapshotStatus(repositoryName)
|
.prepareSnapshotStatus(repositoryName)
|
||||||
|
|
|
@ -27,14 +27,11 @@ package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
import org.elasticsearch.ElasticsearchSecurityException;
|
import org.elasticsearch.ElasticsearchSecurityException;
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
import org.elasticsearch.action.ActionFuture;
|
import org.elasticsearch.action.ActionFuture;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
|
||||||
import org.elasticsearch.cluster.ClusterState;
|
import org.elasticsearch.cluster.ClusterState;
|
||||||
import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
|
||||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.cluster.metadata.Metadata;
|
import org.elasticsearch.cluster.metadata.Metadata;
|
||||||
import org.elasticsearch.cluster.service.ClusterService;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.IndexSettings;
|
import org.elasticsearch.index.IndexSettings;
|
||||||
|
@ -47,7 +44,6 @@ import org.elasticsearch.license.PostStartTrialAction;
|
||||||
import org.elasticsearch.license.PostStartTrialRequest;
|
import org.elasticsearch.license.PostStartTrialRequest;
|
||||||
import org.elasticsearch.license.PostStartTrialResponse;
|
import org.elasticsearch.license.PostStartTrialResponse;
|
||||||
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
|
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
|
||||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
||||||
|
@ -59,7 +55,6 @@ import org.elasticsearch.xpack.searchablesnapshots.action.SearchableSnapshotsSta
|
||||||
import org.elasticsearch.xpack.searchablesnapshots.action.SearchableSnapshotsStatsResponse;
|
import org.elasticsearch.xpack.searchablesnapshots.action.SearchableSnapshotsStatsResponse;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
|
@ -78,18 +73,9 @@ public class SearchableSnapshotsLicenseIntegTests extends BaseSearchableSnapshot
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void createAndMountSearchableSnapshot() throws Exception {
|
public void createAndMountSearchableSnapshot() throws Exception {
|
||||||
createRepo(repoName);
|
createRepository(repoName, "fs");
|
||||||
|
|
||||||
createIndex(indexName);
|
createIndex(indexName);
|
||||||
|
createFullSnapshot(repoName, snapshotName);
|
||||||
CreateSnapshotResponse createSnapshotResponse = client().admin()
|
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(repoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
|
||||||
|
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
|
|
||||||
|
@ -173,27 +159,11 @@ public class SearchableSnapshotsLicenseIntegTests extends BaseSearchableSnapshot
|
||||||
// add a valid license again
|
// add a valid license again
|
||||||
// This is a bit of a hack in tests, as we can't readd a trial license
|
// This is a bit of a hack in tests, as we can't readd a trial license
|
||||||
// We force this by clearing the existing basic license first
|
// We force this by clearing the existing basic license first
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
updateClusterState(
|
||||||
internalCluster().getCurrentMasterNodeInstance(ClusterService.class)
|
currentState -> ClusterState.builder(currentState)
|
||||||
.submitStateUpdateTask("remove license", new ClusterStateUpdateTask() {
|
|
||||||
@Override
|
|
||||||
public ClusterState execute(ClusterState currentState) {
|
|
||||||
return ClusterState.builder(currentState)
|
|
||||||
.metadata(Metadata.builder(currentState.metadata()).removeCustom(LicensesMetadata.TYPE).build())
|
.metadata(Metadata.builder(currentState.metadata()).removeCustom(LicensesMetadata.TYPE).build())
|
||||||
.build();
|
.build()
|
||||||
}
|
);
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(String source, Exception e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) {
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
latch.await();
|
|
||||||
PostStartTrialRequest startTrialRequest = new PostStartTrialRequest().setType(License.LicenseType.TRIAL.getTypeName())
|
PostStartTrialRequest startTrialRequest = new PostStartTrialRequest().setType(License.LicenseType.TRIAL.getTypeName())
|
||||||
.acknowledge(true);
|
.acknowledge(true);
|
||||||
PostStartTrialResponse resp = client().execute(PostStartTrialAction.INSTANCE, startTrialRequest).get();
|
PostStartTrialResponse resp = client().execute(PostStartTrialAction.INSTANCE, startTrialRequest).get();
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.elasticsearch.xpack.searchablesnapshots;
|
package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.OriginSettingClient;
|
import org.elasticsearch.client.OriginSettingClient;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
import org.elasticsearch.cluster.metadata.IndexMetadata;
|
||||||
|
@ -16,12 +15,14 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.indices.SystemIndexDescriptor;
|
import org.elasticsearch.indices.SystemIndexDescriptor;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.plugins.SystemIndexPlugin;
|
import org.elasticsearch.plugins.SystemIndexPlugin;
|
||||||
|
import org.elasticsearch.snapshots.SnapshotInfo;
|
||||||
import org.elasticsearch.xpack.core.ClientHelper;
|
import org.elasticsearch.xpack.core.ClientHelper;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -51,19 +52,13 @@ public class SearchableSnapshotsSystemIndicesIntegTests extends BaseSearchableSn
|
||||||
createAndPopulateIndex(indexName, Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, isHidden));
|
createAndPopulateIndex(indexName, Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, isHidden));
|
||||||
|
|
||||||
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String repositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
createRepo(repositoryName);
|
createRepository(repositoryName, "fs");
|
||||||
|
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final CreateSnapshotResponse snapshotResponse = client.admin()
|
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(repositoryName, snapshotName)
|
|
||||||
.setIndices(indexName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
final int numPrimaries = getNumShards(indexName).numPrimaries;
|
final int numPrimaries = getNumShards(indexName).numPrimaries;
|
||||||
assertThat(snapshotResponse.getSnapshotInfo().successfulShards(), equalTo(numPrimaries));
|
final SnapshotInfo snapshotInfo = createSnapshot(repositoryName, snapshotName, Collections.singletonList(indexName));
|
||||||
assertThat(snapshotResponse.getSnapshotInfo().failedShards(), equalTo(0));
|
assertThat(snapshotInfo.successfulShards(), equalTo(numPrimaries));
|
||||||
|
assertThat(snapshotInfo.failedShards(), equalTo(0));
|
||||||
|
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
assertAcked(client.admin().indices().prepareClose(indexName));
|
assertAcked(client.admin().indices().prepareClose(indexName));
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.elasticsearch.xpack.searchablesnapshots;
|
||||||
import org.elasticsearch.action.ActionFuture;
|
import org.elasticsearch.action.ActionFuture;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.ActionRequest;
|
import org.elasticsearch.action.ActionRequest;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotAction;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotAction;
|
||||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||||
import org.elasticsearch.action.support.ActionFilter;
|
import org.elasticsearch.action.support.ActionFilter;
|
||||||
|
@ -19,7 +18,6 @@ import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.plugins.ActionPlugin;
|
import org.elasticsearch.plugins.ActionPlugin;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.snapshots.SnapshotInfo;
|
|
||||||
import org.elasticsearch.snapshots.SnapshotRestoreException;
|
import org.elasticsearch.snapshots.SnapshotRestoreException;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotAction;
|
||||||
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
||||||
|
@ -34,8 +32,6 @@ import static java.util.Collections.singletonList;
|
||||||
import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_SETTING;
|
import static org.elasticsearch.index.IndexSettings.INDEX_SOFT_DELETES_SETTING;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
|
||||||
import static org.hamcrest.Matchers.greaterThan;
|
|
||||||
|
|
||||||
public class SearchableSnapshotsUuidValidationIntegTests extends BaseSearchableSnapshotsIntegTestCase {
|
public class SearchableSnapshotsUuidValidationIntegTests extends BaseSearchableSnapshotsIntegTestCase {
|
||||||
|
|
||||||
|
@ -91,12 +87,12 @@ public class SearchableSnapshotsUuidValidationIntegTests extends BaseSearchableS
|
||||||
final String restoredIndexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String restoredIndexName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
final String snapshotName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
createRepo(fsRepoName);
|
createRepository(fsRepoName, "fs");
|
||||||
|
|
||||||
final Settings.Builder originalIndexSettings = Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true);
|
final Settings.Builder originalIndexSettings = Settings.builder().put(INDEX_SOFT_DELETES_SETTING.getKey(), true);
|
||||||
createAndPopulateIndex(indexName, originalIndexSettings);
|
createAndPopulateIndex(indexName, originalIndexSettings);
|
||||||
|
|
||||||
createSnapshot(fsRepoName, snapshotName);
|
createFullSnapshot(fsRepoName, snapshotName);
|
||||||
|
|
||||||
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
|
final MountSearchableSnapshotRequest req = new MountSearchableSnapshotRequest(
|
||||||
restoredIndexName,
|
restoredIndexName,
|
||||||
|
@ -114,7 +110,7 @@ public class SearchableSnapshotsUuidValidationIntegTests extends BaseSearchableS
|
||||||
restoreBlockingActionFilter.awaitExecution();
|
restoreBlockingActionFilter.awaitExecution();
|
||||||
|
|
||||||
assertAcked(client().admin().cluster().prepareDeleteSnapshot(fsRepoName, snapshotName).get());
|
assertAcked(client().admin().cluster().prepareDeleteSnapshot(fsRepoName, snapshotName).get());
|
||||||
createSnapshot(fsRepoName, snapshotName);
|
createFullSnapshot(fsRepoName, snapshotName);
|
||||||
|
|
||||||
assertFalse(responseFuture.isDone());
|
assertFalse(responseFuture.isDone());
|
||||||
restoreBlockingActionFilter.unblock();
|
restoreBlockingActionFilter.unblock();
|
||||||
|
@ -127,17 +123,6 @@ public class SearchableSnapshotsUuidValidationIntegTests extends BaseSearchableS
|
||||||
assertAcked(client().admin().indices().prepareDelete(indexName));
|
assertAcked(client().admin().indices().prepareDelete(indexName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void createSnapshot(String fsRepoName, String snapshotName) {
|
|
||||||
final CreateSnapshotResponse createSnapshotResponse = client().admin()
|
|
||||||
.cluster()
|
|
||||||
.prepareCreateSnapshot(fsRepoName, snapshotName)
|
|
||||||
.setWaitForCompletion(true)
|
|
||||||
.get();
|
|
||||||
final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo();
|
|
||||||
assertThat(snapshotInfo.successfulShards(), greaterThan(0));
|
|
||||||
assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RestoreBlockingActionFilter getBlockingActionFilter() {
|
private static RestoreBlockingActionFilter getBlockingActionFilter() {
|
||||||
for (final ActionFilter filter : internalCluster().getCurrentMasterNodeInstance(ActionFilters.class).filters()) {
|
for (final ActionFilter filter : internalCluster().getCurrentMasterNodeInstance(ActionFilters.class).filters()) {
|
||||||
if (filter instanceof RestoreBlockingActionFilter) {
|
if (filter instanceof RestoreBlockingActionFilter) {
|
||||||
|
|
Loading…
Reference in New Issue