use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testSimpleGetLookup.
@Test
public void testSimpleGetLookup() {
final Map<String, Object> map = new HashMap<>();
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME))).andReturn(map).once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
final Response response = lookupCoordinatorResource.getSpecificLookup(LOOKUP_TIER, LOOKUP_NAME);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(map, response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testExceptionalGetLookup.
@Test
public void testExceptionalGetLookup() {
final String errMsg = "some message";
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME))).andThrow(new RuntimeException(errMsg)).once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
final Response response = lookupCoordinatorResource.getSpecificLookup(LOOKUP_TIER, LOOKUP_NAME);
Assert.assertEquals(500, response.getStatus());
Assert.assertEquals(ImmutableMap.of("error", errMsg), response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testMissingGetLookup.
@Test
public void testMissingGetLookup() {
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME))).andReturn(null).once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
final Response response = lookupCoordinatorResource.getSpecificLookup(LOOKUP_TIER, LOOKUP_NAME);
Assert.assertEquals(404, response.getStatus());
EasyMock.verify(lookupCoordinatorManager);
}
use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testDiscoveryGet.
@Test
public void testDiscoveryGet() {
final List<String> tiers = ImmutableList.of();
final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
EasyMock.expect(lookupCoordinatorManager.discoverTiers()).andReturn(tiers).once();
EasyMock.replay(lookupCoordinatorManager);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
final Response response = lookupCoordinatorResource.getTiers(true);
Assert.assertEquals(200, response.getStatus());
Assert.assertEquals(tiers, response.getEntity());
EasyMock.verify(lookupCoordinatorManager);
}
use of io.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.
the class LookupCoordinatorResourceTest method testSimpleNewLookup.
@Test
public void testSimpleNewLookup() 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.updateLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME), EasyMock.eq(ImmutableMap.<String, Object>of()), EasyMock.capture(auditInfoCapture))).andReturn(true).once();
EasyMock.replay(lookupCoordinatorManager, request);
final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, mapper, mapper);
final Response response = lookupCoordinatorResource.createOrUpdateLookup(LOOKUP_TIER, LOOKUP_NAME, author, comment, EMPTY_MAP_SOURCE.openStream(), request);
Assert.assertEquals(202, response.getStatus());
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);
}
Aggregations