Search in sources :

Example 16 with AuditInfo

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

the class LookupCoordinatorManagerTest method testUpdateLookupAdds.

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

        @Override
        public Map<String, Map<String, Map<String, Object>>> getKnownLookups() {
            return EMPTY_TIERED_LOOKUP;
        }
    };
    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), EasyMock.eq(auditInfo))).andReturn(true).once();
    EasyMock.replay(configManager);
    manager.updateLookup(LOOKUP_TIER, SINGLE_LOOKUP_NAME, SINGLE_LOOKUP_SPEC, auditInfo);
    EasyMock.verify(configManager);
}
Also used : AuditInfo(io.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 17 with AuditInfo

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

the class LookupCoordinatorManagerTest method testUpdateLookupFailsUnitialized.

@Test
public void testUpdateLookupFailsUnitialized() throws Exception {
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, Map<String, Object>>> getKnownLookups() {
            return null;
        }
    };
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    expectedException.expect(ISE.class);
    manager.updateLookups(TIERED_LOOKUP_MAP, auditInfo);
}
Also used : AuditInfo(io.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 18 with AuditInfo

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

the class LookupCoordinatorManagerTest method testDeleteLookupIgnoresMissing.

@Test
public void testDeleteLookupIgnoresMissing() throws Exception {
    final Map<String, Object> ignore = ImmutableMap.<String, Object>of("lookup", "ignore");
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {

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

Example 19 with AuditInfo

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

the class LookupCoordinatorManagerTest method testUpdateLookupsAddsNewTier.

@Test
public void testUpdateLookupsAddsNewTier() throws Exception {
    final Map<String, Object> ignore = ImmutableMap.<String, Object>of("prop", "old");
    final AuditInfo auditInfo = new AuditInfo("author", "comment", "localhost");
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {

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

Example 20 with AuditInfo

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

the class LookupCoordinatorManagerTest method testUpdateLookupUpdates.

@Test
public void testUpdateLookupUpdates() throws Exception {
    final Map<String, Object> ignore = ImmutableMap.<String, Object>of("prop", "old");
    final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {

        @Override
        public Map<String, Map<String, Map<String, Object>>> getKnownLookups() {
            return ImmutableMap.<String, Map<String, Map<String, Object>>>of(LOOKUP_TIER, ImmutableMap.of("foo", ImmutableMap.<String, Object>of("prop", "old"), "ignore", ignore));
        }
    };
    final Map<String, Object> newSpec = ImmutableMap.<String, Object>of("prop", "new");
    final Map<String, Map<String, Object>> lookup = ImmutableMap.<String, Map<String, Object>>of("foo", newSpec, "ignore", ignore);
    final Map<String, Map<String, Map<String, Object>>> tier = ImmutableMap.of(LOOKUP_TIER, lookup);
    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("foo", newSpec, "ignore", ignore))), EasyMock.eq(auditInfo))).andReturn(true).once();
    EasyMock.replay(configManager);
    manager.updateLookups(tier, auditInfo);
    EasyMock.verify(configManager);
}
Also used : AuditInfo(io.druid.audit.AuditInfo) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

AuditInfo (io.druid.audit.AuditInfo)33 Test (org.junit.Test)31 Response (javax.ws.rs.core.Response)13 AuditEntry (io.druid.audit.AuditEntry)11 Map (java.util.Map)11 ImmutableMap (com.google.common.collect.ImmutableMap)10 LookupCoordinatorManager (io.druid.server.lookup.cache.LookupCoordinatorManager)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 DateTime (org.joda.time.DateTime)9 Interval (org.joda.time.Interval)6 List (java.util.List)5 TypeReference (com.fasterxml.jackson.core.type.TypeReference)4 ImmutableList (com.google.common.collect.ImmutableList)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 IntervalLoadRule (io.druid.server.coordinator.rules.IntervalLoadRule)3 Rule (io.druid.server.coordinator.rules.Rule)3 IOException (java.io.IOException)2 POST (javax.ws.rs.POST)2 Produces (javax.ws.rs.Produces)2 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)1