|
26 | 26 | import org.elasticsearch.test.ESIntegTestCase;
|
27 | 27 | import org.elasticsearch.test.InternalTestCluster;
|
28 | 28 |
|
| 29 | +import java.io.IOException; |
29 | 30 | import java.nio.file.Path;
|
| 31 | +import java.util.ArrayList; |
| 32 | +import java.util.List; |
30 | 33 |
|
31 | 34 | import static org.hamcrest.Matchers.allOf;
|
32 | 35 | import static org.hamcrest.Matchers.containsString;
|
|
35 | 38 |
|
36 | 39 | @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0)
|
37 | 40 | public class NodeEnvironmentIT extends ESIntegTestCase {
|
38 |
| - public void testStartFailureOnDataForNonDataNode() throws Exception { |
| 41 | + public void testStartFailureOnDataForNonDataNode() { |
39 | 42 | final String indexName = "test-fail-on-data";
|
40 | 43 |
|
41 | 44 | logger.info("--> starting one node");
|
@@ -123,4 +126,33 @@ public void testFailsToStartIfUpgradedTooFar() {
|
123 | 126 | assertThat(illegalStateException.getMessage(),
|
124 | 127 | allOf(startsWith("cannot upgrade a node from version ["), endsWith("] directly to version [" + Version.CURRENT + "]")));
|
125 | 128 | }
|
| 129 | + |
| 130 | + public void testFailsToStartOnDataPathsFromMultipleNodes() throws IOException { |
| 131 | + final List<String> nodes = internalCluster().startNodes(2); |
| 132 | + ensureStableCluster(2); |
| 133 | + |
| 134 | + final List<String> node0DataPaths = Environment.PATH_DATA_SETTING.get(internalCluster().dataPathSettings(nodes.get(0))); |
| 135 | + final List<String> node1DataPaths = Environment.PATH_DATA_SETTING.get(internalCluster().dataPathSettings(nodes.get(1))); |
| 136 | + |
| 137 | + final List<String> allDataPaths = new ArrayList<>(node0DataPaths); |
| 138 | + allDataPaths.addAll(node1DataPaths); |
| 139 | + |
| 140 | + internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodes.get(1))); |
| 141 | + internalCluster().stopRandomNode(InternalTestCluster.nameFilter(nodes.get(0))); |
| 142 | + |
| 143 | + final IllegalStateException illegalStateException = expectThrows(IllegalStateException.class, |
| 144 | + () -> internalCluster().startNode(Settings.builder().putList(Environment.PATH_DATA_SETTING.getKey(), allDataPaths))); |
| 145 | + |
| 146 | + assertThat(illegalStateException.getMessage(), containsString("belong to multiple nodes with IDs")); |
| 147 | + |
| 148 | + final List<String> node0DataPathsPlusOne = new ArrayList<>(node0DataPaths); |
| 149 | + node0DataPathsPlusOne.add(createTempDir().toString()); |
| 150 | + internalCluster().startNode(Settings.builder().putList(Environment.PATH_DATA_SETTING.getKey(), node0DataPathsPlusOne)); |
| 151 | + |
| 152 | + final List<String> node1DataPathsPlusOne = new ArrayList<>(node1DataPaths); |
| 153 | + node1DataPathsPlusOne.add(createTempDir().toString()); |
| 154 | + internalCluster().startNode(Settings.builder().putList(Environment.PATH_DATA_SETTING.getKey(), node1DataPathsPlusOne)); |
| 155 | + |
| 156 | + ensureStableCluster(2); |
| 157 | + } |
126 | 158 | }
|
0 commit comments