Search in sources :

Example 31 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class AdminTestCase method testOnlyAdminserver.

/**
 * Test that a very simple config with only adminserver tag creates
 * adminserver, logserver, configserver and slobroks
 */
@Test
public void testOnlyAdminserver() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "simpleadminconfig20");
    // Verify that the admin plugin has been loaded (always loads routing).
    assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
    ApplicationConfigProducerRoot root = vespaModel.getVespa();
    assertNotNull(root);
    // Verify configIds
    Set<String> configIds = vespaModel.getConfigIds();
    String localhost = HostName.getLocalhost();
    String localhostConfigId = "hosts/" + localhost;
    assertTrue(configIds.contains(localhostConfigId));
    assertTrue(configIds.contains("admin/logserver"));
    assertTrue(configIds.contains("admin/configservers/configserver.0"));
    assertTrue(configIds.contains("admin/slobrok.0"));
    assertFalse(configIds.contains("admin/slobrok.1"));
    // Verify services in the sentinel config
    SentinelConfig.Builder b = new SentinelConfig.Builder();
    vespaModel.getConfig(b, localhostConfigId);
    SentinelConfig sentinelConfig = new SentinelConfig(b);
    assertThat(sentinelConfig.service().size(), is(3));
    assertThat(sentinelConfig.service(0).name(), is("logserver"));
    assertThat(sentinelConfig.service(1).name(), is("slobrok"));
    assertThat(sentinelConfig.service(2).name(), is("logd"));
    assertThat(sentinelConfig.service(0).affinity().cpuSocket(), is(-1));
    assertTrue(sentinelConfig.service(0).preShutdownCommand().isEmpty());
    // Confirm slobrok config
    SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
    vespaModel.getConfig(sb, "admin");
    SlobroksConfig sc = new SlobroksConfig(sb);
    assertEquals(sc.slobrok().size(), 1);
    assertTrue(sc.slobrok().get(0).connectionspec().matches(".*" + localhost + ".*"));
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 32 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class AdminTestCase method testAdmin20.

/**
 * Test that version 2.0 of adminconfig works as expected.
 */
