Search in sources :

Example 6 with ApplicationPackage

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());
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) InMemoryProvisioner(com.yahoo.config.model.provision.InMemoryProvisioner) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 7 with ApplicationPackage

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));
}
Also used : MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) VespaModel(com.yahoo.vespa.model.VespaModel) Matchers.containsString(org.hamcrest.Matchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 8 with ApplicationPackage

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"));
    }
}
Also used : NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 9 with ApplicationPackage

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();
}
Also used : Content(com.yahoo.vespa.model.content.Content) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) TestDriver(com.yahoo.config.model.test.TestDriver)

Example 10 with ApplicationPackage

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"));
}
Also used : PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) TestDriver(com.yahoo.config.model.test.TestDriver) Test(org.junit.Test)

Aggregations

ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)39 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)14 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)13 DeployState (com.yahoo.config.model.deploy.DeployState)12 File (java.io.File)11 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)8 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)7 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)6 Matchers.containsString (org.hamcrest.Matchers.containsString)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 TestDriver (com.yahoo.config.model.test.TestDriver)3 Path (com.yahoo.path.Path)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 MockRoot (com.yahoo.config.model.test.MockRoot)2 Zone (com.yahoo.config.provision.Zone)2 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)2 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)2