Skip to content

Commit

Permalink
Ensure dir is created for file settings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Oct 27, 2023
1 parent 5911496 commit 7496729
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
import org.elasticsearch.core.Tuple;
import org.elasticsearch.reservedstate.action.ReservedClusterSettingsAction;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -99,6 +102,18 @@ public class FileSettingsServiceIT extends ESIntegTestCase {
}
}""";

private Map<Integer, Path> configDirs = new HashMap<>();

@Before
public void clearConfigDirs() {
configDirs.clear();
}

@Override
protected Path nodeConfigPath(int nodeOrdinal) {
return configDirs.computeIfAbsent(nodeOrdinal, k -> createTempDir());
}

private void assertMasterNode(Client client, String node) {
assertThat(
client.admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public AbstractFileWatchingService(ClusterService clusterService, Path watchedFi
this.watchedFileDir = watchedFile.getParent();
this.eventListeners = new CopyOnWriteArrayList<>();
this.active = Files.exists(watchedFileDir.getParent());
if (active == false) {
logger.warn("File watcher cannot start, grandparent directory [{}] does not exist", watchedFileDir.getParent());
}
}

/**
Expand Down

0 comments on commit 7496729

Please sign in to comment.