use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class DeployStateTest method testGetConfigDefinition.
@Test
public void testGetConfigDefinition() {
Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs = new LinkedHashMap<>();
defs.put(new ConfigDefinitionKey("test2", "a.b"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test2", new String[] { "namespace=a.b", "doubleVal double default=1.0" }));
// defs.put(new ConfigDefinitionKey("test2", "c.d"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test2", new String[]{"namespace=c.d", "doubleVal double default=1.0"}));
defs.put(new ConfigDefinitionKey("test3", "xyzzy"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("test3", new String[] { "namespace=xyzzy", "message string" }));
ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/cfg//application/app1"));
DeployState state = createDeployState(app, defs);
assertNotNull(state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b")));
ConfigDefinition test1 = state.getConfigDefinition(new ConfigDefinitionKey("test2", "a.b")).get();
assertNotNull(test1);
assertThat(test1.getName(), is("test2"));
assertThat(test1.getNamespace(), is("a.b"));
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class DeployStateTest method testDefinitionRepoIsUsed.
@Test
public void testDefinitionRepoIsUsed() {
Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs = new LinkedHashMap<>();
defs.put(new ConfigDefinitionKey("foo", "bar"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("foo", new String[] { "namespace=bar", "foo int default=0" }));
defs.put(new ConfigDefinitionKey("test2", "a.b"), new com.yahoo.vespa.config.buildergen.ConfigDefinition("namespace-in-filename", new String[] { "namespace=a.b", "doubleVal double default=1.0" }));
ApplicationPackage app = FilesApplicationPackage.fromFile(new File("src/test/cfg//application/app1"));
DeployState state = createDeployState(app, defs);
assertNotNull(state.getConfigDefinition(new ConfigDefinitionKey("foo", "bar")));
ConfigDefinition overridden = state.getConfigDefinition(new ConfigDefinitionKey("namespace-in-filename", "a.b")).get();
assertNotNull(overridden);
Double defaultValue = overridden.getDoubleDefs().get("doubleVal").getDefVal();
assertNotNull(defaultValue);
assertThat(defaultValue.intValue(), is(0));
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class AccessControlValidatorTest method deployState.
private static DeployState deployState(String servicesXml) {
ApplicationPackage app = new MockApplicationPackage.Builder().withServices(servicesXml).build();
DeployState.Builder builder = new DeployState.Builder().applicationPackage(app).zone(// TODO: remove cd setting
new Zone(SystemName.cd, Environment.prod, RegionName.from("foo"))).properties(new DeployProperties.Builder().hostedVespa(true).build());
final DeployState deployState = builder.build(true);
assertTrue("Test must emulate a hosted deployment.", deployState.isHosted());
assertEquals("Test must emulate a prod environment.", prod, deployState.zone().environment());
return deployState;
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class IdentityBuilderTest method identity_config_produced_from_deployment_spec.
@Test
public void identity_config_produced_from_deployment_spec() throws IOException, SAXException {
Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0'><search /></jdisc>");
String deploymentXml = "<deployment version='1.0' athenz-domain='domain' athenz-service='service'>\n" + " <test/>\n" + " <prod>\n" + " <region active='true'>default</region>\n" + " </prod>\n" + "</deployment>\n";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withDeploymentSpec(deploymentXml).build();
createModel(root, DeployState.createTestState(applicationPackage), clusterElem);
IdentityConfig identityConfig = root.getConfig(IdentityConfig.class, "default/component/" + IdentityProvider.CLASS);
assertEquals("domain", identityConfig.domain());
assertEquals("service", identityConfig.service());
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class RoutingBuilderTest method setsRotationActiveAccordingToDeploymentSpec.
@Test
public void setsRotationActiveAccordingToDeploymentSpec() throws IOException, SAXException {
Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0'><search /></jdisc>");
String deploymentSpec = "<deployment>\n" + " <prod> \n" + " <region active='true'>us-north-1</region>\n" + " <parallel>\n" + " <region active='false'>us-north-2</region>\n" + " <region active='true'>us-north-3</region>\n" + " </parallel>\n" + " <region active='false'>us-north-4</region>\n" + " </prod>\n" + "</deployment>";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withDeploymentSpec(deploymentSpec).build();
// root = new MockRoot("root", applicationPackage);
for (String region : Arrays.asList("us-north-1", "us-north-3")) {
Container container = getContainer(applicationPackage, region, clusterElem);
assertEquals("Region " + region + " is active", "true", container.getServicePropertyString("activeRotation"));
}
for (String region : Arrays.asList("us-north-2", "us-north-4")) {
Container container = getContainer(applicationPackage, region, clusterElem);
assertEquals("Region " + region + " is inactive", "false", container.getServicePropertyString("activeRotation"));
}
Container container = getContainer(applicationPackage, "unknown", clusterElem);
assertEquals("Unknown region is inactive", "false", container.getServicePropertyString("activeRotation"));
}
Aggregations