[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) {
|
private TestCluster buildTestCluster(Scope scope) {
|
||||||
long currentClusterSeed = randomLong();
|
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;
|
NodeSettingsSource nodeSettingsSource = new NodeSettingsSource() {
|
||||||
if (numNodes >= 0) {
|
@Override
|
||||||
minNumNodes = maxNumNodes = numNodes;
|
public Settings settings(int nodeOrdinal) {
|
||||||
|
return nodeSettings(nodeOrdinal);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int numDataNodes = getNumDataNodes();
|
||||||
|
int minNumDataNodes, maxNumDataNodes;
|
||||||
|
if (numDataNodes >= 0) {
|
||||||
|
minNumDataNodes = maxNumDataNodes = numDataNodes;
|
||||||
} else {
|
} else {
|
||||||
minNumNodes = getMinNumDataNodes();
|
minNumDataNodes = getMinNumDataNodes();
|
||||||
maxNumNodes = getMaxNumDataNodes();
|
maxNumDataNodes = getMaxNumDataNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
int numClientNodes = getNumClientNodes();
|
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;
|
package org.elasticsearch.test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
abstract class NodeSettingsSource {
|
abstract class NodeSettingsSource {
|
||||||
|
|
||||||
public static final NodeSettingsSource EMPTY = new 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
|
* @return the settings for the node represented by the given ordinal, or {@code null} if there are no settings defined
|
||||||
* case a random settings will be generated for the node)
|
|
||||||
*/
|
*/
|
||||||
public abstract Settings settings(int nodeOrdinal);
|
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