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));
}
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));
}
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());
}
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());
}
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();
}
Aggregations