Search in sources :

Example 26 with MockRoot

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

the class ConfigModelContextTest method testConfigModelContext.

@Test
public void testConfigModelContext() {
    AbstractConfigProducer root = new MockRoot();
    String id = "foobar";
    ApplicationPackage pkg = new MockApplicationPackage.Builder().withServices("<services version=\"1.0\"><admin version=\"2.0\" /></services>").build();
    DeployState deployState = DeployState.createTestState(pkg);
    DeployLogger logger = deployState.getDeployLogger();
    ConfigModelContext ctx = ConfigModelContext.create(deployState, null, root, id);
    assertThat(ctx.getApplicationPackage(), is(pkg));
    assertThat(ctx.getProducerId(), is(id));
    assertThat(ctx.getParentProducer(), is(root));
    assertThat(ctx.getDeployLogger(), is(logger));
    ctx = ConfigModelContext.create(null, root, id);
    assertThat(ctx.getProducerId(), is(id));
    assertThat(ctx.getParentProducer(), is(root));
    AbstractConfigProducer newRoot = new MockRoot("bar");
    ctx = ctx.withParent(newRoot);
    assertThat(ctx.getProducerId(), is(id));
    assertThat(ctx.getParentProducer(), is(not(root)));
    assertThat(ctx.getParentProducer(), is(newRoot));
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) DeployState(com.yahoo.config.model.deploy.DeployState) AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) DeployLogger(com.yahoo.config.application.api.DeployLogger) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test)

Example 27 with MockRoot

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

the class LegacyConfigModelBuilderTest method testThatProducerIsInserted.

@Test
public void testThatProducerIsInserted() {
    String services = "<foo><config name=\"bar\"><key>value</key></config></foo>";
    ModelBuilder builder = new ModelBuilder();
    Model model = builder.build(DeployState.createTestState(new MockApplicationPackage.Builder().withServices(services).build()), null, new MockRoot(), XML.getDocument(services).getDocumentElement());
    assertThat(model.getContext().getParentProducer().getUserConfigs().size(), is(1));
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) ConfigModel(com.yahoo.config.model.ConfigModel) Test(org.junit.Test)

Example 28 with MockRoot

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

the class ContainerClusterTest method requireThatRoutingProviderIsDisabledForNonHosted.

@Test
public void requireThatRoutingProviderIsDisabledForNonHosted() {
    DeployState state = new DeployState.Builder().properties(new DeployProperties.Builder().hostedVespa(false).build()).build(true);
    MockRoot root = new MockRoot("foo", state);
    ContainerCluster cluster = new ContainerCluster(root, "container0", "container1");
    RoutingProviderConfig.Builder builder = new RoutingProviderConfig.Builder();
    cluster.getConfig(builder);
    RoutingProviderConfig config = new RoutingProviderConfig(builder);
    assertFalse(config.enabled());
    assertEquals(0, cluster.getAllComponents().stream().map(c -> c.getClassId().getName()).filter(c -> c.equals("com.yahoo.jdisc.http.filter.security.RoutingConfigProvider")).count());
}
Also used : QrStartConfig(com.yahoo.search.config.QrStartConfig) ClusterControllerContainer(com.yahoo.vespa.model.admin.clustercontroller.ClusterControllerContainer) MetricDefaultsConfig(com.yahoo.container.jdisc.config.MetricDefaultsConfig) ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) RegionName(com.yahoo.config.provision.RegionName) DeployState(com.yahoo.config.model.deploy.DeployState) MockRoot(com.yahoo.config.model.test.MockRoot) HostResource(com.yahoo.vespa.model.HostResource) ClusterInfoConfig(com.yahoo.cloud.config.ClusterInfoConfig) ContainerSearch(com.yahoo.vespa.model.container.search.ContainerSearch) Host(com.yahoo.vespa.model.Host) ThreadpoolConfig(com.yahoo.container.handler.ThreadpoolConfig) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) Component(com.yahoo.vespa.model.container.component.Component) Iterator(java.util.Iterator) ContainerDocproc(com.yahoo.vespa.model.container.docproc.ContainerDocproc) Environment(com.yahoo.config.provision.Environment) Collection(java.util.Collection) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Assert.assertFalse(org.junit.Assert.assertFalse) Zone(com.yahoo.config.provision.Zone) SystemName(com.yahoo.config.provision.SystemName) Optional(java.util.Optional) SearchChains(com.yahoo.vespa.model.container.search.searchchain.SearchChains) ClusterControllerClusterVerifier(com.yahoo.vespa.model.admin.clustercontroller.ClusterControllerClusterVerifier) RoutingProviderConfig(com.yahoo.cloud.config.RoutingProviderConfig) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) Assert.assertEquals(org.junit.Assert.assertEquals) RoutingProviderConfig(com.yahoo.cloud.config.RoutingProviderConfig) DeployState(com.yahoo.config.model.deploy.DeployState) MockRoot(com.yahoo.config.model.test.MockRoot) Test(org.junit.Test)

Example 29 with MockRoot

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

the class ContainerClusterTest method requreThatWeCanGetTheZoneConfig.

@Test
public void requreThatWeCanGetTheZoneConfig() {
    DeployState state = new DeployState.Builder().properties(new DeployProperties.Builder().hostedVespa(true).build()).zone(new Zone(SystemName.cd, Environment.test, RegionName.from("some-region"))).build(true);
    MockRoot root = new MockRoot("foo", state);
    ContainerCluster cluster = new ContainerCluster(root, "container0", "container1");
    ConfigserverConfig.Builder builder = new ConfigserverConfig.Builder();
    cluster.getConfig(builder);
    ConfigserverConfig config = new ConfigserverConfig(builder);
    assertEquals(Environment.test.value(), config.environment());
    assertEquals("some-region", config.region());
    assertEquals("cd", config.system());
}
Also used : ConfigserverConfig(com.yahoo.cloud.config.ConfigserverConfig) DeployState(com.yahoo.config.model.deploy.DeployState) MockRoot(com.yahoo.config.model.test.MockRoot) Zone(com.yahoo.config.provision.Zone) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) Test(org.junit.Test)

Example 30 with MockRoot

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

the class ConfigserverClusterTest method setupCluster.

@Before
public void setupCluster() {
    String services = "<jdisc id='standalone' version='1.0'>" + "  <http>" + "    <server port='1337' id='configserver' />" + "  </http>" + "</jdisc>";
    root = new MockRoot();
    new ConfigServerContainerModelBuilder(new TestOptions().rpcPort(12345).useVespaVersionInRequest(true).hostedVespa(true).environment("test").region("bar").numParallelTenantLoaders(99)).build(new DeployState.Builder().build(true), null, root, XML.getDocument(services).getDocumentElement());
    root.freezeModelTopology();
}
Also used : ConfigServerContainerModelBuilder(com.yahoo.vespa.model.container.xml.ConfigServerContainerModelBuilder) MockRoot(com.yahoo.config.model.test.MockRoot) ConfigServerContainerModelBuilder(com.yahoo.vespa.model.container.xml.ConfigServerContainerModelBuilder) Before(org.junit.Before)

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