Search in sources :

Example 31 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testNullValsNewLookup.

@Test
public void testNullValsNewLookup() 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);
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    EasyMock.replay(lookupCoordinatorManager, request);
    Assert.assertEquals(400, lookupCoordinatorResource.createOrUpdateLookup(null, LOOKUP_NAME, author, comment, EMPTY_MAP_SOURCE.openStream(), request).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.createOrUpdateLookup(LOOKUP_TIER, null, author, comment, EMPTY_MAP_SOURCE.openStream(), request).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.createOrUpdateLookup(LOOKUP_TIER, "", author, comment, EMPTY_MAP_SOURCE.openStream(), request).getStatus());
    Assert.assertEquals(400, lookupCoordinatorResource.createOrUpdateLookup("", LOOKUP_NAME, author, comment, EMPTY_MAP_SOURCE.openStream(), request).getStatus());
    EasyMock.verify(lookupCoordinatorManager, request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) Test(org.junit.Test)

Example 32 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testGetAllNodesStatusDetailedFalse.

@Test
public void testGetAllNodesStatusDetailedFalse() {
    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, false);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(ImmutableMap.of(LOOKUP_TIER, ImmutableMap.of(LOOKUP_NODE, new LookupsState(ImmutableMap.of(LOOKUP_NAME, SINGLE_LOOKUP.getVersion()), null, null))), response.getEntity());
    EasyMock.verify(lookupCoordinatorManager);
}
Also used : Response(javax.ws.rs.core.Response) LookupCoordinatorManager(org.apache.druid.server.lookup.cache.LookupCoordinatorManager) LookupsState(org.apache.druid.query.lookup.LookupsState) Test(org.junit.Test)

Example 33 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testMissingGet.

@Test
public void testMissingGet() {
    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.getTiers(false);
    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 34 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testGetSpecificNodeStatus.

@Test
public void testGetSpecificNodeStatus() {
    final LookupCoordinatorManager lookupCoordinatorManager = EasyMock.createStrictMock(LookupCoordinatorManager.class);
    EasyMock.expect(lookupCoordinatorManager.getLastKnownLookupsStateOnNodes()).andReturn(NODES_LOOKUP_STATE);
    EasyMock.replay(lookupCoordinatorManager);
    final LookupCoordinatorResource lookupCoordinatorResource = new LookupCoordinatorResource(lookupCoordinatorManager, MAPPER, MAPPER);
    final Response response = lookupCoordinatorResource.getSpecificNodeStatus(LOOKUP_TIER, LOOKUP_NODE);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(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 35 with LookupCoordinatorManager

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

the class LookupCoordinatorResourceTest method testGetLookupStatusForTier.

@Test
public void testGetLookupStatusForTier() {
    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.getLookupStatusForTier(LOOKUP_TIER, false);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(ImmutableMap.of(LOOKUP_NAME, new LookupCoordinatorResource.LookupStatus(true, null)), 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)

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