Search in sources :

Example 16 with AuditInfo

use of org.apache.druid.audit.AuditInfo in project druid by druid-io.

the class LookupCoordinatorManagerTest method testDeleteLookup.

@Test
public void testDeleteLookup() {
    final LookupExtractorFactoryMapContainer ignore = new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("lookup", "ignore"));
    final LookupExtractorFactoryMapContainer lookup = new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("lookup", "foo"));
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, druidNodeDiscoveryProvider, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups() {
            return ImmutableMap.of(LOOKUP_TIER, ImmutableMap.of("foo", lookup, "ignore", ignore));
        }
    };
    manager.start();
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    EasyMock.reset(configManager);
    EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(ImmutableMap.of(LOOKUP_TIER, ImmutableMap.of("ignore", ignore))), EasyMock.eq(auditInfo))).andReturn(SetResult.ok()).once();
    EasyMock.replay(configManager);
    Assert.assertTrue(manager.deleteLookup(LOOKUP_TIER, "foo", auditInfo));
    EasyMock.verify(configManager);
}
Also used : AuditInfo(org.apache.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 17 with AuditInfo

use of org.apache.druid.audit.AuditInfo in project druid by druid-io.

the class LookupCoordinatorManagerTest method testDeleteLastLookup.

@Test
public void testDeleteLastLookup() {
    final LookupExtractorFactoryMapContainer lookup = new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("lookup", "foo"));
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, druidNodeDiscoveryProvider, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups() {
            return ImmutableMap.of(LOOKUP_TIER, ImmutableMap.of("foo", lookup));
        }
    };
    manager.start();
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    EasyMock.reset(configManager);
    EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(ImmutableMap.<String, Map<String, LookupExtractorFactoryMapContainer>>of()), EasyMock.eq(auditInfo))).andReturn(SetResult.ok()).once();
    EasyMock.replay(configManager);
    Assert.assertTrue(manager.deleteLookup(LOOKUP_TIER, "foo", auditInfo));
    EasyMock.verify(configManager);
}
Also used : AuditInfo(org.apache.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 18 with AuditInfo

use of org.apache.druid.audit.AuditInfo in project druid by druid-io.

the class LookupCoordinatorManagerTest method testDeleteLookupIgnoresNotReady.

@Test
public void testDeleteLookupIgnoresNotReady() {
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, druidNodeDiscoveryProvider, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups() {
            return null;
        }
    };
    manager.start();
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    Assert.assertFalse(manager.deleteLookup(LOOKUP_TIER, "foo", auditInfo));
}
Also used : AuditInfo(org.apache.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 19 with AuditInfo

use of org.apache.druid.audit.AuditInfo in project druid by druid-io.

the class LookupCoordinatorManagerTest method testUpdateLookupsOnlyUpdatesToTier.

@Test
public void testUpdateLookupsOnlyUpdatesToTier() {
    final LookupExtractorFactoryMapContainer ignore = new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("prop", "old"));
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, druidNodeDiscoveryProvider, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups() {
            return ImmutableMap.of(LOOKUP_TIER + "1", ImmutableMap.of("foo", new LookupExtractorFactoryMapContainer("v0", ImmutableMap.of("prop", "new"))), LOOKUP_TIER + "2", ImmutableMap.of("ignore", ignore));
        }
    };
    manager.start();
    final LookupExtractorFactoryMapContainer newSpec = new LookupExtractorFactoryMapContainer("v1", ImmutableMap.of("prop", "new"));
    EasyMock.reset(configManager);
    EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(ImmutableMap.<String, Map<String, LookupExtractorFactoryMapContainer>>of(LOOKUP_TIER + "1", ImmutableMap.of("foo", newSpec), LOOKUP_TIER + "2", ImmutableMap.of("ignore", ignore))), EasyMock.eq(auditInfo))).andReturn(SetResult.ok()).once();
    EasyMock.replay(configManager);
    Assert.assertTrue(manager.updateLookups(ImmutableMap.of(LOOKUP_TIER + "1", ImmutableMap.of("foo", newSpec)), auditInfo));
    EasyMock.verify(configManager);
}
Also used : AuditInfo(org.apache.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 20 with AuditInfo

use of org.apache.druid.audit.AuditInfo in project druid by druid-io.

the class LookupCoordinatorManagerTest method testUpdateLookupAdds.

@Test
public void testUpdateLookupAdds() {
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, druidNodeDiscoveryProvider, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, LookupExtractorFactoryMapContainer>> getKnownLookups() {
            return EMPTY_TIERED_LOOKUP;
        }
    };
    manager.start();
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    EasyMock.reset(configManager);
    EasyMock.expect(configManager.set(EasyMock.eq(LookupCoordinatorManager.LOOKUP_CONFIG_KEY), EasyMock.eq(TIERED_LOOKUP_MAP_V0), EasyMock.eq(auditInfo))).andReturn(SetResult.ok()).once();
    EasyMock.replay(configManager);
    manager.updateLookup(LOOKUP_TIER, SINGLE_LOOKUP_NAME, SINGLE_LOOKUP_SPEC_V0, auditInfo);
    EasyMock.verify(configManager);
}
Also used : AuditInfo(org.apache.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

AuditInfo (org.apache.druid.audit.AuditInfo)50 Test (org.junit.Test)45 Map (java.util.Map)17 AuditEntry (org.apache.druid.audit.AuditEntry)16 ImmutableMap (com.google.common.collect.ImmutableMap)14 Response (javax.ws.rs.core.Response)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)10 LookupCoordinatorManager (org.apache.druid.server.lookup.cache.LookupCoordinatorManager)10 ImmutableList (com.google.common.collect.ImmutableList)9 List (java.util.List)8 IntervalLoadRule (org.apache.druid.server.coordinator.rules.IntervalLoadRule)6 Rule (org.apache.druid.server.coordinator.rules.Rule)6 TypeReference (com.fasterxml.jackson.core.type.TypeReference)4 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 HashMap (java.util.HashMap)3 POST (javax.ws.rs.POST)3 IOException (java.io.IOException)2 Consumes (javax.ws.rs.Consumes)2 Path (javax.ws.rs.Path)2