Search in sources :

Example 11 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class ProfileSplitterBoltTest method testResolveEntityName.

/**
 * The entity associated with a profile is defined with a Stellar expression.  That expression
 * can refer to any field within the message.
 *
 * In this case the entity is defined as 'ip_src_addr' which is resolved to '10.0.0.1' based on
 * the data contained within the message.
 */
@Test
public void testResolveEntityName() throws Exception {
    ProfilerConfig config = toProfilerConfig(profileWithOnlyIfTrue);
    ProfileSplitterBolt bolt = createBolt(config);
    bolt.execute(tuple);
    // expected values
    String expectedEntity = "10.0.0.1";
    ProfileConfig expectedConfig = config.getProfiles().get(0);
    Values expected = new Values(message, timestamp, expectedEntity, expectedConfig);
    // a tuple should be emitted for the downstream profile builder
    verify(outputCollector, times(1)).emit(eq(tuple), eq(expected));
    // the original tuple should be ack'd
    verify(outputCollector, times(1)).ack(eq(tuple));
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) Values(org.apache.storm.tuple.Values) ProfileConfig(org.apache.metron.common.configuration.profiler.ProfileConfig) Test(org.junit.Test) BaseBoltTest(org.apache.metron.test.bolt.BaseBoltTest)

Example 12 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class ProfileSplitterBoltTest method testOnlyIfFalse.

/**
 * What happens when a profile's 'onlyif' expression is false?  The message
 * should NOT be applied to the profile.
 */
@Test
public void testOnlyIfFalse() throws Exception {
    ProfilerConfig config = toProfilerConfig(profileWithOnlyIfFalse);
    ProfileSplitterBolt bolt = createBolt(config);
    bolt.execute(tuple);
    // a tuple should NOT be emitted for the downstream profile builder
    verify(outputCollector, times(0)).emit(any());
    // the original tuple should be ack'd
    verify(outputCollector, times(1)).ack(eq(tuple));
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) Test(org.junit.Test) BaseBoltTest(org.apache.metron.test.bolt.BaseBoltTest)

Example 13 with ProfilerConfig

use of org.apache.metron.common.configuration.profiler.ProfilerConfig in project metron by apache.

the class DefaultClockFactoryTest method testCreateProcessingTimeClock.

/**
 * When a 'timestampField' is defined the factory should return a clock
 * that deals with processing time.
 */
@Test
public void testCreateProcessingTimeClock() {
    // the profiler uses processing time by default
    ProfilerConfig config = new ProfilerConfig();
    // the factory should return a clock that handles 'processing time'
    Clock clock = clockFactory.createClock(config);
    assertTrue(clock instanceof WallClock);
}
Also used : ProfilerConfig(org.apache.metron.common.configuration.profiler.ProfilerConfig) Test(org.junit.Test)

Aggregations

ProfilerConfig (org.apache.metron.common.configuration.profiler.ProfilerConfig)13 Test (org.junit.Test)10 BaseBoltTest (org.apache.metron.test.bolt.BaseBoltTest)8 Values (org.apache.storm.tuple.Values)6 ProfileConfig (org.apache.metron.common.configuration.profiler.ProfileConfig)3 File (java.io.File)1 Map (java.util.Map)1 SensorEnrichmentConfig (org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig)1 ProfilerConfigurations (org.apache.metron.common.configuration.profiler.ProfilerConfigurations)1 Clock (org.apache.metron.profiler.clock.Clock)1 Tuple (org.apache.storm.tuple.Tuple)1 JSONObject (org.json.simple.JSONObject)1