Skip to content

Commit

Permalink
Fix Path comparisons for Windows tests (elastic#46503)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
williamrandolph committed Sep 10, 2019
1 parent f1cbaa5 commit 6e88b74
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -390,7 +389,6 @@ public void run() {
}

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);

Expand All @@ -406,7 +404,8 @@ public void testCustomDataPaths() throws Exception {
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),
Expand All @@ -418,7 +417,8 @@ public void testCustomDataPaths() throws Exception {
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),
Expand Down

0 comments on commit 6e88b74

Please sign in to comment.