Search in sources :

Example 11 with MockRoot

use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.

the class ConfigValueChangeValidatorTest method requireThatAnnotationDoesNotHaveEmtpyConfigList.

@Test(expected = IllegalStateException.class)
public void requireThatAnnotationDoesNotHaveEmtpyConfigList() {
    MockRoot root = createRootWithChildren(new EmptyConfigListAnnotationService(""));
    getConfigChanges(root, root);
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) Test(org.junit.Test)

Example 12 with MockRoot

use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.

the class ConfigValueChangeValidatorTest method requireThatConfigsFromAnnotatedSuperClassesAreDetected.

@Test
public void requireThatConfigsFromAnnotatedSuperClassesAreDetected() {
    MockRoot oldRoot = createRootWithChildren(new SimpleConfigProducer("p", 1).withChildren(new ChildServiceWithAnnotation("child1", 0), new ChildServiceWithoutAnnotation("child2", 0)));
    MockRoot newRoot = createRootWithChildren(new SimpleConfigProducer("p", 2).withChildren(new ChildServiceWithAnnotation("child1", 0), new ChildServiceWithoutAnnotation("child2", 0)));
    List<ConfigChangeAction> changes = getConfigChanges(oldRoot, newRoot);
    assertEquals(2, changes.size());
    assertComponentsEquals(changes, "p/child1", 0);
    assertComponentsEquals(changes, "p/child2", 1);
    assertEmptyLog();
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) ConfigChangeAction(com.yahoo.config.model.api.ConfigChangeAction) Test(org.junit.Test)

Example 13 with MockRoot

use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.

the class ConfigValueChangeValidatorTest method createRootWithChildren.

private static MockRoot createRootWithChildren(AbstractConfigProducer<?>... children) {
    MockRoot root = new MockRoot();
    Arrays.asList(children).forEach(root::addChild);
    root.freezeModelTopology();
    return root;
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot)

Example 14 with MockRoot

use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.

the class MultilevelDispatchTest method createCluster.

private ContentCluster createCluster(String dispatchXml) throws Exception {
    String[] hosts = { "mh0", "mh1", "mh2", "mh3", "mh4", "mh5" };
    MockRoot root = ContentClusterUtils.createMockRoot(hosts);
    ContentCluster cluster = ContentClusterUtils.createCluster(createClusterXml(getGroupXml(), Optional.of(dispatchXml), 1, 1), root);
    AbstractConfigProducer<Dispatch> dispatchParent = new SimpleConfigProducer<>(root, "tlds");
    HostResource hostResource = new HostResource(new Host(root, "mockhost"));
    IndexedSearchCluster index = cluster.getSearch().getIndexed();
    index.addTld(dispatchParent, hostResource);
    index.setupDispatchGroups();
    root.freezeModelTopology();
    cluster.validate();
    return cluster;
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) MockRoot(com.yahoo.config.model.test.MockRoot) SimpleConfigProducer(com.yahoo.vespa.model.SimpleConfigProducer) Host(com.yahoo.vespa.model.Host) Matchers.containsString(org.hamcrest.Matchers.containsString) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster)

Example 15 with MockRoot

use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.

the class StorageClusterTest method requireThatUserDoesNotSpecifyBothGroupAndNodes.

@Test
public void requireThatUserDoesNotSpecifyBothGroupAndNodes() throws Exception {
    String xml = "<cluster id=\"storage\">\n" + "<documents/>\n" + "<engine>\n" + "    <fail-partition-on-error>true</fail-partition-on-error>\n" + "    <revert-time>34m</revert-time>\n" + "    <recovery-time>5d</recovery-time>\n" + "</engine>" + "  <group>\n" + "    <node distribution-key=\"0\" hostalias=\"mockhost\"/>\n" + "  </group>\n" + "  <nodes>\n" + "    <node distribution-key=\"1\" hostalias=\"mockhost\"/>\n" + "  </nodes>\n" + "</cluster>";
    try {
        final MockRoot root = new MockRoot();
        root.getDeployState().getDocumentModel().getDocumentManager().add(new NewDocumentType(new NewDocumentType.Name("music")));
        ContentClusterUtils.createCluster(xml, root);
        fail("Did not fail when having both group and nodes");
    } catch (RuntimeException e) {
        e.printStackTrace();
        assertEquals("Both group and nodes exists, only one of these tags is legal", e.getMessage());
    }
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Aggregations

MockRoot (com.yahoo.config.model.test.MockRoot)43 Test (org.junit.Test)29 ConfigChangeAction (com.yahoo.config.model.api.ConfigChangeAction)7 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)7 DeployState (com.yahoo.config.model.deploy.DeployState)6 Host (com.yahoo.vespa.model.Host)4 HostResource (com.yahoo.vespa.model.HostResource)4 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)3 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)3 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)3 Zone (com.yahoo.config.provision.Zone)3 NodeSpec (com.yahoo.vespa.model.search.NodeSpec)3 SearchNode (com.yahoo.vespa.model.search.SearchNode)3 Before (org.junit.Before)3 ConfigserverConfig (com.yahoo.cloud.config.ConfigserverConfig)2 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)2 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)2 StorServerConfig (com.yahoo.vespa.config.content.core.StorServerConfig)2 ContainerSearch (com.yahoo.vespa.model.container.search.ContainerSearch)2 SearchChains (com.yahoo.vespa.model.container.search.searchchain.SearchChains)2