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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations