Search in sources :

Example 1 with LogforwarderConfig

use of com.yahoo.cloud.config.LogforwarderConfig in project vespa by vespa-engine.

the class DedicatedAdminV4Test method testLogForwarding.

@Test
public void testLogForwarding() throws IOException, SAXException {
    String services = "<services>" + "  <admin version='4.0'>" + "    <slobroks><nodes count='2' dedicated='true'/></slobroks>" + "    <logservers><nodes count='1' dedicated='true'/></logservers>" + "    <logforwarding>" + "      <splunk deployment-server='foo:123' client-name='foocli'/>" + "    </logforwarding>" + "  </admin>" + "</services>";
    VespaModel model = createModel(hosts, services);
    assertEquals(3, model.getHosts().size());
    assertHostContainsServices(model, "hosts/myhost0", "logd", "logforwarder", "slobrok");
    assertHostContainsServices(model, "hosts/myhost1", "logd", "logforwarder", "slobrok");
    assertHostContainsServices(model, "hosts/myhost2", "logd", "logforwarder", "logserver");
    Set<String> configIds = model.getConfigIds();
    // 1 logforwarder on each host
    IntStream.of(0, 1, 2).forEach(i -> assertTrue(configIds.toString(), configIds.contains("hosts/myhost" + i + "/logforwarder")));
    // First forwarder
    {
        LogforwarderConfig.Builder builder = new LogforwarderConfig.Builder();
        model.getConfig(builder, "hosts/myhost0/logforwarder");
        LogforwarderConfig config = new LogforwarderConfig(builder);
        assertEquals("foo:123", config.deploymentServer());
        assertEquals("foocli", config.clientName());
        assertEquals("/opt/splunkforwarder", config.splunkHome());
    }
    // Other host's forwarder
    {
        LogforwarderConfig.Builder builder = new LogforwarderConfig.Builder();
        model.getConfig(builder, "hosts/myhost2/logforwarder");
        LogforwarderConfig config = new LogforwarderConfig(builder);
        assertEquals("foo:123", config.deploymentServer());
        assertEquals("foocli", config.clientName());
    }
}
Also used : LogforwarderConfig(com.yahoo.cloud.config.LogforwarderConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Aggregations

LogforwarderConfig (com.yahoo.cloud.config.LogforwarderConfig)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 Test (org.junit.Test)1