Search in sources :

Example 26 with ApplicationPackage

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"));
}
Also used : ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) LinkedHashMap(java.util.LinkedHashMap) ConfigDefinition(com.yahoo.vespa.config.ConfigDefinition) File(java.io.File) Test(org.junit.Test)

Example 27 with ApplicationPackage

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));
}
Also used : ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) FilesApplicationPackage(com.yahoo.config.model.application.provider.FilesApplicationPackage) LinkedHashMap(java.util.LinkedHashMap) ConfigDefinition(com.yahoo.vespa.config.ConfigDefinition) File(java.io.File) Test(org.junit.Test)

Example 28 with ApplicationPackage

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;
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) Zone(com.yahoo.config.provision.Zone) DeployProperties(com.yahoo.config.model.deploy.DeployProperties) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage)

Example 29 with ApplicationPackage

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());
}
Also used : Element(org.w3c.dom.Element) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) IdentityConfig(com.yahoo.container.core.identity.IdentityConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 30 with ApplicationPackage

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"));
}
Also used : Container(com.yahoo.vespa.model.container.Container) Element(org.w3c.dom.Element) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Aggregations

ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)39 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)25 Test (org.junit.Test)21 VespaModel (com.yahoo.vespa.model.VespaModel)14 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)13 DeployState (com.yahoo.config.model.deploy.DeployState)12 File (java.io.File)11 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)10 DeployProperties (com.yahoo.config.model.deploy.DeployProperties)8 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)7 InMemoryProvisioner (com.yahoo.config.model.provision.InMemoryProvisioner)6 Matchers.containsString (org.hamcrest.Matchers.containsString)5 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)4 TestDriver (com.yahoo.config.model.test.TestDriver)3 Path (com.yahoo.path.Path)3 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 MockRoot (com.yahoo.config.model.test.MockRoot)2 Zone (com.yahoo.config.provision.Zone)2 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)2 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)2