Search in sources :

Example 6 with ConfigDefinition

use of com.yahoo.vespa.config.ConfigDefinition 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 7 with ConfigDefinition

use of com.yahoo.vespa.config.ConfigDefinition in project vespa by vespa-engine.

the class ApplicationDeployTest method testConfigDefinitionsAndNamespaces.

/**
 * Tests that config definitions with namespace are treated properly when they have the format
 * as in the config definitions dir ($VESPA_HOME/share/vespa/configdefinitions on a machine
 * with Vespa packages installed) (does not test when read from user def files). Also tests a config
 * definition without version in file name
 */
@Test
public void testConfigDefinitionsAndNamespaces() {
    final File appDir = new File("src/test/cfg/application/configdeftest");
    FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir);
    DeployState deployState = new DeployState.Builder().applicationPackage(app).build(true);
    ConfigDefinition def = deployState.getConfigDefinition(new ConfigDefinitionKey("foo", CNode.DEFAULT_NAMESPACE)).get();
    assertThat(def.getNamespace(), is(CNode.DEFAULT_NAMESPACE));
    def = deployState.getConfigDefinition(new ConfigDefinitionKey("baz", "xyzzy")).get();
    assertThat(def.getNamespace(), is("xyzzy"));
    def = deployState.getConfigDefinition(new ConfigDefinitionKey("foo", "qux")).get();
    assertThat(def.getNamespace(), is("qux"));
    // A config def without version in filename and version in file header
    def = deployState.getConfigDefinition(new ConfigDefinitionKey("xyzzy", CNode.DEFAULT_NAMESPACE)).get();
    assertThat(def.getNamespace(), is(CNode.DEFAULT_NAMESPACE));
    assertThat(def.getName(), is("xyzzy"));
}
Also used : DeployState(com.yahoo.config.model.deploy.DeployState) UnparsedConfigDefinition(com.yahoo.config.application.api.UnparsedConfigDefinition) ConfigDefinition(com.yahoo.vespa.config.ConfigDefinition) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Aggregations

ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)7 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)5 UnparsedConfigDefinition (com.yahoo.config.application.api.UnparsedConfigDefinition)4 Test (org.junit.Test)4 DefParser (com.yahoo.config.codegen.DefParser)3 File (java.io.File)3 LinkedHashMap (java.util.LinkedHashMap)3 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 FilesApplicationPackage (com.yahoo.config.model.application.provider.FilesApplicationPackage)2 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 JarFile (java.util.jar.JarFile)2 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)1 DeployState (com.yahoo.config.model.deploy.DeployState)1 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)1 Element (org.w3c.dom.Element)1