Skip to content

Commit

Permalink
[TEST] Fix ShardPathTests for MDP (#79393)
Browse files Browse the repository at this point in the history
An assert in newly added test didn't anticipate the possibility of
multiple data paths. This change allows any of the shard paths
to be a data path.

Closes #79249
  • Loading branch information
grcevski authored Oct 18, 2021
1 parent dc071ae commit 64a946a
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ public void testLoadEmptyShards() throws IOException {

public void testShardPathSelection() throws IOException {
try (NodeEnvironment env = newNodeEnvironment(Settings.builder().build())) {
NodeEnvironment.NodePath path = env.nodePaths()[0];
assertEquals(path, ShardPath.getPathWithMostFreeSpace(env));
NodeEnvironment.NodePath[] paths = env.nodePaths();
assertThat(List.of(paths), hasItem(ShardPath.getPathWithMostFreeSpace(env)));
ShardId shardId = new ShardId("foo", "0xDEADBEEF", 0);

Settings indexSettings = Settings.builder()
Expand All @@ -198,7 +198,13 @@ public void testShardPathSelection() throws IOException {

ShardPath shardPath = ShardPath.selectNewPathForShard(env, shardId, idxSettings, 1L, new HashMap<>());
assertNotNull(shardPath.getDataPath());
assertEquals(path.indicesPath.resolve("0xDEADBEEF").resolve("0"), shardPath.getDataPath());

List<Path> indexPaths = new ArrayList<>();
for (NodeEnvironment.NodePath nodePath : paths) {
indexPaths.add(nodePath.indicesPath.resolve("0xDEADBEEF").resolve("0"));
}

assertThat(indexPaths, hasItem(shardPath.getDataPath()));
assertEquals("0xDEADBEEF", shardPath.getShardId().getIndex().getUUID());
assertEquals("foo", shardPath.getShardId().getIndexName());
assertFalse(shardPath.isCustomDataPath());
Expand Down

0 comments on commit 64a946a

Please sign in to comment.