Generate consistent random settings across nodes

IndexGatewayTests rely on that all nodes have the same type of
storage to pass consistently. Random configs should be the same for all
nodes in the cluster.
This commit is contained in:
Simon Willnauer 2013-07-25 09:31:46 +02:00
parent 4f0080b206
commit 02ca879f5d
2 changed files with 29 additions and 28 deletions

View File

@ -100,6 +100,7 @@ public abstract class AbstractNodesTests extends ElasticsearchTestCase {
Node node = nodeBuilder()
.settings(finalSettings)
.build();
logger.info("Build Node [{}] with settings [{}]", id, finalSettings.toDelimitedString(','));
nodes.put(id, node);
clients.put(id, node.client());
return node;

View File

@ -53,6 +53,9 @@ import static org.hamcrest.Matchers.*;
*/
public class IndexGatewayTests extends AbstractNodesTests {
private Settings defaultSettings;
private String storeType;
@After
public void closeNodes() throws Exception {
node("server1").stop();
@ -63,14 +66,38 @@ public class IndexGatewayTests extends AbstractNodesTests {
@Before
public void buildNode1() throws Exception {
super.setUp();
Builder builder = ImmutableSettings.builder();
builder.put("cluster.routing.schedule", "100ms");
builder.put("gateway.type", "fs");
if (between(0, 5) == 0) {
builder.put("gateway.fs.buffer_size", between(1, 100) + "kb");
}
if (between(0, 5) == 0) {
builder.put("gateway.fs.chunk_size", between(1, 100) + "kb");
}
builder.put("index.number_of_replicas", "1");
builder.put("index.number_of_shards", rarely() ? Integer.toString(between(2, 6)) : "1");
storeType = rarely() ? "ram" : "fs";
builder.put("index.store", storeType);
defaultSettings = builder.build();
buildNode("server1");
// since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well
((InternalNode) node("server1")).injector().getInstance(Gateway.class).reset();
closeAllNodes();
}
@Override
protected final Settings getClassDefaultSettings() {
return defaultSettings;
}
protected boolean isPersistentStorage() {
assert storeType != null;
return "fs".equals(storeType);
}
@Test
@Slow
public void testSnapshotOperations() throws Exception {
@ -339,33 +366,6 @@ public class IndexGatewayTests extends AbstractNodesTests {
testLoad(getRandom().nextBoolean());
}
private String storeType;
@Override
protected final Settings getClassDefaultSettings() {
Builder builder = ImmutableSettings.builder();
builder.put("cluster.routing.schedule", "100ms");
builder.put("gateway.type", "fs");
if (between(0, 5) == 0) {
builder.put("gateway.fs.buffer_size", between(1, 100) + "kb");
}
if (between(0, 5) == 0) {
builder.put("gateway.fs.chunk_size", between(1, 100) + "kb");
}
builder.put("index.number_of_replicas", "1");
builder.put("index.number_of_shards", rarely() ? Integer.toString(between(2, 6)) : "1");
storeType = rarely() ? "ram" : "fs";
builder.put("index.store", storeType);
return builder.build();
}
protected boolean isPersistentStorage() {
return "fs".equals(storeType);
}
@Test
@Slow
public void testIndexActions() throws Exception {