Search in sources :

Example 21 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testGetAllNodesStatus.

@Test
public void testGetAllNodesStatus() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andReturn(SINGLE_TIER_MAP);
    EasyMock.expect(lookupCoordinatorManager.getLastKnownLookupsStateOnNodes()).andReturn(NODES_LOOKUP_STATE);
    EasyMock.expect(lookupCoordinatorManager.discoverNodesInTier(LOOKUP_TIER)).andReturn(ImmutableList.of(LOOKUP_NODE));
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    final Response response = lookupCoordinatorResource.getAllNodesStatus(false, null);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(ImmutableMap.of(LOOKUP_TIER, ImmutableMap.of(LOOKUP_NODE, LOOKUP_STATE)), 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 22 with LookupCoordinatorManager

use of org.apache.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);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 23 with LookupCoordinatorManager

use of org.apache.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);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 24 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testGetAllLookupSpecs.

@Test
public void testGetAllLookupSpecs() {
    final Map<String, Map<String, LookupExtractorFactoryMapContainer>> lookups = ImmutableMap.of("tier1", ImmutableMap.of("lookup1", new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("k1", "v2")), "lookup2", new LookupExtractorFactoryMapContainer("v1", ImmutableMap.of("k", "v"))), "tier2", ImmutableMap.of("lookup1", new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("k1", "v2"))));
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getKnownLookups()).andReturn(lookups).once();
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    final Response response = lookupCoordinatorResource.getAllLookupSpecs();
    Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus());
    Assert.assertEquals(lookups, response.getEntity());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) LookupExtractorFactoryMapContainer(org.apache.druid.server.lookup.cache.LookupExtractorFactoryMapContainer) Test(org.junit.Test)

Example 25 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testInvalidGetLookup.

@Test
public void testInvalidGetLookup() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup("foo", null).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup("foo", "").getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup("", "foo").getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.getSpecificLookup(null, "foo").getStatus());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) 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