use of io.netty.handler.codec.http.HttpResponseStatus.INTERNAL_SERVER_ERROR in project crate by crate.
the class GatewayIndexStateIT method testRecoverMissingAnalyzer.
/**
* This test really tests worst case scenario where we have a missing analyzer setting.
* In that case we now have the ability to check the index on local recovery from disk
* if it is sane and if we can successfully create an IndexService.
* This also includes plugins etc.
*/
@Test
public void testRecoverMissingAnalyzer() throws Exception {
logger.info("--> starting one node");
internalCluster().startNode();
var tableName = getFqn("test");
prepareCreate(tableName).setSettings(Settings.builder().put("index.analysis.analyzer.test.tokenizer", "standard").put("index.number_of_shards", "1")).addMapping("default", "{\n" + " \"default\": {\n" + " \"properties\": {\n" + " \"field1\": {\n" + " \"type\": \"text\",\n" + " \"analyzer\": \"test\"\n" + " }\n" + " }\n" + " }\n" + " }}", XContentType.JSON).get();
logger.info("--> indexing a simple document");
execute("insert into test (field1) values ('value one')");
execute("refresh table test");
logger.info("--> waiting for green status");
if (usually()) {
ensureYellow();
} else {
internalCluster().startNode();
client().admin().cluster().health(Requests.clusterHealthRequest().waitForGreenStatus().waitForEvents(Priority.LANGUID).waitForNoRelocatingShards(true).waitForNodes("2")).actionGet(REQUEST_TIMEOUT);
}
ClusterState state = client().admin().cluster().prepareState().get().getState();
final IndexMetadata metadata = state.getMetadata().index(tableName);
final IndexMetadata.Builder brokenMeta = IndexMetadata.builder(metadata).settings(metadata.getSettings().filter((s) -> "index.analysis.analyzer.test.tokenizer".equals(s) == false));
restartNodesOnBrokenClusterState(ClusterState.builder(state).metadata(Metadata.builder(state.getMetadata()).put(brokenMeta)));
// check that the cluster does not keep reallocating shards
assertBusy(() -> {
final RoutingTable routingTable = client().admin().cluster().prepareState().execute().actionGet(REQUEST_TIMEOUT).getState().routingTable();
final IndexRoutingTable indexRoutingTable = routingTable.index(tableName);
assertNotNull(indexRoutingTable);
for (IndexShardRoutingTable shardRoutingTable : indexRoutingTable) {
assertTrue(shardRoutingTable.primaryShard().unassigned());
assertEquals(UnassignedInfo.AllocationStatus.DECIDERS_NO, shardRoutingTable.primaryShard().unassignedInfo().getLastAllocationStatus());
assertThat(shardRoutingTable.primaryShard().unassignedInfo().getNumFailedAllocations(), greaterThan(0));
}
}, 60, TimeUnit.SECONDS);
execute("alter table test close");
// try to open it with the broken setting - fail again!
assertThrowsMatches(() -> execute("alter table test open"), isSQLError(is("Failed to verify index " + metadata.getIndex().getName()), INTERNAL_ERROR, INTERNAL_SERVER_ERROR, 5000));
}
Aggregations