Search in sources :

Example 81 with Event

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());
}
Also used : Tools(loghub.Tools) Event(loghub.Event) Test(org.junit.Test)

Example 82 with Event

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());
}
Also used : Tools(loghub.Tools) Event(loghub.Event) Test(org.junit.Test)

Example 83 with Event

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());
}
Also used : Tools(loghub.Tools) Event(loghub.Event) Test(org.junit.Test)

Example 84 with Event

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"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 85 with Event

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"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Aggregations

Event (loghub.Event)102 Test (org.junit.Test)90 Properties (loghub.configuration.Properties)63 Pipeline (loghub.Pipeline)23 Date (java.util.Date)19 Map (java.util.Map)18 HashMap (java.util.HashMap)14 IOException (java.io.IOException)13 Tools (loghub.Tools)13 URL (java.net.URL)8 Collections (java.util.Collections)8 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)8 Level (org.apache.logging.log4j.Level)7 List (java.util.List)6 EventsProcessor (loghub.EventsProcessor)6 LogManager (org.apache.logging.log4j.LogManager)6 Logger (org.apache.logging.log4j.Logger)6 LogUtils (loghub.LogUtils)5 ProcessorException (loghub.ProcessorException)5 Assert (org.junit.Assert)5