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() Node node = nodeBuilder()
.settings(finalSettings) .settings(finalSettings)
.build(); .build();
logger.info("Build Node [{}] with settings [{}]", id, finalSettings.toDelimitedString(','));
nodes.put(id, node); nodes.put(id, node);
clients.put(id, node.client()); clients.put(id, node.client());
return node; return node;

View File

@ -53,6 +53,9 @@ import static org.hamcrest.Matchers.*;
*/ */
public class IndexGatewayTests extends AbstractNodesTests { public class IndexGatewayTests extends AbstractNodesTests {
private Settings defaultSettings;
private String storeType;
@After @After
public void closeNodes() throws Exception { public void closeNodes() throws Exception {
node("server1").stop(); node("server1").stop();
@ -63,13 +66,37 @@ public class IndexGatewayTests extends AbstractNodesTests {
@Before @Before
public void buildNode1() throws Exception { 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"); buildNode("server1");
// since we store (by default) the index snapshot under the gateway, resetting it will reset the index data as well // 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(); ((InternalNode) node("server1")).injector().getInstance(Gateway.class).reset();
closeAllNodes(); closeAllNodes();
} }
@Override
protected final Settings getClassDefaultSettings() {
return defaultSettings;
}
protected boolean isPersistentStorage() {
assert storeType != null;
return "fs".equals(storeType);
}
@Test @Test
@Slow @Slow
@ -339,33 +366,6 @@ public class IndexGatewayTests extends AbstractNodesTests {
testLoad(getRandom().nextBoolean()); 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 @Test
@Slow @Slow
public void testIndexActions() throws Exception { public void testIndexActions() throws Exception {