@Test
public void testAdmin20() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "adminconfig20");
    // Verify that the admin plugin has been loaded (always loads routing).
    assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
    ApplicationConfigProducerRoot root = vespaModel.getVespa();
    assertNotNull(root);
    // Verify configIds
    Set<String> configIds = vespaModel.getConfigIds();
    String localhost = HostName.getLocalhost();
    String localhostConfigId = "hosts/" + localhost;
    assertTrue(configIds.contains(localhostConfigId));
    assertTrue(configIds.contains("admin/logserver"));
    assertTrue(configIds.contains("admin/configservers/configserver.0"));
    assertTrue(configIds.contains("admin/slobrok.0"));
    assertTrue(configIds.contains("admin/slobrok.1"));
    assertFalse(configIds.contains("admin/slobrok.2"));
    assertTrue(configIds.contains("admin"));
    // Confirm 2 slobroks in config
    SlobroksConfig.Builder sb = new SlobroksConfig.Builder();
    vespaModel.getConfig(sb, "admin/slobrok.0");
    SlobroksConfig sc = new SlobroksConfig(sb);
    assertEquals(sc.slobrok().size(), 2);
    boolean localHostOK = false;
    for (Slobrok s : sc.slobrok()) {
        if (s.connectionspec().matches(".*" + localhost + ".*"))
            localHostOK = true;
    }
    assertTrue(localHostOK);
    LogdConfig.Builder lb = new LogdConfig.Builder();
    vespaModel.getConfig(lb, "admin/slobrok.0");
    LogdConfig lc = new LogdConfig(lb);
    assertEquals(lc.logserver().host(), localhost);
    // Verify services in the sentinel config
    SentinelConfig.Builder b = new SentinelConfig.Builder();
    vespaModel.getConfig(b, localhostConfigId);
    SentinelConfig sentinelConfig = new SentinelConfig(b);
    assertThat(sentinelConfig.service().size(), is(4));
    assertThat(sentinelConfig.service(0).name(), is("logserver"));
    assertThat(sentinelConfig.service(1).name(), is("slobrok"));
    assertThat(sentinelConfig.service(2).name(), is("slobrok2"));
    assertThat(sentinelConfig.service(3).name(), is("logd"));
}
Also used : SlobroksConfig(com.yahoo.cloud.config.SlobroksConfig) LogdConfig(com.yahoo.cloud.config.log.LogdConfig) ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) SentinelConfig(com.yahoo.cloud.config.SentinelConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Slobrok(com.yahoo.cloud.config.SlobroksConfig.Slobrok) Test(org.junit.Test)

Example 33 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class AdminTestCase method testMultipleConfigServers.

@Test
public void testMultipleConfigServers() throws Exception {
    VespaModel vespaModel = getVespaModel(TESTDIR + "multipleconfigservers");
    // Verify that the admin plugin has been loaded (always loads routing).
    assertThat(vespaModel.configModelRepo().asMap().size(), is(2));
    ApplicationConfigProducerRoot root = vespaModel.getVespa();
    assertNotNull(root);
    Admin admin = vespaModel.getAdmin();
    assertNotNull(admin);
    // Verify configIds
    Set<String> configIds = vespaModel.getConfigIds();
    String localhost = HostName.getLocalhost();
    String localhostConfigId = "hosts/" + localhost;
    assertTrue(configIds.contains(localhostConfigId));
    assertTrue(configIds.contains("admin/logserver"));
    assertTrue(configIds.contains("admin/configservers/configserver.0"));
    assertTrue(configIds.contains("admin/configservers/configserver.1"));
    assertThat(admin.getConfigservers().size(), is(2));
    // Default configserver is the first one in the list and should have the default ports too
    Configserver server1 = admin.getConfigservers().get(0);
    assertEquals(admin.getConfigserver(), server1);
    assertThat(server1.getPortCount(), is(2));
    assertThat(server1.getRelativePort(0), is(19070));
    assertThat(server1.getRelativePort(1), is(19071));
    // Second configserver should be on second host but have the same port number
    Configserver server2 = admin.getConfigservers().get(1);
    assertNotSame(server1, server2);
    assertNotSame(server1.getHostName(), server2.getHostName());
    assertThat(server2.getPortCount(), is(2));
    assertThat(server2.getRelativePort(0), is(19070));
    assertThat(server2.getRelativePort(1), is(19071));
}
Also used : ApplicationConfigProducerRoot(com.yahoo.config.model.ApplicationConfigProducerRoot) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 34 with VespaModel

use of com.yahoo.vespa.model.VespaModel 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)

Example 35 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class ValidationTester method deploy.

/**
 * Deploys an application
 *
 * @param previousModel the previous model, or null if no previous
 * @param services the services file content
 * @param validationOverrides the validation overrides file content, or null if none
 * @return the new model and any change actions
 */
public Pair<VespaModel, List<ConfigChangeAction>> deploy(VespaModel previousModel, String services, String validationOverrides) {
    Instant now = LocalDate.parse("2000-01-01", DateTimeFormatter.ISO_DATE).atStartOfDay().atZone(ZoneOffset.UTC).toInstant();
    ApplicationPackage newApp = new MockApplicationPackage.Builder().withServices(services).withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).withValidationOverrides(validationOverrides).build();
    VespaModelCreatorWithMockPkg newModelCreator = new VespaModelCreatorWithMockPkg(newApp);
    DeployState.Builder deployStateBuilder = new DeployState.Builder().applicationPackage(newApp).properties(new DeployProperties.Builder().hostedVespa(true).build()).modelHostProvisioner(new InMemoryProvisioner(nodeCount)).now(now);
    if (previousModel != null)
        deployStateBuilder.previousModel(previousModel);
    VespaModel newModel = newModelCreator.create(deployStateBuilder);
    return new Pair<>(newModel, newModelCreator.configChangeActions);
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) Instant(java.time.Instant) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Pair(com.yahoo.collections.Pair)

Aggregations

VespaModel (com.yahoo.vespa.model.VespaModel)153 Test (org.junit.Test)135 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)35 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)26 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)22 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)21 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)18 DeployState (com.yahoo.config.model.deploy.DeployState)18 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)15 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)14 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)13 Matchers.containsString (org.hamcrest.Matchers.containsString)12 File (java.io.File)8 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)6 ValidationTester (com.yahoo.vespa.model.application.validation.ValidationTester)6 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)6 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)5 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)5 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)5 HostResource (com.yahoo.vespa.model.HostResource)5