use of loghub.Event in project LogHub by fbacchella.
the class TestNettyNameResolver method arootasipv6addr.
@Test(timeout = 6000)
public void arootasipv6addr() throws Throwable {
Event e = Tools.getEvent();
// / resolving a.root-servers.net. in IPv6
e.put("host", InetAddress.getByName("2001:503:ba3e::2:30"));
Tools.ProcessingStatus status = dorequest(i -> {
i.setField("host");
i.setDestination("fqdn");
}, e, "0.3.0.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.3.a.b.3.0.5.0.1.0.0.2.ip6.arpa");
e = status.mainQueue.take();
Assert.assertEquals("resolution failed", "a.root-servers.net", e.get("fqdn"));
Assert.assertEquals("Queue not empty: " + status.mainQueue, 0, status.mainQueue.size());
Assert.assertEquals("Still waiting events: " + status.repository, 0, status.repository.waiting());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestNettyNameResolver method resolvemany.
@Test(timeout = 6000)
public void resolvemany() throws ProcessorException, InterruptedException, ConfigException, IOException {
Event e = Tools.getEvent();
e.put("hostipv6str", "2001:503:ba3e::2:30");
e.put("hostipv6inet", InetAddress.getByName("2001:503:ba3e::2:30"));
e.put("hostipv4str", "198.41.0.4");
e.put("hostipv4inet", InetAddress.getByName("198.41.0.4"));
Tools.ProcessingStatus status = dorequest(i -> {
i.setFields(new String[] { "*" });
i.setDestination("fqdn_${field}");
}, e, "0.3.0.0.2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.e.3.a.b.3.0.5.0.1.0.0.2.ip6.arpa", "4.0.41.198.in-addr.ptr");
do {
e = status.mainQueue.element();
Thread.sleep(10);
} while (e.size() != 8);
e = status.mainQueue.take();
Assert.assertEquals("Still waiting events: " + status.repository, 0, status.repository.waiting());
for (String i : new String[] { "hostipv6str", "hostipv6inet", "hostipv4str", "hostipv4inet" }) {
Assert.assertEquals("resolution failed", "a.root-servers.net", e.get("fqdn_" + i));
}
Assert.assertEquals("Queue not empty: " + status.mainQueue.size(), 0, status.mainQueue.size());
Assert.assertEquals("Still waiting events: " + status.repository, 0, status.repository.waiting());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestNettyNameResolver method badresolvertimeout.
@Test(timeout = 2000)
public void badresolvertimeout() throws Throwable {
Event e = Tools.getEvent();
// / resolving a.root-servers.net. in IPv4
e.put("host", InetAddress.getByName("10.0.0.1"));
Tools.ProcessingStatus status = dorequest(i -> {
i.setResolver("169.254.1.1");
i.setField("host");
i.setDestination("fqdn");
i.setTimeout(1);
}, e);
e = status.mainQueue.take();
Assert.assertEquals("resolution not failed", null, e.get("fqdn"));
Assert.assertEquals("resolution not paused", "PAUSED", status.status.get(1));
Assert.assertEquals("Queue not empty: " + status.mainQueue, 0, status.mainQueue.size());
Assert.assertEquals("Still waiting events: " + status.repository, 0, status.repository.waiting());
}
use of loghub.Event in project LogHub by fbacchella.
the class TestOnigurumaRegex method testLoadPatterns1.
@Test
public void testLoadPatterns1() throws ProcessorException {
OnigurumaRegex grok = new OnigurumaRegex();
grok.setField("message");
grok.setPattern("<(?<syslog_pri>\\d+)>(?<message>.*)");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("message", "<15>a text");
Assert.assertTrue(e.process(grok));
Assert.assertEquals("Didn't find the good syslog priority", "15", e.get("syslog_pri"));
Assert.assertEquals("Didn't find the good syslog message", "a text", e.get("message"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestOnigurumaRegex method testUtf1.
@Test
public void testUtf1() throws ProcessorException {
OnigurumaRegex grok = new OnigurumaRegex();
grok.setField("message");
grok.setPattern("<(?<syslog_pri>\\d+)>(?<message>.*)");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("message", "<15>a textà ");
Assert.assertTrue(e.process(grok));
Assert.assertEquals("Didn't find the good syslog priority", "15", e.get("syslog_pri"));
Assert.assertEquals("Didn't find the good syslog message", "a textà ", e.get("message"));
}
Aggregations