Search in sources :

Example 16 with VespaModelCreatorWithMockPkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg in project vespa by vespa-engine.

the class ModelProvisioningTest method testNodeCountForJdisc.

@Test
public void testNodeCountForJdisc() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>\n" + "\n" + "<admin version='3.0'><nodes count='1' /></admin>\n" + "<jdisc id='mydisc' version='1.0'>" + "  <handler id='myHandler'>" + "    <component id='injected' />" + "  </handler>" + "  <nodes count=\"3\"/>" + "</jdisc>" + "<jdisc id='mydisc2' version='1.0'>" + "  <document-processing/>" + "  <handler id='myHandler'>" + "    <component id='injected' />" + "  </handler>" + "  <nodes count='2' allocated-memory='45%' jvmargs='-verbosegc' preload='lib/blablamalloc.so'/>" + "</jdisc>" + "</services>";
    String hosts = "<hosts>" + " <host name='myhost0'>" + "  <alias>node0</alias>" + " </host>" + " <host name='myhost1'>" + "  <alias>node1</alias>" + " </host>" + " <host name='myhost2'>" + "  <alias>node2</alias>" + " </host>" + " <host name='myhost3'>" + "  <alias>node3</alias>" + " </host>" + " <host name='myhost4'>" + "  <alias>node4</alias>" + " </host>" + " <host name='myhost5'>" + "  <alias>node5</alias>" + " </host>" + "</hosts>";
    VespaModelCreatorWithMockPkg creator = new VespaModelCreatorWithMockPkg(null, services);
    VespaModel model = creator.create(new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(Hosts.readFrom(new StringReader(hosts)), true)));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().size(), is(3));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(0).getConfigId(), is("mydisc/container.0"));
    assertTrue(model.getContainerClusters().get("mydisc").getContainers().get(0).isInitialized());
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(1).getConfigId(), is("mydisc/container.1"));
    assertTrue(model.getContainerClusters().get("mydisc").getContainers().get(1).isInitialized());
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(2).getConfigId(), is("mydisc/container.2"));
    assertTrue(model.getContainerClusters().get("mydisc").getContainers().get(2).isInitialized());
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().size(), is(2));
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().get(0).getConfigId(), is("mydisc2/container.0"));
    assertTrue(model.getContainerClusters().get("mydisc2").getContainers().get(0).isInitialized());
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().get(1).getConfigId(), is("mydisc2/container.1"));
    assertTrue(model.getContainerClusters().get("mydisc2").getContainers().get(1).isInitialized());
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(0).getJvmArgs(), is(""));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(1).getJvmArgs(), is(""));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(2).getJvmArgs(), is(""));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(0).getPreLoad(), is(getDefaults().underVespaHome("lib64/vespa/malloc/libvespamalloc.so")));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(1).getPreLoad(), is(getDefaults().underVespaHome("lib64/vespa/malloc/libvespamalloc.so")));
    assertThat(model.getContainerClusters().get("mydisc").getContainers().get(2).getPreLoad(), is(getDefaults().underVespaHome("lib64/vespa/malloc/libvespamalloc.so")));
    assertThat(model.getContainerClusters().get("mydisc").getMemoryPercentage(), is(Optional.empty()));
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().get(0).getJvmArgs(), is("-verbosegc"));
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().get(1).getJvmArgs(), is("-verbosegc"));
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().get(0).getPreLoad(), is("lib/blablamalloc.so"));
    assertThat(model.getContainerClusters().get("mydisc2").getContainers().get(1).getPreLoad(), is("lib/blablamalloc.so"));
    assertThat(model.getContainerClusters().get("mydisc2").getMemoryPercentage(), is(Optional.of(45)));
    HostSystem hostSystem = model.getHostSystem();
    assertNotNull(hostSystem.getHostByHostname("myhost0"));
    assertNotNull(hostSystem.getHostByHostname("myhost1"));
    assertNotNull(hostSystem.getHostByHostname("myhost2"));
    assertNotNull(hostSystem.getHostByHostname("myhost3"));
    assertNull(hostSystem.getHostByHostname("Nope"));
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) StringReader(java.io.StringReader) HostSystem(com.yahoo.vespa.model.HostSystem) Test(org.junit.Test)

Example 17 with VespaModelCreatorWithMockPkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg in project vespa by vespa-engine.

the class ContentBuilderTest method requireThatUserConfigCanBeSpecifiedForASearchDefinition.

