Search in sources :

Example 21 with ConfigDefinitionKey

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

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

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

the class ApplicationDeployTest method testConfigDefinitionsFromJars.

@Test
public void testConfigDefinitionsFromJars() throws IOException {
    String appName = "src/test/cfg//application/app1";
    FilesApplicationPackage app = FilesApplicationPackage.fromFile(new File(appName), false);
    Map<ConfigDefinitionKey, UnparsedConfigDefinition> defs = app.getAllExistingConfigDefs();
    assertThat(defs.size(), is(5));
}
Also used : UnparsedConfigDefinition(com.yahoo.config.application.api.UnparsedConfigDefinition) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JarFile(java.util.jar.JarFile) File(java.io.File) Test(org.junit.Test)

Example 24 with ConfigDefinitionKey

use of com.yahoo.vespa.config.ConfigDefinitionKey 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)

Example 25 with ConfigDefinitionKey

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

the class DomConfigPayloadBuilderTest method testNameParsing.

@Test
public void testNameParsing() throws FileNotFoundException, ParserConfigurationException {
    Element configRoot = getDocument(new StringReader("<config name=\"function-test\" version=\"1\" namespace=\"config\">" + "<int_val>1</int_val> +" + "</config>"));
    ConfigDefinitionKey key = DomConfigPayloadBuilder.parseConfigName(configRoot);
    assertThat(key.getName(), is("function-test"));
    assertThat(key.getNamespace(), is("config"));
    configRoot = getDocument(new StringReader("<config name=\"function_test\" version=\"1\">" + "<int_val>1</int_val> +" + "</config>"));
    key = DomConfigPayloadBuilder.parseConfigName(configRoot);
    assertThat(key.getName(), is("function_test"));
    assertThat(key.getNamespace(), is("config"));
    // Both namespace and name in name attribute
    configRoot = getDocument(new StringReader("<config name=\"config.function-test\" version=\"1\">" + "<int_val>1</int_val> +" + "</config>"));
    key = DomConfigPayloadBuilder.parseConfigName(configRoot);
    assertThat(key.getName(), is("function-test"));
    assertThat(key.getNamespace(), is("config"));
}
Also used : Element(org.w3c.dom.Element) ConfigDefinitionKey(com.yahoo.vespa.config.ConfigDefinitionKey) Test(org.junit.Test)

Aggregations

ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)28 Test (org.junit.Test)15 File (java.io.File)7 UnparsedConfigDefinition (com.yahoo.config.application.api.UnparsedConfigDefinition)6 UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)5 ConfigDefinition (com.yahoo.vespa.config.ConfigDefinition)5 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)4 JarFile (java.util.jar.JarFile)4 Element (org.w3c.dom.Element)4 DefParser (com.yahoo.config.codegen.DefParser)3 ConfigPayloadBuilder (com.yahoo.vespa.config.ConfigPayloadBuilder)3 ConfigDefinition (com.yahoo.vespa.config.buildergen.ConfigDefinition)3 LinkedHashMap (java.util.LinkedHashMap)3 ConfigInstance (com.yahoo.config.ConfigInstance)2 ApplicationFile (com.yahoo.config.application.api.ApplicationFile)2 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 GenericConfig (com.yahoo.vespa.config.GenericConfig)2 VespaModel (com.yahoo.vespa.model.VespaModel)2