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"));
}
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");
}
}
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());
}
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"));
}
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");
}
Aggregations