use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testFailedNew.
@Test
public void testFailedNew() throws Exception {
final String author = "some author";
final String comment = "some comment";
final String ip = "127.0.0.1";
final HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
EasyMock.expect(request.getContentType()).andReturn(MediaType.APPLICATION_JSON).once();
EasyMock.expect(request.getRemoteAddr()).andReturn(ip).once();
final Capture<AuditInfo> auditInfoCapture = Capture.newInstance();
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.updateLookups(EasyMock.eq(SINGLE_TIER_MAP), EasyMock.capture(auditInfoCapture))).andReturn(false).once();
EasyMock.replay(lookupCoordinatorManager, request);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
final Response response = lookupCoordinatorResource.updateAllLookups(SINGLE_TIER_MAP_SOURCE.openStream(), author, comment, request);
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(ImmutableMap.of("error", "Unknown error updating configuration"), response.getEntity());
Assert.assertTrue(auditInfoCapture.hasCaptured());
final AuditInfo auditInfo = auditInfoCapture.getValue();
Assert.assertEquals(author, auditInfo.getAuthor());
Assert.assertEquals(comment, auditInfo.getComment());
Assert.assertEquals(ip, auditInfo.getIp());
EasyMock.verify(lookupCoordinatorManager, request);
}
use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testGetSpecificLookupStatus.
@Test
public void testGetSpecificLookupStatus() {
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andReturn(SINGLE_TIER_MAP);
EasyMock.expect(lookupCoordinatorManager.discoverNodesInTier(LOOKUP_TIER)).andReturn(ImmutableList.of(LOOKUP_NODE));
EasyMock.expect(lookupCoordinatorManager.getLastKnownLookupsStateOnNodes()).andReturn(NODES_LOOKUP_STATE);
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
final Response response = lookupCoordinatorResource.getSpecificLookupStatus(LOOKUP_TIER, LOOKUP_NAME, false);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(new LookupCoordinatorResource.LookupStatus(true, null), response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testExceptionalNew.
@Test
public void testExceptionalNew() throws Exception {
final String author = "some author";
final String comment = "some comment";
final String ip = "127.0.0.1";
final String errMsg = "some error";
final HttpServletRequest request = EasyMock.createStrictMock(HttpServletRequest.class);
EasyMock.expect(request.getContentType()).andReturn(MediaType.APPLICATION_JSON).once();
EasyMock.expect(request.getRemoteAddr()).andReturn(ip).once();
final Capture<AuditInfo> auditInfoCapture = Capture.newInstance();
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.updateLookups(EasyMock.eq(SINGLE_TIER_MAP), EasyMock.capture(auditInfoCapture))).andThrow(new RuntimeException(errMsg)).once();
EasyMock.replay(lookupCoordinatorManager, request);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
final Response response = lookupCoordinatorResource.updateAllLookups(SINGLE_TIER_MAP_SOURCE.openStream(), author, comment, request);
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(ImmutableMap.of("error", errMsg), response.getEntity());
Assert.assertTrue(auditInfoCapture.hasCaptured());
final AuditInfo auditInfo = auditInfoCapture.getValue();
Assert.assertEquals(author, auditInfo.getAuthor());
Assert.assertEquals(comment, auditInfo.getComment());
Assert.assertEquals(ip, auditInfo.getIp());
EasyMock.verify(lookupCoordinatorManager, request);
}
use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testExceptionalGet.
@Test
public void testExceptionalGet() {
final String errMsg = "some error";
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andThrow(new RuntimeException(errMsg)).once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
final Response response = lookupCoordinatorResource.getTiers(false);
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(ImmutableMap.of("error", errMsg), response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testInvalidDelete.
@Test
public void testInvalidDelete() {
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup("foo", null, null, null, null).getStatus());
Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup(null, null, null, null, null).getStatus());
Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup(null, "foo", null, null, null).getStatus());
Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup("foo", "", null, null, null).getStatus());
Assert.assertEquals(400, lookupCoordinatorResource.deleteLookup("", "foo", null, null, null).getStatus());
EasyMock.verify(lookupCoordinatorManager);
}
Aggregations