Search in sources :

Example 21 with MockRoot

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

the class FileSenderTest method setup.

@Before
public void setup() {
    MockRoot root = new MockRoot();
    producer = new SimpleConfigProducer<>(root, "test");
    service = new TestService(root, "service");
    serviceList = new ArrayList<>();
    serviceList.add(service);
    ConfigDefinitionKey key = new ConfigDefinitionKey("myname", "mynamespace");
    def = new ConfigDefinition("myname", "1", "mynamespace");
    builder = new ConfigPayloadBuilder(def);
    Map<ConfigDefinitionKey, ConfigPayloadBuilder> builderMap = new HashMap<>();
    builderMap.put(key, builder);
    UserConfigRepo testRepo = new UserConfigRepo(builderMap);
    producer.setUserConfigs(testRepo);
}
Also used : UserConfigRepo(com.yahoo.config.model.producer.UserConfigRepo) MockRoot(com.yahoo.config.model.test.MockRoot) HashMap(java.util.HashMap) Before(org.junit.Before)

Example 22 with MockRoot

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

the class ModelGraphTest method require_that_instance_can_be_created.

@Test
public void require_that_instance_can_be_created() {
    ModelGraph graph = new ModelGraphBuilder().addBuilder(new GraphMock.BC()).addBuilder(new GraphMock.BB()).addBuilder(new GraphMock.BA()).build();
    List<ModelNode> nodes = graph.topologicalSort();
    MockRoot root = new MockRoot();
    GraphMock.A a = (GraphMock.A) nodes.get(0).createModel(ConfigModelContext.create(null, root, "first"));
    GraphMock.B b = (GraphMock.B) nodes.get(1).createModel(ConfigModelContext.create(null, root, "second"));
    GraphMock.B b2 = (GraphMock.B) nodes.get(1).createModel(ConfigModelContext.create(null, root, "second2"));
    GraphMock.C c = (GraphMock.C) nodes.get(2).createModel(ConfigModelContext.create(null, root, "third"));
    assertNotNull(a);
    assertNotNull(b);
    assertNotNull(b2);
    assertNotNull(c);
    assertThat(a.getId(), is("first"));
    assertThat(b.getId(), is("second"));
    assertThat(b2.getId(), is("second2"));
    assertThat(c.getId(), is("third"));
    assertThat(b.a, is(a));
    assertNotNull(c.b);
    assertThat(c.b.size(), is(2));
    assertTrue(c.b.contains(b));
    assertTrue(c.b.contains(b2));
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) Test(org.junit.Test)

Example 23 with MockRoot

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

the class DomSearchChainsBuilderTest method referToFederationAsSearcher.

@Test
public void referToFederationAsSearcher() {
    final Element element = parse("<searchchains>", "  <federation id='federationSearcher'>", "    <source id='mysource'>", "      <federationoptions optional='false' />", "    </source>", "  </federation>", "  <searchchain id='default'>", "    <searcher id='federationSearcher'/>", "  </searchchain>", "</searchchains>");
    try {
        new DomSearchChainsBuilder().build(new MockRoot(), element);
        fail("Expected exception when referring to an outer 'federation' as a 'searcher'.");
    } catch (RuntimeException e) {
        assertThat(e.getMessage(), containsString("Two different types declared for the component with name 'federationSearcher'"));
    }
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) Element(org.w3c.dom.Element) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 24 with MockRoot

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

the class ConfigValueChangeValidatorTest method requireThatValidatorHandlesModelsWithDifferentTopology.

@Test
public void requireThatValidatorHandlesModelsWithDifferentTopology() {
    MockRoot oldRoot = createRootWithChildren(new SimpleConfigProducer("p1", 0).withChildren(new ServiceWithAnnotation("s1", 1)), new SimpleConfigProducer("p2", 0).withChildren(new ServiceWithAnnotation("s2", 1)));
    MockRoot newRoot = createRootWithChildren(new ServiceWithAnnotation("s1", 2), new ServiceWithAnnotation("s2", 2), new ServiceWithAnnotation("s3", 2));
    List<ConfigChangeAction> changes = getConfigChanges(oldRoot, newRoot);
    assertTrue(changes.isEmpty());
    assertEmptyLog();
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) ConfigChangeAction(com.yahoo.config.model.api.ConfigChangeAction) Test(org.junit.Test)

Example 25 with MockRoot

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

the class ConfigValueChangeValidatorTest method requireThatServicesAnnotatedWithNonRestartConfigProduceWarningInLog.

@Test
public void requireThatServicesAnnotatedWithNonRestartConfigProduceWarningInLog() {
    MockRoot root = createRootWithChildren(new NonRestartConfigAnnotatedService(""));
    getConfigChanges(root, root);
    assertEquals(1, logger.entries.size());
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) 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