Search in sources :

Example 46 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class SearchBuilderTest method cluster_is_connected_to_search_clusters.

@Test
public void cluster_is_connected_to_search_clusters() throws Exception {
    String hosts = hostsXml();
    String services = "" + "<services>" + "  <admin version='2.0'>" + "    <adminserver hostalias='mockhost'/>" + "  </admin>" + "  <jdisc version='1.0' id='container'>" + "      <search>" + "        <chain id='mychain' inherits='vespa'/>" + "      </search>" + "      <nodes>" + "        <node hostalias=\"mockhost\" />" + "      </nodes>" + "  </jdisc>" + contentXml() + "</services>";
    VespaModel model = getVespaModelWithMusic(hosts, services);
    ContainerCluster cluster = model.getContainerClusters().get("container");
    assertFalse(cluster.getSearchChains().localProviders().isEmpty());
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 47 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class ClusterControllerTestCase method testUnconfigured.

@Test
public void testUnconfigured() throws Exception {
    String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<services>\n" + "\n" + "  <admin version=\"2.0\">\n" + "    <adminserver hostalias=\"configserver\" />\n" + "    <logserver hostalias=\"logserver\" />\n" + "    <slobroks>\n" + "      <slobrok hostalias=\"configserver\" />\n" + "      <slobrok hostalias=\"logserver\" />\n" + "    </slobroks>\n" + "  </admin>\n" + "  <content version='1.0' id='bar'>" + "     <redundancy>1</redundancy>\n" + "     <documents>" + "       <document type=\"type1\" mode=\"store-only\"/>\n" + "     </documents>\n" + "     <group>" + "       <node hostalias='node0' distribution-key='0' />" + "     </group>" + "    <tuning>" + "      <cluster-controller>\n" + "        <init-progress-time>34567</init-progress-time>" + "      </cluster-controller>" + "    </tuning>" + "   </content>" + "\n" + "</services>";
    VespaModel model = createVespaModel(xml);
    assertTrue(model.getService("admin/cluster-controllers/0").isPresent());
    assertTrue(existsHostsWithClusterControllerConfigId(model));
    assertGroupSize(model, "admin/cluster-controllers/0/components/clustercontroller-bar-configurer", 1);
    assertThat(model.getAdmin().getClusterControllers().getContainers().size(), is(1));
    FleetcontrollerConfig.Builder builder = new FleetcontrollerConfig.Builder();
    model.getConfig(builder, "admin/cluster-controllers/0/components/clustercontroller-bar-configurer");
    FleetcontrollerConfig cfg = new FleetcontrollerConfig(builder);
    assertThat(cfg.index(), is(0));
    assertThat(cfg.fleet_controller_count(), is(1));
    assertThat(cfg.init_progress_time(), is(34567000));
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) FleetcontrollerConfig(com.yahoo.vespa.config.content.FleetcontrollerConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 48 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class ClusterControllerTestCase method createVespaModel.

private VespaModel createVespaModel(String servicesXml) throws IOException, SAXException {
    VespaModel model = new VespaModel(new MockApplicationPackage.Builder().withServices(servicesXml).withSearchDefinitions(sds).build());
    SimpleApplicationValidator.checkServices(new StringReader(servicesXml), new Version(6));
    return model;
}
Also used : Version(com.yahoo.component.Version) VespaModel(com.yahoo.vespa.model.VespaModel) StringReader(java.io.StringReader)

Example 49 with VespaModel

use of com.yahoo.vespa.model.VespaModel 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 50 with VespaModel

use of com.yahoo.vespa.model.VespaModel in project vespa by vespa-engine.

the class ClusterSizeReductionValidatorTest method testSizeReductionValidation.

@Test
public void testSizeReductionValidation() throws IOException, SAXException {
    ValidationTester tester = new ValidationTester(30);
    VespaModel previous = tester.deploy(null, getServices(30), null).getFirst();
    try {
        tester.deploy(previous, getServices(14), null);
        fail("Expected exception due to cluster size reduction");
    } catch (IllegalArgumentException expected) {
        assertEquals("cluster-size-reduction: Size reduction in 'default' is too large. Current size: 30, new size: 14. New size must be at least 50% of the current size", Exceptions.toMessageString(expected));
    }
}
Also used : VespaModel(com.yahoo.vespa.model.VespaModel) ValidationTester(com.yahoo.vespa.model.application.validation.ValidationTester) Test(org.junit.Test)

Aggregations

VespaModel (com.yahoo.vespa.model.VespaModel)153 Test (org.junit.Test)135 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)35 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)26 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)22 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)21 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)18 DeployState (com.yahoo.config.model.deploy.DeployState)18 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)15 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)14 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)13 Matchers.containsString (org.hamcrest.Matchers.containsString)12 File (java.io.File)8 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)6 ValidationTester (com.yahoo.vespa.model.application.validation.ValidationTester)6 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)6 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)5 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)5 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)5 HostResource (com.yahoo.vespa.model.HostResource)5