@Test public void testClusterHealth() throws Exception { startNode("server1"); createTestIndex(); // Shouldn't log cluster health call HttpClientResponse response = httpClient("server1").request("_cluster/health"); assertThat((String) response.get("status"), equalTo("green")); Map<String, Object> data = createSearchQuery("user:kimchy"); httpClient("server1").request("POST", "_search", data); // Should start with logging for the POST /_search request Map<String, Object> logJson = XContentFactory.xContent(XContentType.JSON) .createParser(mockESLoggerFactory.getMessage().substring(5)) .mapAndClose(); assertThat((Integer) logJson.get("size"), greaterThan(100)); assertThat( (String) logJson.get("data"), equalTo("{\"query\":{\"query_string\":{\"query\":\"user:kimchy\"}}}")); }
@AfterMethod public void closeNodes() { closeAllNodes(); ESLoggerFactory.setDefaultFactory(mockESLoggerFactory.getRealFactory()); }