Search in sources :

Example 1 with LookupCoordinatorManager

use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testGetEmptyAllLookupSpecs.

@Test
public void testGetEmptyAllLookupSpecs() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andReturn(null).once();
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    final Response response = lookupCoordinatorResource.getAllLookupSpecs();
    Assert.assertEquals(Status.NOT_FOUND.getStatusCode(), response.getStatus());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 2 with LookupCoordinatorManager

use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testExceptionalNewLookup.

@Test
public void testExceptionalNewLookup() throws Exception {
    final String errMsg = "error message";
    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(SINGLE_LOOKUP), EasyMock.capture(auditInfoCapture))).andThrow(new RuntimeException(errMsg)).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(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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) AuditInfo(org.apache.druid.audit.AuditInfo) Test(org.junit.Test)

Example 3 with LookupCoordinatorManager

use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testExceptionalGetTier.

@Test
public void testExceptionalGetTier() {
    final String tier = "some tier";
    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.getSpecificTier(tier, false);
    Assert.assertEquals(500, response.getStatus());
    Assert.assertEquals(ImmutableMap.of("error", errMsg), response.getEntity());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 4 with LookupCoordinatorManager

use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testSimpleGetTier.

@Test
public void testSimpleGetTier() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andReturn(SINGLE_TIER_MAP).once();
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    final Response response = lookupCoordinatorResource.getSpecificTier(LOOKUP_TIER, false);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(SINGLE_TIER_MAP.get(LOOKUP_TIER).keySet(), response.getEntity());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 5 with LookupCoordinatorManager

use of org.apache.druid.server.lookup.cache.LookupCoordinatorManager in project druid by druid-io.

the class LookupCoordinatorResourceTest method testSimpleGetLookup.

@Test
public void testSimpleGetLookup() {
    final LookupExtractorFactoryMapContainer container = new LookupExtractorFactoryMapContainer("v0", new HashMap<>());
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getLookup(EasyMock.eq(LOOKUP_TIER), EasyMock.eq(LOOKUP_NAME))).andReturn(container).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(container, response.getEntity());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) LookupExtractorFactoryMapContainer(org.apache.druid.server.lookup.cache.LookupExtractorFactoryMapContainer) Test(org.junit.Test)

Aggregations

LookupCoordinatorManager (org.apache.druid.server.lookup.cache.LookupCoordinatorManager)36 Test (org.junit.Test)36 Response (javax.ws.rs.core.Response)33 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 AuditInfo (org.apache.druid.audit.AuditInfo)10 ImmutableMap (com.google.common.collect.ImmutableMap)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 LookupExtractorFactoryMapContainer (org.apache.druid.server.lookup.cache.LookupExtractorFactoryMapContainer)2 LookupsState (org.apache.druid.query.lookup.LookupsState)1