Fix Path comparisons for Windows tests (#46503) (#46566)

* Fix Path comparisons for Windows tests

The test NodeEnvironmentTests#testCustonDataPaths worked just fine on
Darwin and Linux, but the comparison was breaking in Windows because one
path had the "C:\" prefix and the other one didn't. The simple fix is to
compare absolute paths rather than potentially relative ones.
This commit is contained in:
William Brafford 2019-09-11 09:33:00 -04:00 committed by GitHub
parent aa0c586b73
commit 8c9f15db44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,7 +19,6 @@
package org.elasticsearch.env;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.util.Constants;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.internal.io.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
@ -390,7 +389,6 @@ public class NodeEnvironmentTests extends ESTestCase {
}
public void testCustomDataPaths() throws Exception {
assumeFalse("Fails on Windows, see https://github.com/elastic/elasticsearch/issues/45333", Constants.WINDOWS);
String[] dataPaths = tmpPaths();
NodeEnvironment env = newNodeEnvironment(dataPaths, "/tmp", Settings.EMPTY);
@ -406,7 +404,8 @@ public class NodeEnvironmentTests extends ESTestCase {
assertTrue("settings with path_data should have a custom data path", s2.hasCustomDataPath());
assertThat(env.availableShardPaths(sid), equalTo(env.availableShardPaths(sid)));
assertThat(env.resolveCustomLocation(s2, sid), equalTo(PathUtils.get("/tmp/foo/0/" + index.getUUID() + "/0")));
assertThat(env.resolveCustomLocation(s2, sid).toAbsolutePath(),
equalTo(PathUtils.get("/tmp/foo/0/" + index.getUUID() + "/0").toAbsolutePath()));
assertThat("shard paths with a custom data_path should contain only regular paths",
env.availableShardPaths(sid),
@ -418,7 +417,8 @@ public class NodeEnvironmentTests extends ESTestCase {
IndexSettings s3 = new IndexSettings(s2.getIndexMetaData(), Settings.builder().build());
assertThat(env.availableShardPaths(sid), equalTo(env.availableShardPaths(sid)));
assertThat(env.resolveCustomLocation(s3, sid), equalTo(PathUtils.get("/tmp/foo/0/" + index.getUUID() + "/0")));
assertThat(env.resolveCustomLocation(s3, sid).toAbsolutePath(),
equalTo(PathUtils.get("/tmp/foo/0/" + index.getUUID() + "/0").toAbsolutePath()));
assertThat("shard paths with a custom data_path should contain only regular paths",
env.availableShardPaths(sid),