use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ContainerModelBuilderTest method singlenode_servicespec_is_used_with_hosted_vespa.
@Test
public void singlenode_servicespec_is_used_with_hosted_vespa() throws IOException, SAXException {
String servicesXml = "<jdisc id='default' version='1.0' />";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com", "host2.yahoo.com")).applicationPackage(applicationPackage).properties(new DeployProperties.Builder().multitenant(true).hostedVespa(true).build()).build(true));
assertEquals(1, model.getHostSystem().getHosts().size());
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ContainerModelBuilderTest method singlenode_servicespec_is_used_with_hosts_xml.
@Test
public void singlenode_servicespec_is_used_with_hosts_xml() throws IOException, SAXException {
String servicesXml = "<jdisc id='default' version='1.0' />";
String hostsXml = "<hosts>\n" + " <host name=\"test1.yahoo.com\">\n" + " <alias>node1</alias>\n" + " </host>\n" + "</hosts>";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withHosts(hostsXml).withServices(servicesXml).build();
VespaModel model = new VespaModel(applicationPackage);
assertThat(model.getHostSystem().getHosts().size(), is(1));
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class DeploymentFileValidatorTest method testDeploymentWithNonExistentGlobalId.
@Test
public void testDeploymentWithNonExistentGlobalId() throws IOException, SAXException {
final String simpleHosts = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<hosts> " + "<host name=\"localhost\">" + "<alias>node0</alias>" + "</host>" + "</hosts>";
final String services = "<services version='1.0'>" + " <admin version='2.0'>" + " <adminserver hostalias='node0' />" + " </admin>" + " <jdisc id='default' version='1.0'>" + " <search/>" + " <nodes>" + " <node hostalias='node0'/>" + " </nodes>" + " </jdisc>" + "</services>";
final String deploymentSpec = "<?xml version='1.0' encoding='UTF-8'?>" + "<deployment version='1.0'>" + " <test />" + " <prod global-service-id='non-existing'>" + " <region active='true'>us-east</region>" + " </prod>" + "</deployment>";
ApplicationPackage app = new MockApplicationPackage.Builder().withHosts(simpleHosts).withServices(services).withDeploymentSpec(deploymentSpec).build();
DeployState.Builder builder = new DeployState.Builder().applicationPackage(app);
try {
final DeployState deployState = builder.build(true);
VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState);
new DeploymentFileValidator().validate(model, deployState);
fail("Did not get expected exception");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), containsString("specified in deployment.xml does not match any container cluster id"));
}
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ClusterTest method newContentCluster.
private static ContentCluster newContentCluster(String contentSearchXml, boolean globalDocType) throws ParseException {
ApplicationPackage app = new MockApplicationPackage.Builder().withHosts(joinLines("<hosts>", " <host name='localhost'><alias>my_host</alias></host>", "</hosts>")).withServices(joinLines("<services version='1.0'>", " <admin version='2.0'>", " <adminserver hostalias='my_host' />", " </admin>", " <content version='1.0'>", " <documents>", " " + getDocumentXml(globalDocType), " </documents>", " <engine><proton /></engine>", " <group>", " <node hostalias='my_host' distribution-key='0' />", " </group>", contentSearchXml, " </content>", "</services>")).withSearchDefinitions(ApplicationPackageUtils.generateSearchDefinition("my_document")).build();
List<Content> contents = new TestDriver().buildModel(app).getConfigModels(Content.class);
assertEquals(1, contents.size());
return contents.get(0).getCluster();
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class TldTest method requireThatUseLocalPolicyIsOk.
@Test
public void requireThatUseLocalPolicyIsOk() {
ApplicationPackage app = new MockApplicationPackage.Builder().withHosts("<hosts>" + "<host name='search.node1'><alias>search1</alias></host>" + "<host name='search.node2'><alias>search2</alias></host>" + "<host name='jdisc.host.other'><alias>gateway</alias></host>" + "</hosts>").withServices("<services>" + " <admin version='2.0'>" + " <adminserver hostalias='gateway' />" + " </admin>" + " <jdisc version='1.0' id='default'>" + " <search />" + " <nodes>" + " <node hostalias='search1'/>" + " <node hostalias='search2'/>" + " </nodes>" + " </jdisc>" + " <jdisc version='1.0' id='gw'>" + " <document-api/>" + " <nodes>" + " <node hostalias='gateway'/>" + " </nodes>" + " </jdisc>" + " <content version='1.0' id='foo'>" + " <redundancy>2</redundancy>" + " <documents>" + " <document type='music' mode='index'/>" + " </documents>" + " <group name='topGroup'>" + " <distribution partitions='1|*'/>" + " <group name='group1' distribution-key='0'>" + " <node hostalias='search1' distribution-key='0'/>" + " </group>" + " <group name='group2' distribution-key='1'>" + " <node hostalias='search2' distribution-key='1'/>" + " </group>" + " </group>" + " <tuning>" + " <dispatch>" + " <use-local-node>true</use-local-node>" + " </dispatch>" + " </tuning>" + " </content>" + "</services>").withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).build();
PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/gw.0.tld.0");
PartitionsConfig config = new PartitionsConfig(builder);
assertEquals(1, config.dataset().size());
// gateway TLD with no local search node gets all search nodes
assertEquals(2, config.dataset(0).engine().size());
// Load Balance row 0
assertEquals("rowid not equal 0", 0, config.dataset(0).engine(0).rowid());
assertEquals("partid not equal 0", 0, config.dataset(0).engine(0).partid());
assertTrue("Not configured with correct search node", config.dataset(0).engine(0).name_and_port().contains("search.node1"));
// Load Balance row 1
assertEquals("rowid not equal to 1", 1, config.dataset(0).engine(1).rowid());
assertEquals("partid no equal to 0", 0, config.dataset(0).engine(1).partid());
assertTrue("Not configured with correct search node", config.dataset(0).engine(1).name_and_port().contains("search.node2"));
// First container with a local search node
builder = new PartitionsConfig.Builder();
new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.0.tld.0");
config = new PartitionsConfig(builder);
assertEquals(1, config.dataset().size());
assertEquals(1, config.dataset(0).engine().size());
assertEquals(0, config.dataset(0).engine(0).rowid());
assertEquals(0, config.dataset(0).engine(0).partid());
assertTrue("Not configured with local search node as engine", config.dataset(0).engine(0).name_and_port().contains("search.node1"));
// Second container with a local search node
builder = new PartitionsConfig.Builder();
new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.1.tld.1");
config = new PartitionsConfig(builder);
assertEquals(1, config.dataset().size());
assertEquals(1, config.dataset(0).engine().size());
assertEquals(0, config.dataset(0).engine(0).rowid());
assertEquals(0, config.dataset(0).engine(0).partid());
assertTrue("Not configured with local search node as engine", config.dataset(0).engine(0).name_and_port().contains("search.node2"));
}
Aggregations