use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test8.
@Test
public void test8() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.setTimestamp(new Date(1));
Tools.runProcessing(sent, conf.namedPipeLine.get("timestamp"), conf);
Assert.assertEquals(new Date(0), sent.getTimestamp());
Assert.assertEquals(new Date(1), sent.get("reception_time"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test4.
@Test
public void test4() throws ProcessorException {
Etl.Assign etl = new Etl.Assign();
etl.setLvalue(new String[] { "a" });
etl.setExpression("formatters.a.format(event)");
Map<String, String> formats = Collections.singletonMap("a", "${@timestamp%t<GMT>H}");
Map<String, Object> properties = new HashMap<>();
properties.put("__FORMATTERS", formats);
boolean done = etl.configure(new Properties(properties));
Assert.assertTrue("configuration failed", done);
Event event = Tools.getEvent();
event.setTimestamp(new Date(3600 * 1000));
event.process(etl);
Assert.assertEquals("evaluation failed", "01", event.get("a"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestEtl method test6.
@Test
public void test6() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("count", "1");
Tools.runProcessing(sent, conf.namedPipeLine.get("second"), conf);
Assert.assertEquals("conversion not expected", 1, sent.get("count"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestGrok method TestLoadPatterns6.
@Test
public void TestLoadPatterns6() throws ProcessorException {
Grok grok = new Grok();
grok.setFields(new String[] { "remotehost" });
grok.setPattern("%{HOSTNAME:.}\\.google\\.com");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("localhost", "127.0.0.1");
e.put("remotehost", "www.google.com");
e.put("remotehostother", "www.google.com");
e.put("host", "www.yahoo.com");
Tools.runProcessing(e, "main", Collections.singletonList(grok));
Assert.assertEquals("invalid FQDN matching", "www", e.get("remotehost"));
}
use of loghub.configuration.Properties in project LogHub by fbacchella.
the class TestGrok method TestLoadPatterns5.
@Test
public void TestLoadPatterns5() throws ProcessorException {
Grok grok = new Grok();
grok.setFields(new String[] { "localhost" });
grok.setPattern("%{HOSTNAME:.}\\.google\\.com");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("localhost", "127.0.0.1");
e.put("remotehost", "www.google.com");
e.put("remotehostother", "www.google.com");
e.put("host", "www.yahoo.com");
Tools.runProcessing(e, "main", Collections.singletonList(grok));
Assert.assertEquals("invalid FQDN matching", "www.google.com", e.get("remotehost"));
Assert.assertEquals("invalid FQDN matching", "127.0.0.1", e.get("localhost"));
}
Aggregations