Add helper method so indices path is not copied all over

This commit is contained in:
Ryan Ernst 2015-09-09 15:51:34 -07:00
parent 8f75c2b3a8
commit 5c810eff59
6 changed files with 13 additions and 17 deletions

View File

@ -98,8 +98,7 @@ public class OldIndexBackwardsCompatibilityIT extends ESIntegTestCase {
private List<String> loadIndexesList(String prefix) throws IOException {
List<String> indexes = new ArrayList<>();
Path dir = getDataPath("/indices/bwc");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, prefix + "-*.zip")) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(getBwcIndicesPath(), prefix + "-*.zip")) {
for (Path path : stream) {
indexes.add(path.getFileName().toString());
}

View File

@ -62,12 +62,12 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
// Configure using path.repo
return settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.put("path.repo", reposRoot())
.put("path.repo", getBwcIndicesPath())
.build();
} else {
// Configure using url white list
try {
URI repoJarPatternUri = new URI("jar:" + reposRoot().toUri().toString() + "*.zip!/repo/");
URI repoJarPatternUri = new URI("jar:" + getBwcIndicesPath().toUri().toString() + "*.zip!/repo/");
return settingsBuilder()
.put(super.nodeSettings(nodeOrdinal))
.putArray("repositories.url.allowed_urls", repoJarPatternUri.toString())
@ -128,10 +128,6 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
}
}
private Path reposRoot() {
return getDataPath("/indices/bwc");
}
private List<String> repoVersions() throws Exception {
return listRepoVersions("repo");
}
@ -142,7 +138,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
private List<String> listRepoVersions(String prefix) throws Exception {
List<String> repoVersions = new ArrayList<>();
Path repoFiles = reposRoot();
Path repoFiles = getBwcIndicesPath();
try (DirectoryStream<Path> stream = Files.newDirectoryStream(repoFiles, prefix + "-*.zip")) {
for (Path entry : stream) {
String fileName = entry.getFileName().toString();
@ -155,8 +151,8 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
}
private void createRepo(String prefix, String version, String repo) throws Exception {
String repoFile = "/indices/bwc/" + prefix + "-" + version + ".zip";
URI repoFileUri = getDataPath(repoFile).toUri();
Path repoFile = getBwcIndicesPath().resolve(prefix + "-" + version + ".zip");
URI repoFileUri = repoFile.toUri();
URI repoJarUri = new URI("jar:" + repoFileUri.toString() + "!/repo/");
logger.info("--> creating repository [{}] for version [{}]", repo, version);
assertAcked(client().admin().cluster().preparePutRepository(repo)

View File

@ -133,8 +133,7 @@ public class MultiDataPathUpgraderTests extends ESTestCase {
*/
public void testUpgradeRealIndex() throws IOException, URISyntaxException {
List<Path> indexes = new ArrayList<>();
Path dir = getDataPath("/indices/bwc");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "index-*.zip")) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(getBwcIndicesPath(), "index-*.zip")) {
for (Path path : stream) {
indexes.add(path);
}

View File

@ -1786,8 +1786,7 @@ public class InternalEngineTests extends ESTestCase {
public void testUpgradeOldIndex() throws IOException {
List<Path> indexes = new ArrayList<>();
Path dir = getDataPath("/indices/bwc");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "index-*.zip")) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(getBwcIndicesPath(), "index-*.zip")) {
for (Path path : stream) {
indexes.add(path);
}

View File

@ -1157,8 +1157,7 @@ public class TranslogTests extends ESTestCase {
public void testUpgradeOldTranslogFiles() throws IOException {
List<Path> indexes = new ArrayList<>();
Path dir = getDataPath("/indices/bwc");
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "index-*.zip")) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(getBwcIndicesPath(), "index-*.zip")) {
for (Path path : stream) {
indexes.add(path);
}

View File

@ -488,6 +488,10 @@ public abstract class ESTestCase extends LuceneTestCase {
}
}
public Path getBwcIndicesPath() {
return getDataPath("/indices/bwc");
}
/** Returns a random number of temporary paths. */
public String[] tmpPaths() {
final int numPaths = TestUtil.nextInt(random(), 1, 3);