Search in sources :

Example 6 with CoreConfigParser

use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.

the class CoreConfigTest method minimal_config_with_absolute_paths_is_read.

@Test
public void minimal_config_with_absolute_paths_is_read() {
    Path configMinimalAbsPaths = Util.getTypedbDir().resolve("server/test/config/config-minimal-abs-path.yml");
    CoreConfig config = CoreConfigFactory.config(configMinimalAbsPaths, new HashSet<>(), new CoreConfigParser());
    assertTrue(config.storage().dataDir().isAbsolute());
    assertEquals(new InetSocketAddress("0.0.0.0", 1730), config.server().address());
    assertEquals(200 * Bytes.MB, config.storage().databaseCache().dataSize());
    assertEquals(700 * Bytes.MB, config.storage().databaseCache().indexSize());
    assertFalse(config.vaticleFactory().enable());
    assertTrue(config.log().output().outputs().containsKey("stdout"));
    assertTrue(config.log().output().outputs().containsKey("file"));
    assertTrue(config.log().output().outputs().get("file").asFile().path().isAbsolute());
    assertEquals(50 * Bytes.MB, config.log().output().outputs().get("file").asFile().fileSizeCap());
    assertEquals(1 * Bytes.GB, config.log().output().outputs().get("file").asFile().archivesSizeCap());
    assertNotNull(config.log().logger().defaultLogger());
    assertFalse(config.log().logger().defaultLogger().outputs().isEmpty());
    assertEquals("warn", config.log().logger().defaultLogger().level());
    assertFalse(config.log().debugger().reasoner().isEnabled());
}
Also used : Path(java.nio.file.Path) CoreConfig(com.vaticle.typedb.core.server.parameters.CoreConfig) InetSocketAddress(java.net.InetSocketAddress) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Example 7 with CoreConfigParser

use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.

the class CoreConfigTest method config_file_is_read.

@Test
public void config_file_is_read() {
    CoreConfig config = CoreConfigFactory.config(new CoreConfigParser());
    assertTrue(config.storage().dataDir().toString().endsWith("server/data"));
    assertEquals(new InetSocketAddress("0.0.0.0", 1729), config.server().address());
    assertEquals(500 * Bytes.MB, config.storage().databaseCache().dataSize());
    assertEquals(500 * Bytes.MB, config.storage().databaseCache().indexSize());
    assertFalse(config.vaticleFactory().enable());
    assertTrue(config.log().output().outputs().containsKey("stdout"));
    assertTrue(config.log().output().outputs().containsKey("file"));
    assertTrue(config.log().output().outputs().get("file").asFile().path().toString().endsWith("server/logs"));
    assertEquals(50 * Bytes.MB, config.log().output().outputs().get("file").asFile().fileSizeCap());
    assertEquals(1 * Bytes.GB, config.log().output().outputs().get("file").asFile().archivesSizeCap());
    assertNotNull(config.log().logger().defaultLogger());
    assertFalse(config.log().logger().defaultLogger().outputs().isEmpty());
    assertEquals("warn", config.log().logger().defaultLogger().level());
    assertFalse(config.log().debugger().reasoner().isEnabled());
}
Also used : CoreConfig(com.vaticle.typedb.core.server.parameters.CoreConfig) InetSocketAddress(java.net.InetSocketAddress) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Example 8 with CoreConfigParser

use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.

the class CoreConfigTest method config_file_accepts_overrides.

@Test
public void config_file_accepts_overrides() {
    CoreConfig config = CoreConfigFactory.config(set(new Option("storage.data", "server/alt-data"), new Option("server.address", "0.0.0.0:1730"), new Option("log.output.file.directory", "server/alt-logs"), new Option("log.logger.default.level", "info"), new Option("log.logger.typedb.output", "[file]")), new CoreConfigParser());
    assertTrue(config.storage().dataDir().toString().endsWith("server/alt-data"));
    assertEquals(new InetSocketAddress("0.0.0.0", 1730), config.server().address());
    assertFalse(config.vaticleFactory().enable());
    assertTrue(config.log().output().outputs().containsKey("stdout"));
    assertTrue(config.log().output().outputs().containsKey("file"));
    assertTrue(config.log().output().outputs().get("file").asFile().path().toString().endsWith("server/alt-logs"));
    assertEquals(50 * Bytes.MB, config.log().output().outputs().get("file").asFile().fileSizeCap());
    assertEquals(1 * Bytes.GB, config.log().output().outputs().get("file").asFile().archivesSizeCap());
    assertNotNull(config.log().logger().defaultLogger());
    assertFalse(config.log().logger().defaultLogger().outputs().isEmpty());
    assertEquals("info", config.log().logger().defaultLogger().level());
    assertEquals(list("file"), config.log().logger().filteredLoggers().get("typedb").outputs());
    assertFalse(config.log().debugger().reasoner().isEnabled());
}
Also used : CoreConfig(com.vaticle.typedb.core.server.parameters.CoreConfig) InetSocketAddress(java.net.InetSocketAddress) Option(com.vaticle.typedb.core.server.parameters.util.Option) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Example 9 with CoreConfigParser

use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.

the class CoreConfigTest method config_file_wrong_path_type_throws.

@Test
public void config_file_wrong_path_type_throws() {
    Path configInvalidPathType = Util.getTypedbDir().resolve("server/test/config/config-wrong-path-type.yml");
    try {
        CoreConfigFactory.config(configInvalidPathType, new HashSet<>(), new CoreConfigParser());
        fail();
    } catch (TypeDBException e) {
        assert e.code().isPresent();
        assertEquals(CONFIG_UNEXPECTED_VALUE.code(), e.code().get());
        assertEquals(CONFIG_UNEXPECTED_VALUE.message("storage.data", "123456[int]", YAMLParser.Value.Primitive.PATH.help()), e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Example 10 with CoreConfigParser

use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.

the class CoreConfigTest method config_file_unrecognised_option.

@Test
public void config_file_unrecognised_option() {
    Path configUnrecognisedOption = Util.getTypedbDir().resolve("server/test/config/config-unrecognised-option.yml");
    try {
        CoreConfigFactory.config(configUnrecognisedOption, new HashSet<>(), new CoreConfigParser());
        fail();
    } catch (TypeDBException e) {
        assert e.code().isPresent();
        assertEquals(UNRECOGNISED_CONFIGURATION_OPTIONS.code(), e.code().get());
        assertEquals(UNRECOGNISED_CONFIGURATION_OPTIONS.message(list("log.custom-logger-invalid")), e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) TypeDBException(com.vaticle.typedb.core.common.exception.TypeDBException) CoreConfigParser(com.vaticle.typedb.core.server.parameters.CoreConfigParser) Test(org.junit.Test)

Aggregations

CoreConfigParser (com.vaticle.typedb.core.server.parameters.CoreConfigParser)11 Test (org.junit.Test)10 TypeDBException (com.vaticle.typedb.core.common.exception.TypeDBException)7 Path (java.nio.file.Path)7 CoreConfig (com.vaticle.typedb.core.server.parameters.CoreConfig)4 InetSocketAddress (java.net.InetSocketAddress)3 Option (com.vaticle.typedb.core.server.parameters.util.Option)2 ServerSubcommand (com.vaticle.typedb.core.server.parameters.ServerSubcommand)1 ServerSubcommandParser (com.vaticle.typedb.core.server.parameters.ServerSubcommandParser)1 IOException (java.io.IOException)1 BindException (java.net.BindException)1