[TEST] made sure nodeSettings method gets called for every node type, not only data nodes in case numDataNodes is specified.
This fixes a test ZenUnicastDiscoveryTests when running in network mode
This commit is contained in:
parent
a414e4f2f3
commit
51ba3ca220
|
@ -1161,33 +1161,25 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase
|
|||
|
||||
private TestCluster buildTestCluster(Scope scope) {
|
||||
long currentClusterSeed = randomLong();
|
||||
int numNodes = getNumDataNodes();
|
||||
NodeSettingsSource nodeSettingsSource;
|
||||
if (numNodes > 0) {
|
||||
NodeSettingsSource.Immutable.Builder nodesSettings = NodeSettingsSource.Immutable.builder();
|
||||
for (int i = 0; i < numNodes; i++) {
|
||||
nodesSettings.set(i, nodeSettings(i));
|
||||
}
|
||||
nodeSettingsSource = nodesSettings.build();
|
||||
} else {
|
||||
nodeSettingsSource = new NodeSettingsSource() {
|
||||
@Override
|
||||
public Settings settings(int nodeOrdinal) {
|
||||
return nodeSettings(nodeOrdinal);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int minNumNodes, maxNumNodes;
|
||||
if (numNodes >= 0) {
|
||||
minNumNodes = maxNumNodes = numNodes;
|
||||
NodeSettingsSource nodeSettingsSource = new NodeSettingsSource() {
|
||||
@Override
|
||||
public Settings settings(int nodeOrdinal) {
|
||||
return nodeSettings(nodeOrdinal);
|
||||
}
|
||||
};
|
||||
|
||||
int numDataNodes = getNumDataNodes();
|
||||
int minNumDataNodes, maxNumDataNodes;
|
||||
if (numDataNodes >= 0) {
|
||||
minNumDataNodes = maxNumDataNodes = numDataNodes;
|
||||
} else {
|
||||
minNumNodes = getMinNumDataNodes();
|
||||
maxNumNodes = getMaxNumDataNodes();
|
||||
minNumDataNodes = getMinNumDataNodes();
|
||||
maxNumDataNodes = getMaxNumDataNodes();
|
||||
}
|
||||
|
||||
int numClientNodes = getNumClientNodes();
|
||||
return new TestCluster(currentClusterSeed, minNumNodes, maxNumNodes, clusterName(scope.name(), ElasticsearchTestCase.CHILD_VM_ID, currentClusterSeed), nodeSettingsSource, numClientNodes);
|
||||
return new TestCluster(currentClusterSeed, minNumDataNodes, maxNumDataNodes, clusterName(scope.name(), ElasticsearchTestCase.CHILD_VM_ID, currentClusterSeed), nodeSettingsSource, numClientNodes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,11 +18,8 @@
|
|||
*/
|
||||
package org.elasticsearch.test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
abstract class NodeSettingsSource {
|
||||
|
||||
public static final NodeSettingsSource EMPTY = new NodeSettingsSource() {
|
||||
|
@ -33,44 +30,8 @@ abstract class NodeSettingsSource {
|
|||
};
|
||||
|
||||
/**
|
||||
* @return the settings for the node represented by the given ordinal, or {@code null} if there are not settings defined (in which
|
||||
* case a random settings will be generated for the node)
|
||||
* @return the settings for the node represented by the given ordinal, or {@code null} if there are no settings defined
|
||||
*/
|
||||
public abstract Settings settings(int nodeOrdinal);
|
||||
|
||||
public static class Immutable extends NodeSettingsSource {
|
||||
|
||||
private final Map<Integer, Settings> settingsPerNode;
|
||||
|
||||
private Immutable(Map<Integer, Settings> settingsPerNode) {
|
||||
this.settingsPerNode = settingsPerNode;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Settings settings(int nodeOrdinal) {
|
||||
return settingsPerNode.get(nodeOrdinal);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private final ImmutableMap.Builder<Integer, Settings> settingsPerNode = ImmutableMap.builder();
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder set(int ordinal, Settings settings) {
|
||||
settingsPerNode.put(ordinal, settings);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Immutable build() {
|
||||
return new Immutable(settingsPerNode.build());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue