use of com.yahoo.vespa.model.test.VespaModelTester in project vespa by vespa-engine.
the class ModelProvisioningTest method testThatTldConfigIdsAreDeterministic.
@Test
public void testThatTldConfigIdsAreDeterministic() {
String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + " <admin version='4.0'/>" + " <jdisc version='1.0' id='jdisc0'>" + " <search/>" + " <nodes count='2'/>" + " </jdisc>" + " <jdisc version='1.0' id='jdisc1'>" + " <search/>" + " <nodes count='2'/>" + " </jdisc>" + " <content version='1.0' id='content0'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='type1' mode='index'/>" + " </documents>" + " <nodes count='2'/>" + " </content>" + " <content version='1.0' id='content1'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='type1' mode='index'/>" + " </documents>" + " <nodes count='2'/>" + " </content>" + "</services>";
int numberOfHosts = 8;
{
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts);
// Nodes used will be default0, default1, .. and so on.
VespaModel model = tester.createModel(services, true);
assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
Map<String, ContentCluster> contentClusters = model.getContentClusters();
assertEquals(2, contentClusters.size());
checkThatTldAndContainerRunningOnSameHostHaveSameId(model.getContainerClusters().values(), model.getContentClusters().values(), 0);
}
{
VespaModelTester tester = new VespaModelTester();
tester.addHosts(numberOfHosts + 1);
// Start numbering nodes with index 1 and retire first node
// Nodes used will be default1, default2, .. and so on. Containers will start with index 1, not 0 as they are in the test above
VespaModel model = tester.createModel(services, true, 1, "default0");
assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
Map<String, ContentCluster> contentClusters = model.getContentClusters();
assertEquals(2, contentClusters.size());
checkThatTldAndContainerRunningOnSameHostHaveSameId(model.getContainerClusters().values(), model.getContentClusters().values(), 1);
}
}
use of com.yahoo.vespa.model.test.VespaModelTester in project vespa by vespa-engine.
the class ModelProvisioningTest method testNoNodeTagMeans1NodeNonHosted.
@Test
public void testNoNodeTagMeans1NodeNonHosted() {
String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + " <jdisc id='foo' version='1.0'>" + " <search/>" + " <document-api/>" + " </jdisc>" + " <content version='1.0' id='bar'>" + " <documents>" + " <document type='type1' mode='index'/>" + " </documents>" + " </content>" + "</services>";
VespaModelTester tester = new VespaModelTester();
tester.setHosted(false);
tester.addHosts(1);
VespaModel model = tester.createModel(services, true);
assertEquals(1, model.getRoot().getHostSystem().getHosts().size());
assertEquals(1, model.getAdmin().getSlobroks().size());
assertEquals(1, model.getContainerClusters().get("foo").getContainers().size());
assertEquals(1, model.getContentClusters().get("bar").getRootGroup().recursiveGetNodes().size());
}
use of com.yahoo.vespa.model.test.VespaModelTester in project vespa by vespa-engine.
the class ModelProvisioningTest method testCombinedClusterWithJvmArgs.
@Test
public void testCombinedClusterWithJvmArgs() {
String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + " <container version='1.0' id='container1'>" + " <document-processing/>" + " <nodes of='content1' jvmargs='testarg'/>" + " </container>" + " <content version='1.0' id='content1'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='type1' mode='index'/>" + " </documents>" + " <nodes count='2'/>" + " </content>" + "</services>";
VespaModelTester tester = new VespaModelTester();
tester.addHosts(2);
VespaModel model = tester.createModel(xmlWithNodes, true);
assertEquals("Nodes in content1", 2, model.getContentClusters().get("content1").getRootGroup().getNodes().size());
assertEquals("Nodes in container1", 2, model.getContainerClusters().get("container1").getContainers().size());
for (Container container : model.getContainerClusters().get("container1").getContainers()) assertTrue(container.getJvmArgs().contains("testarg"));
}
use of com.yahoo.vespa.model.test.VespaModelTester in project vespa by vespa-engine.
the class ModelProvisioningTest method testNonExistingCombinedClusterReference.
@Test
public void testNonExistingCombinedClusterReference() {
String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + " <container version='1.0' id='container1'>" + " <nodes of='container2'/>" + " </container>" + "</services>";
VespaModelTester tester = new VespaModelTester();
tester.addHosts(2);
try {
tester.createModel(xmlWithNodes, true);
fail("Expected exception");
} catch (IllegalArgumentException e) {
assertEquals("container cluster 'container1' references service 'container2' but this service is not defined", e.getMessage());
}
}
use of com.yahoo.vespa.model.test.VespaModelTester in project vespa by vespa-engine.
the class ModelProvisioningTest method testMultipleCombinedClusters.
@Test
public void testMultipleCombinedClusters() {
String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + " <container version='1.0' id='container1'>" + " <nodes of='content1'/>" + " </container>" + " <container version='1.0' id='container2'>" + " <nodes of='content2'/>" + " </container>" + " <content version='1.0' id='content1'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='type1' mode='index'/>" + " </documents>" + " <nodes count='2'/>" + " </content>" + " <content version='1.0' id='content2'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='type1' mode='index'/>" + " </documents>" + " <nodes count='3'/>" + " </content>" + "</services>";
VespaModelTester tester = new VespaModelTester();
tester.addHosts(5);
VespaModel model = tester.createModel(xmlWithNodes, true);
assertEquals("Nodes in content1", 2, model.getContentClusters().get("content1").getRootGroup().getNodes().size());
assertEquals("Nodes in container1", 2, model.getContainerClusters().get("container1").getContainers().size());
assertEquals("Nodes in content2", 3, model.getContentClusters().get("content2").getRootGroup().getNodes().size());
assertEquals("Nodes in container2", 3, model.getContainerClusters().get("container2").getContainers().size());
}
Aggregations