Search in sources :

Example 1 with BlockMasterServiceOnMaster

use of org.elasticsearch.test.disruption.BlockMasterServiceOnMaster in project crate by crate.

the class MasterDisruptionIT method testMappingNewFieldsTimeoutDoesntAffectCheckpoints.

@Test
public void testMappingNewFieldsTimeoutDoesntAffectCheckpoints() throws Exception {
    InternalTestCluster internalCluster = internalCluster();
    internalCluster.startNodes(3, Settings.builder().put(MappingUpdatedAction.INDICES_MAPPING_DYNAMIC_TIMEOUT_SETTING.getKey(), "1ms").build());
    ensureStableCluster(3);
    logger.info("creating table t with 1 shards and 1 replica");
    execute("create table t (id int primary key, x object(dynamic)) clustered into 1 shards with " + "(number_of_replicas = 1, \"routing.allocation.exclude._name\" = '" + internalCluster().getMasterName() + "', \"write.wait_for_active_shards\" = 1)");
    ensureGreen();
    execute("insert into t values (?, ?)", new Object[] { 1, Map.of("first field", "first value") });
    ServiceDisruptionScheme disruption = new BlockMasterServiceOnMaster(random());
    setDisruptionScheme(disruption);
    disruption.startDisrupting();
    try {
        execute("insert into t values (?, ?), (?, ?), (?, ?)", new Object[] { 2, Map.of("2nd field", "2nd value"), 3, Map.of("3rd field", "3rd value"), 4, Map.of("4th field", "4th value") });
    } catch (Exception e) {
    // failure is acceptable
    }
    disruption.stopDisrupting();
    String indexName = toIndexName(sqlExecutor.getCurrentSchema(), "t", null);
    assertBusy(() -> {
        IndicesStatsResponse stats = client().admin().indices().prepareStats(indexName).clear().get();
        for (ShardStats shardStats : stats.getShards()) {
            assertThat(shardStats.getShardRouting().toString(), shardStats.getSeqNoStats().getGlobalCheckpoint(), equalTo(shardStats.getSeqNoStats().getLocalCheckpoint()));
        }
    }, 1, TimeUnit.MINUTES);
}
Also used : ShardStats(org.elasticsearch.action.admin.indices.stats.ShardStats) IndicesStatsResponse(org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse) ServiceDisruptionScheme(org.elasticsearch.test.disruption.ServiceDisruptionScheme) InternalTestCluster(org.elasticsearch.test.InternalTestCluster) BlockMasterServiceOnMaster(org.elasticsearch.test.disruption.BlockMasterServiceOnMaster) Test(org.junit.Test)

Aggregations

IndicesStatsResponse (org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse)1 ShardStats (org.elasticsearch.action.admin.indices.stats.ShardStats)1 InternalTestCluster (org.elasticsearch.test.InternalTestCluster)1 BlockMasterServiceOnMaster (org.elasticsearch.test.disruption.BlockMasterServiceOnMaster)1 ServiceDisruptionScheme (org.elasticsearch.test.disruption.ServiceDisruptionScheme)1 Test (org.junit.Test)1