@Test
public void requireThatUserConfigCanBeSpecifiedForASearchDefinition() throws Exception {
    String services = getConfigOverrideServices("<node hostalias='mockhost' distribution-key='0'/>", "  <config name='mynamespace.myconfig'>" + "    <myfield>myvalue</myfield>" + "  </config>");
    VespaModel m = new VespaModelCreatorWithMockPkg(createAppWithMusic(getHosts(), services)).create();
    String configId = "clu/search/cluster.clu/music";
    {
        GenericConfig.GenericConfigBuilder builder = new GenericConfig.GenericConfigBuilder(new ConfigDefinitionKey("myconfig", "mynamespace"), new ConfigPayloadBuilder());
        m.getConfig(builder, configId);
        assertEquals(builder.getPayload().getSlime().get().field("myfield").asString(), "myvalue");
    }
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) GenericConfig(com.yahoo.vespa.config.GenericConfig) VespaModel(com.yahoo.vespa.model.VespaModel) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) Matchers.containsString(org.hamcrest.Matchers.containsString) ConfigPayloadBuilder(com.yahoo.vespa.config.ConfigPayloadBuilder) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 18 with VespaModelCreatorWithMockPkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg in project vespa by vespa-engine.

the class ContentBuilderTest method testMultipleSearchNodesOnSameHost.

@Test
public void testMultipleSearchNodesOnSameHost() throws Exception {
    String services = getServices("<node hostalias='mockhost' distribution-key='0'/>" + "<node hostalias='mockhost' distribution-key='1'/>");
    VespaModel m = new VespaModelCreatorWithMockPkg(createAppWithMusic(getHosts(), services)).create();
    PartitionsConfig partitionsConfig = new PartitionsConfig((PartitionsConfig.Builder) m.getConfig(new PartitionsConfig.Builder(), "clu/search/cluster.clu/tlds/qrc.0.tld.0"));
    assertTrue(partitionsConfig.dataset(0).engine(0).name_and_port().startsWith("tcp/node0:191"));
    IndexedSearchCluster sc = m.getContentClusters().get("clu").getSearch().getIndexed();
    assertEquals(2, sc.getSearchNodeCount());
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 19 with VespaModelCreatorWithMockPkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg in project vespa by vespa-engine.

the class ContentBuilderTest method testConfigIdLookup.

@Test
public void testConfigIdLookup() throws Exception {
    VespaModel m = new VespaModelCreatorWithMockPkg(createAppWithMusic(getHosts(), getBasicServices())).create();
    PartitionsConfig partitionsConfig = new PartitionsConfig((PartitionsConfig.Builder) m.getConfig(new PartitionsConfig.Builder(), "clu/search/cluster.clu/tlds/qrc.0.tld.0"));
    assertTrue(partitionsConfig.dataset(0).engine(0).name_and_port().startsWith("tcp/node0:191"));
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 20 with VespaModelCreatorWithMockPkg

use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg in project vespa by vespa-engine.

the class StorageNodeTest method getConfig.

private StorDevicesConfig getConfig(boolean useVdsEngine) {
    String vdsConfig = useVdsEngine ? "    <engine>" + "      <vds/>" + "    </engine>" : "";
    String servicesXml = "<?xml version='1.0' encoding='utf-8' ?>" + "<services version='1.0'>" + "  <admin version='2.0'>" + "    <adminserver hostalias='node0'/>" + "  </admin>" + "  <content version='1.0' id='zoo'>" + "    <redundancy>1</redundancy>" + "    <nodes count='1' />" + "    <documents>" + "      <document type='type1' mode='streaming' />" + "    </documents>" + vdsConfig + "  </content>" + "</services>";
    List<String> searchDefinitions = ApplicationPackageUtils.generateSearchDefinition("type1");
    VespaModelCreatorWithMockPkg modelCreator = new VespaModelCreatorWithMockPkg(null, servicesXml, searchDefinitions);
    ApplicationPackage appPkg = modelCreator.appPkg;
    boolean failOnOutOfCapacity = true;
    InMemoryProvisioner provisioner = new InMemoryProvisioner(failOnOutOfCapacity, "host1.yahoo.com", "host2.yahoo.com");
    DeployProperties.Builder builder = new DeployProperties.Builder();
    DeployProperties properties = builder.hostedVespa(true).build();
    DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
    VespaModel model = modelCreator.create(true, deployState);
    return model.getConfig(StorDevicesConfig.class, "zoo/storage/0");
}
Also used : VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) 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)

Aggregations

VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)31 VespaModel (com.yahoo.vespa.model.VespaModel)26 Test (org.junit.Test)22 DeployState (com.yahoo.config.model.deploy.DeployState)5 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)4 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)4 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)4 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)3 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)3 AttributesConfig (com.yahoo.vespa.config.search.AttributesConfig)3 PartitionsConfig (com.yahoo.vespa.config.search.core.PartitionsConfig)3 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)3 IndexedSearchCluster (com.yahoo.vespa.model.search.IndexedSearchCluster)3 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)2 ProtonEngine (com.yahoo.vespa.model.content.engines.ProtonEngine)2 ContentClusterBuilder (com.yahoo.vespa.model.content.utils.ContentClusterBuilder)2