From 2d9e5b48078b911eaf7ba969807fe34d24a965ef Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 17 Apr 2015 08:26:25 -0400 Subject: [PATCH] fix FileSystemUtils failures --- .../elasticsearch/common/io/FileSystemUtils.java | 2 ++ .../org/elasticsearch/NamingConventionTests.java | 2 +- .../OldIndexBackwardsCompatibilityTests.java | 4 ++-- .../bwcompat/RestoreBackwardsCompatTests.java | 2 +- ...utingBackwardCompatibilityUponUpgradeTests.java | 2 +- .../allocation/BalanceUnbalancedClusterTest.java | 2 +- .../common/io/FileSystemUtilsTests.java | 2 +- .../common/logging/log4j/Log4jESLoggerTests.java | 2 +- .../logging/log4j/LoggingConfigurationTests.java | 2 +- .../analysis/HunspellTokenFilterFactoryTests.java | 4 ++-- .../index/query/TemplateQueryParserTest.java | 2 +- .../index/query/TemplateQueryTest.java | 2 +- .../index/translog/TranslogVersionTests.java | 12 ++++++------ .../indices/analyze/HunspellServiceTests.java | 10 +++++----- .../org/elasticsearch/plugins/PluginTestCase.java | 2 +- .../org/elasticsearch/plugins/SitePluginTests.java | 2 +- .../elasticsearch/script/OnDiskScriptTests.java | 2 +- .../SignificantTermsSignificanceScoreTests.java | 2 +- .../aggregations/metrics/ScriptedMetricTests.java | 2 +- .../elasticsearch/test/ElasticsearchTestCase.java | 14 ++++++++++---- .../org/elasticsearch/tribe/TribeUnitTests.java | 2 +- 21 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java b/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java index a0a7f50de4f..50f845f754a 100644 --- a/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java +++ b/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java @@ -258,6 +258,8 @@ public final class FileSystemUtils { Files.walkFileTree(source, new TreeCopier(source, destination, true)); } } + + // TODO: note that this will fail if source and target are on different NIO.2 filesystems. static class TreeCopier extends SimpleFileVisitor { private final Path source; diff --git a/src/test/java/org/elasticsearch/NamingConventionTests.java b/src/test/java/org/elasticsearch/NamingConventionTests.java index ff6c2f58e89..885649a1cec 100644 --- a/src/test/java/org/elasticsearch/NamingConventionTests.java +++ b/src/test/java/org/elasticsearch/NamingConventionTests.java @@ -55,7 +55,7 @@ public class NamingConventionTests extends ElasticsearchTestCase { String[] packages = {"org.elasticsearch", "org.apache.lucene"}; for (final String packageName : packages) { final String path = "/" + packageName.replace('.', '/'); - final Path startPath = getResourcePath(path); + final Path startPath = getDataPath(path); final Set ignore = Sets.newHashSet(PathUtils.get("/org/elasticsearch/stresstest"), PathUtils.get("/org/elasticsearch/benchmark/stress")); Files.walkFileTree(startPath, new FileVisitor() { private Path pkgPrefix = PathUtils.get(path).getParent(); diff --git a/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java b/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java index 01141ac7e2e..8e563877207 100644 --- a/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java +++ b/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityTests.java @@ -85,7 +85,7 @@ public class OldIndexBackwardsCompatibilityTests extends ElasticsearchIntegratio @Before public void initIndexesList() throws Exception { indexes = new ArrayList<>(); - Path dir = getResourcePath("."); + Path dir = getDataPath("."); try (DirectoryStream stream = Files.newDirectoryStream(dir, "index-*.zip")) { for (Path path : stream) { indexes.add(path.getFileName().toString()); @@ -153,7 +153,7 @@ public class OldIndexBackwardsCompatibilityTests extends ElasticsearchIntegratio String indexName = indexFile.replace(".zip", "").toLowerCase(Locale.ROOT); // decompress the index - Path backwardsIndex = getResourcePath(indexFile); + Path backwardsIndex = getDataPath(indexFile); try (InputStream stream = Files.newInputStream(backwardsIndex)) { TestUtil.unzip(stream, unzipDir); } diff --git a/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatTests.java b/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatTests.java index 90120ca3a79..70288427a96 100644 --- a/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatTests.java +++ b/src/test/java/org/elasticsearch/bwcompat/RestoreBackwardsCompatTests.java @@ -95,7 +95,7 @@ public class RestoreBackwardsCompatTests extends AbstractSnapshotTests { private List repoVersions() throws Exception { List repoVersions = newArrayList(); - Path repoFiles = getResourcePath("."); + Path repoFiles = getDataPath("."); try (DirectoryStream stream = Files.newDirectoryStream(repoFiles, "repo-*.zip")) { for (Path entry : stream) { String fileName = entry.getFileName().toString(); diff --git a/src/test/java/org/elasticsearch/cluster/routing/RoutingBackwardCompatibilityUponUpgradeTests.java b/src/test/java/org/elasticsearch/cluster/routing/RoutingBackwardCompatibilityUponUpgradeTests.java index 9392b8bb6b0..b0ec52e3bbd 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/RoutingBackwardCompatibilityUponUpgradeTests.java +++ b/src/test/java/org/elasticsearch/cluster/routing/RoutingBackwardCompatibilityUponUpgradeTests.java @@ -49,7 +49,7 @@ public class RoutingBackwardCompatibilityUponUpgradeTests extends ElasticsearchI } private void test(String name, Class expectedHashFunction, boolean expectedUseType) throws Exception { - Path zippedIndexDir = getResourcePath("/org/elasticsearch/cluster/routing/" + name + ".zip"); + Path zippedIndexDir = getDataPath("/org/elasticsearch/cluster/routing/" + name + ".zip"); Settings baseSettings = prepareBackwardsDataDir(zippedIndexDir); internalCluster().startNode(ImmutableSettings.builder() .put(baseSettings) diff --git a/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceUnbalancedClusterTest.java b/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceUnbalancedClusterTest.java index fc3fb6af17d..0185a7c0204 100644 --- a/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceUnbalancedClusterTest.java +++ b/src/test/java/org/elasticsearch/cluster/routing/allocation/BalanceUnbalancedClusterTest.java @@ -45,7 +45,7 @@ public class BalanceUnbalancedClusterTest extends CatAllocationTestBase { @Override protected Path getCatPath() throws IOException { Path tmp = newTempDirPath(); - try (InputStream stream = Files.newInputStream(getResourcePath("/org/elasticsearch/cluster/routing/issue_9023.zip"))) { + try (InputStream stream = Files.newInputStream(getDataPath("/org/elasticsearch/cluster/routing/issue_9023.zip"))) { TestUtil.unzip(stream, tmp); } return tmp.resolve("issue_9023"); diff --git a/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java b/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java index 88546b9bcda..031fa5c40ac 100644 --- a/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java +++ b/src/test/java/org/elasticsearch/common/io/FileSystemUtilsTests.java @@ -55,7 +55,7 @@ public class FileSystemUtilsTests extends ElasticsearchTestCase { // We first copy sources test files from src/test/resources // Because after when the test runs, src files are moved to their destination - final Path path = getResourcePath("/org/elasticsearch/common/io/copyappend"); + final Path path = getDataPath("/org/elasticsearch/common/io/copyappend"); FileSystemUtils.copyDirectoryRecursively(path, src); } diff --git a/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java b/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java index 49b02d2604c..c39c8a5b90f 100644 --- a/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java +++ b/src/test/java/org/elasticsearch/common/logging/log4j/Log4jESLoggerTests.java @@ -52,7 +52,7 @@ public class Log4jESLoggerTests extends ElasticsearchTestCase { super.setUp(); this.testLevel = Log4jESLoggerFactory.getLogger("test").getLevel(); LogConfigurator.reset(); - Path configDir = getResourcePath("config"); + Path configDir = getDataPath("config"); // Need to set custom path.conf so we can use a custom logging.yml file for the test Settings settings = ImmutableSettings.builder() .put("path.conf", configDir.toAbsolutePath()) diff --git a/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java b/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java index 651c2322601..50bc90b6dbf 100644 --- a/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java +++ b/src/test/java/org/elasticsearch/common/logging/log4j/LoggingConfigurationTests.java @@ -56,7 +56,7 @@ public class LoggingConfigurationTests extends ElasticsearchTestCase { public void testResolveMultipleConfigs() throws Exception { String level = Log4jESLoggerFactory.getLogger("test").getLevel(); try { - Path configDir = getResourcePath("config"); + Path configDir = getDataPath("config"); Settings settings = ImmutableSettings.builder() .put("path.conf", configDir.toAbsolutePath()) .build(); diff --git a/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java b/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java index a547fb88805..cb79991b90c 100644 --- a/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java +++ b/src/test/java/org/elasticsearch/index/analysis/HunspellTokenFilterFactoryTests.java @@ -33,7 +33,7 @@ public class HunspellTokenFilterFactoryTests extends ElasticsearchTestCase { @Test public void testDedup() throws IOException { Settings settings = settingsBuilder() - .put("path.conf", getResourcePath("/indices/analyze/conf_dir")) + .put("path.conf", getDataPath("/indices/analyze/conf_dir")) .put("index.analysis.filter.en_US.type", "hunspell") .put("index.analysis.filter.en_US.locale", "en_US") .build(); @@ -45,7 +45,7 @@ public class HunspellTokenFilterFactoryTests extends ElasticsearchTestCase { assertThat(hunspellTokenFilter.dedup(), is(true)); settings = settingsBuilder() - .put("path.conf", getResourcePath("/indices/analyze/conf_dir")) + .put("path.conf", getDataPath("/indices/analyze/conf_dir")) .put("index.analysis.filter.en_US.type", "hunspell") .put("index.analysis.filter.en_US.dedup", false) .put("index.analysis.filter.en_US.locale", "en_US") diff --git a/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java b/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java index ddaecec2fa8..36611e1b43c 100644 --- a/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java +++ b/src/test/java/org/elasticsearch/index/query/TemplateQueryParserTest.java @@ -66,7 +66,7 @@ public class TemplateQueryParserTest extends ElasticsearchTestCase { @Before public void setup() throws IOException { Settings settings = ImmutableSettings.settingsBuilder() - .put("path.conf", this.getResourcePath("config")) + .put("path.conf", this.getDataPath("config")) .put("name", getClass().getName()) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .build(); diff --git a/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java b/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java index 0d8b8909d21..0adcba647fd 100644 --- a/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java +++ b/src/test/java/org/elasticsearch/index/query/TemplateQueryTest.java @@ -66,7 +66,7 @@ public class TemplateQueryTest extends ElasticsearchIntegrationTest { @Override public Settings nodeSettings(int nodeOrdinal) { return settingsBuilder().put(super.nodeSettings(nodeOrdinal)) - .put("path.conf", this.getResourcePath("config")).build(); + .put("path.conf", this.getDataPath("config")).build(); } @Test diff --git a/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java b/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java index 92cf4eb021d..076fe05335e 100644 --- a/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java +++ b/src/test/java/org/elasticsearch/index/translog/TranslogVersionTests.java @@ -42,7 +42,7 @@ public class TranslogVersionTests extends ElasticsearchTestCase { @Test public void testV0LegacyTranslogVersion() throws Exception { - Path translogFile = getResourcePath("/org/elasticsearch/index/translog/translog-v0.binary"); + Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v0.binary"); assertThat("test file should exist", Files.exists(translogFile), equalTo(true)); TranslogStream stream = TranslogStreams.translogStreamFor(translogFile); assertThat("a version0 stream is returned", stream instanceof LegacyTranslogStream, equalTo(true)); @@ -75,7 +75,7 @@ public class TranslogVersionTests extends ElasticsearchTestCase { @Test public void testV1ChecksummedTranslogVersion() throws Exception { - Path translogFile = getResourcePath("/org/elasticsearch/index/translog/translog-v1.binary"); + Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1.binary"); assertThat("test file should exist", Files.exists(translogFile), equalTo(true)); TranslogStream stream = TranslogStreams.translogStreamFor(translogFile); assertThat("a version1 stream is returned", stream instanceof ChecksummedTranslogStream, equalTo(true)); @@ -111,7 +111,7 @@ public class TranslogVersionTests extends ElasticsearchTestCase { @Test public void testCorruptedTranslogs() throws Exception { try { - Path translogFile = getResourcePath("/org/elasticsearch/index/translog/translog-v1-corrupted-magic.binary"); + Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1-corrupted-magic.binary"); assertThat("test file should exist", Files.exists(translogFile), equalTo(true)); TranslogStream stream = TranslogStreams.translogStreamFor(translogFile); fail("should have thrown an exception about the header being corrupt"); @@ -121,7 +121,7 @@ public class TranslogVersionTests extends ElasticsearchTestCase { } try { - Path translogFile = getResourcePath("/org/elasticsearch/index/translog/translog-invalid-first-byte.binary"); + Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-invalid-first-byte.binary"); assertThat("test file should exist", Files.exists(translogFile), equalTo(true)); TranslogStream stream = TranslogStreams.translogStreamFor(translogFile); fail("should have thrown an exception about the header being corrupt"); @@ -131,7 +131,7 @@ public class TranslogVersionTests extends ElasticsearchTestCase { } try { - Path translogFile = getResourcePath("/org/elasticsearch/index/translog/translog-v1-corrupted-body.binary"); + Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1-corrupted-body.binary"); assertThat("test file should exist", Files.exists(translogFile), equalTo(true)); TranslogStream stream = TranslogStreams.translogStreamFor(translogFile); try (StreamInput in = stream.openInput(translogFile)) { @@ -154,7 +154,7 @@ public class TranslogVersionTests extends ElasticsearchTestCase { @Test public void testTruncatedTranslog() throws Exception { try { - Path translogFile = getResourcePath("/org/elasticsearch/index/translog/translog-v1-truncated.binary"); + Path translogFile = getDataPath("/org/elasticsearch/index/translog/translog-v1-truncated.binary"); assertThat("test file should exist", Files.exists(translogFile), equalTo(true)); TranslogStream stream = TranslogStreams.translogStreamFor(translogFile); try (StreamInput in = stream.openInput(translogFile)) { diff --git a/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java b/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java index cbaef97c5d0..304940e8141 100644 --- a/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java +++ b/src/test/java/org/elasticsearch/indices/analyze/HunspellServiceTests.java @@ -45,7 +45,7 @@ public class HunspellServiceTests extends ElasticsearchIntegrationTest { @Test public void testLocaleDirectoryWithNodeLevelConfig() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() - .put("path.conf", getResourcePath("/indices/analyze/conf_dir")) + .put("path.conf", getDataPath("/indices/analyze/conf_dir")) .put(HUNSPELL_LAZY_LOAD, randomBoolean()) .put(HUNSPELL_IGNORE_CASE, true) .build(); @@ -59,7 +59,7 @@ public class HunspellServiceTests extends ElasticsearchIntegrationTest { @Test public void testLocaleDirectoryWithLocaleSpecificConfig() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() - .put("path.conf", getResourcePath("/indices/analyze/conf_dir")) + .put("path.conf", getDataPath("/indices/analyze/conf_dir")) .put(HUNSPELL_LAZY_LOAD, randomBoolean()) .put(HUNSPELL_IGNORE_CASE, true) .put("indices.analysis.hunspell.dictionary.en_US.strict_affix_parsing", false) @@ -82,7 +82,7 @@ public class HunspellServiceTests extends ElasticsearchIntegrationTest { @Test public void testCustomizeLocaleDirectory() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() - .put(HUNSPELL_LOCATION, getResourcePath("/indices/analyze/conf_dir/hunspell")) + .put(HUNSPELL_LOCATION, getDataPath("/indices/analyze/conf_dir/hunspell")) .build(); internalCluster().startNode(settings); @@ -93,7 +93,7 @@ public class HunspellServiceTests extends ElasticsearchIntegrationTest { @Test public void testDicWithNoAff() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() - .put("path.conf", getResourcePath("/indices/analyze/no_aff_conf_dir")) + .put("path.conf", getDataPath("/indices/analyze/no_aff_conf_dir")) .put(HUNSPELL_LAZY_LOAD, randomBoolean()) .build(); @@ -112,7 +112,7 @@ public class HunspellServiceTests extends ElasticsearchIntegrationTest { @Test public void testDicWithTwoAffs() throws Exception { Settings settings = ImmutableSettings.settingsBuilder() - .put("path.conf", getResourcePath("/indices/analyze/two_aff_conf_dir")) + .put("path.conf", getDataPath("/indices/analyze/two_aff_conf_dir")) .put(HUNSPELL_LAZY_LOAD, randomBoolean()) .build(); diff --git a/src/test/java/org/elasticsearch/plugins/PluginTestCase.java b/src/test/java/org/elasticsearch/plugins/PluginTestCase.java index 00b762cac58..1b0668120da 100644 --- a/src/test/java/org/elasticsearch/plugins/PluginTestCase.java +++ b/src/test/java/org/elasticsearch/plugins/PluginTestCase.java @@ -42,7 +42,7 @@ public abstract class PluginTestCase extends ElasticsearchIntegrationTest { ImmutableSettings.Builder settings = settingsBuilder(); settings.put(nodeSettings); if (resource != null) { - settings.put("path.plugins", getResourcePath(pluginDir).toAbsolutePath()); + settings.put("path.plugins", getDataPath(pluginDir).toAbsolutePath()); } if (pluginClassNames.length > 0) { diff --git a/src/test/java/org/elasticsearch/plugins/SitePluginTests.java b/src/test/java/org/elasticsearch/plugins/SitePluginTests.java index 31fc1f1cf80..7889ec9ead9 100644 --- a/src/test/java/org/elasticsearch/plugins/SitePluginTests.java +++ b/src/test/java/org/elasticsearch/plugins/SitePluginTests.java @@ -49,7 +49,7 @@ public class SitePluginTests extends ElasticsearchIntegrationTest { @Override protected Settings nodeSettings(int nodeOrdinal) { - Path pluginDir = getResourcePath("/org/elasticsearch/plugins"); + Path pluginDir = getDataPath("/org/elasticsearch/plugins"); return settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) .put("path.plugins", pluginDir.toAbsolutePath()) diff --git a/src/test/java/org/elasticsearch/script/OnDiskScriptTests.java b/src/test/java/org/elasticsearch/script/OnDiskScriptTests.java index 7a73ab7d470..78a28520d4a 100644 --- a/src/test/java/org/elasticsearch/script/OnDiskScriptTests.java +++ b/src/test/java/org/elasticsearch/script/OnDiskScriptTests.java @@ -44,7 +44,7 @@ public class OnDiskScriptTests extends ElasticsearchIntegrationTest { public Settings nodeSettings(int nodeOrdinal) { //Set path so ScriptService will pick up the test scripts return settingsBuilder().put(super.nodeSettings(nodeOrdinal)) - .put("path.conf", this.getResourcePath("config")) + .put("path.conf", this.getDataPath("config")) .put("script.engine.expression.file.aggs", "off") .put("script.engine.mustache.file.aggs", "off") .put("script.engine.mustache.file.search", "off") diff --git a/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreTests.java b/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreTests.java index ab08c6765c4..86722eed01b 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/bucket/SignificantTermsSignificanceScoreTests.java @@ -79,7 +79,7 @@ public class SignificantTermsSignificanceScoreTests extends ElasticsearchIntegra return settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) .put("plugin.types", CustomSignificanceHeuristicPlugin.class.getName()) - .put("path.conf", this.getResourcePath("config")) + .put("path.conf", this.getDataPath("config")) .build(); } diff --git a/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java b/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java index 7dfd0e050ce..10a8df25b98 100644 --- a/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java +++ b/src/test/java/org/elasticsearch/search/aggregations/metrics/ScriptedMetricTests.java @@ -115,7 +115,7 @@ public class ScriptedMetricTests extends ElasticsearchIntegrationTest { protected Settings nodeSettings(int nodeOrdinal) { Settings settings = ImmutableSettings.settingsBuilder() .put(super.nodeSettings(nodeOrdinal)) - .put("path.conf", getResourcePath("/org/elasticsearch/search/aggregations/metrics/scripted/conf")) + .put("path.conf", getDataPath("/org/elasticsearch/search/aggregations/metrics/scripted/conf")) .build(); return settings; } diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java b/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java index d39b9cd654b..1b4131646ab 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchTestCase.java @@ -57,6 +57,8 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.net.URI; import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; @@ -173,11 +175,15 @@ public abstract class ElasticsearchTestCase extends ESTestCase { * return URL encoded paths if the parent path contains spaces or other * non-standard characters. */ - public Path getResourcePath(String relativePath) { + @Override + public Path getDataPath(String relativePath) { + // we override LTC behavior here: wrap even resources with mockfilesystems, + // because some code is buggy when it comes to multiple nio.2 filesystems + // (e.g. FileSystemUtils, and likely some tests) try { - return getDataPath(relativePath); - } catch (IOException e) { - throw new RuntimeException(e); + return PathUtils.get(getClass().getResource(relativePath).toURI()); + } catch (Exception e) { + throw new RuntimeException("resource not found: " + relativePath, e); } } diff --git a/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java b/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java index d116f199292..2089404165c 100644 --- a/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java +++ b/src/test/java/org/elasticsearch/tribe/TribeUnitTests.java @@ -86,7 +86,7 @@ public class TribeUnitTests extends ElasticsearchTestCase { @Test public void testThatTribeClientsIgnoreGlobalConfig() throws Exception { - Path pathConf = getResourcePath("elasticsearch.yml").getParent(); + Path pathConf = getDataPath("elasticsearch.yml").getParent(); Settings settings = ImmutableSettings.builder().put("config.ignore_system_properties", true).put("path.conf", pathConf).build(); assertTribeNodeSuccesfullyCreated(settings); }