@Test public synchronized void readIndicesStatsInfo() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); String info = tested.readIndicesStatsInfo(null); System.out.println(info); assertStartsWith( "{\"_shards\":{\"total\":0,\"successful\":0,\"failed\":0},\"_all\":{\"primaries\":{},\"total\":{}},\"indices\":{}}", info); Map<String, String> params = new HashMap<String, String>(); params.put("index", "test"); info = tested.readIndicesStatsInfo(params); Assert.fail("IOException must be thrown due missing index"); } catch (IOException e) { Assert.assertEquals( "response status is NOT_FOUND with content {\"error\":\"IndexMissingException[[test] missing]\",\"status\":404}", e.getMessage()); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readClusterNodesInfoInfo() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); String info = tested.readClusterNodesInfoInfo(null); System.out.println(info); assertStartsWith("{\"cluster_name\":\"elasticsearch\",\"nodes\":{", info); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readPendingClusterTasksInfo() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); String info = tested.readPendingClusterTasksInfo(null); System.out.println(info); Assert.assertEquals("{\"tasks\":[]}", info); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readIndicesRecoveryInfo_allIndices() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); indexCreate("test_index"); String info = tested.readIndicesRecoveryInfo(null); System.out.println(info); assertStartsWith("{\"test_index\":{\"shards\":[{\"id\":0,\"type\":\"GATEWAY\"", info); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readIndicesSegmentsInfo_missingAllIndices() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); tested.readIndicesSegmentsInfo(null); Assert.fail("IOException must be thrown due missing index"); } catch (IOException e) { Assert.assertEquals( "response status is NOT_FOUND with content {\"error\":\"IndexMissingException[[_all] missing]\",\"status\":404}", e.getMessage()); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readIndicesSegmentsInfo_missingOneIndex() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); Map<String, String> params = new HashMap<String, String>(); params.put("index", "test"); tested.readIndicesSegmentsInfo(params); Assert.fail("IOException must be thrown due missing index"); } catch (IOException e) { Assert.assertEquals( "response status is NOT_FOUND with content {\"error\":\"IndexMissingException[[test] missing]\",\"status\":404}", e.getMessage()); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readIndicesSegmentsInfo_allIndices() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); indexCreate("test_index"); String info = tested.readIndicesSegmentsInfo(null); System.out.println(info); assertStartsWith( "{\"_shards\":{\"total\":10,\"successful\":5,\"failed\":0},\"indices\":{\"test_index\":{\"", info); } finally { finalizeESClientForUnitTest(); } }
@Test public synchronized void readClusterStatsInfo() throws Exception { try { Client client = prepareESClientForUnitTest(); SourceClientESClient tested = new SourceClientESClient(client); String info = tested.readClusterStatsInfo(null); System.out.println(info); assertContains( info, "\"cluster_name\":\"elasticsearch\",\"status\":\"green\",\"indices\":{\"count\":0,\"shards\":{},\"docs\":{\"count\":0,\"deleted\":0}"); assertContains(info, "\"nodes\":{\"count\":{\"total\":1"); Map<String, String> params = new HashMap<String, String>(); params.put("nodeId", "this_node_does_not_exists"); info = tested.readClusterStatsInfo(params); System.out.println(info); assertContains(info, "\"nodes\":{\"count\":{\"total\":0"); } finally { finalizeESClientForUnitTest(); } }