Search in sources :

Example 46 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class ConsensusCommitConfigTest method constructor_AsyncExecutionRelatedPropertiesWithoutAsyncRollbackPropertyGiven_ShouldUseAsyncCommitValueForAsyncRollback.

@Test
public void constructor_AsyncExecutionRelatedPropertiesWithoutAsyncRollbackPropertyGiven_ShouldUseAsyncCommitValueForAsyncRollback() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.ASYNC_COMMIT_ENABLED, "true");
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.isAsyncCommitEnabled()).isEqualTo(true);
    // use the async commit value
    assertThat(config.isAsyncRollbackEnabled()).isEqualTo(true);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 47 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class ConsensusCommitConfigTest method constructor_PropertiesWithSerializableStrategyGiven_ShouldLoadProperly.

@Test
public void constructor_PropertiesWithSerializableStrategyGiven_ShouldLoadProperly() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.SERIALIZABLE_STRATEGY, SerializableStrategy.EXTRA_WRITE.toString());
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getSerializableStrategy()).isEqualTo(SerializableStrategy.EXTRA_WRITE);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 48 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class ConsensusCommitConfigTest method constructor_AsyncExecutionRelatedPropertiesGiven_ShouldLoadProperly.

@Test
public void constructor_AsyncExecutionRelatedPropertiesGiven_ShouldLoadProperly() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.ASYNC_COMMIT_ENABLED, "true");
    props.setProperty(ConsensusCommitConfig.ASYNC_ROLLBACK_ENABLED, "true");
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.isAsyncCommitEnabled()).isEqualTo(true);
    assertThat(config.isAsyncRollbackEnabled()).isEqualTo(true);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 49 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class SchemaLoaderIntegrationTestBase method beforeAll.

@BeforeAll
public void beforeAll() throws Exception {
    initialize();
    Properties properties = getProperties();
    namespace1 = getNamespace1();
    namespace2 = getNamespace2();
    writeConfigFile(properties);
    Map<String, Object> schemaJsonMap = getSchemaJsonMap();
    writeSchemaFile(schemaJsonMap);
    StorageFactory factory = StorageFactory.create(properties);
    admin = factory.getAdmin();
    consensusCommitAdmin = new ConsensusCommitAdmin(admin, new DatabaseConfig(properties));
}
Also used : StorageFactory(com.scalar.db.service.StorageFactory) ConsensusCommitAdmin(com.scalar.db.transaction.consensuscommit.ConsensusCommitAdmin) Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 50 with DatabaseConfig

use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.

the class CosmosSchemaLoaderWithStorageSpecificArgsIntegrationTest method getCommandArgsForCreationWithCoordinator.

@Override
protected List<String> getCommandArgsForCreationWithCoordinator(String configFile, String schemaFile) throws IOException {
    CosmosConfig config = new CosmosConfig(new DatabaseConfig(new File(configFile)));
    ImmutableList.Builder<String> builder = ImmutableList.<String>builder().add("--cosmos").add("-h").add(config.getEndpoint()).add("--schema-file").add(schemaFile).add("-p").add(config.getKey());
    CosmosEnv.getDatabasePrefix().ifPresent((prefix) -> builder.add("--table-metadata-database-prefix").add(prefix).add("--coordinator-namespace-prefix").add(prefix));
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) File(java.io.File) DatabaseConfig(com.scalar.db.config.DatabaseConfig)

Aggregations

DatabaseConfig (com.scalar.db.config.DatabaseConfig)66 Properties (java.util.Properties)60 Test (org.junit.jupiter.api.Test)40 StorageFactory (com.scalar.db.service.StorageFactory)6 BasicDataSource (org.apache.commons.dbcp2.BasicDataSource)4 BeforeAll (org.junit.jupiter.api.BeforeAll)3 ImmutableList (com.google.common.collect.ImmutableList)2 ConsensusCommitAdmin (com.scalar.db.transaction.consensuscommit.ConsensusCommitAdmin)2 File (java.io.File)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ConfigUtils.getString (com.scalar.db.config.ConfigUtils.getString)1 JdbcConfig (com.scalar.db.storage.jdbc.JdbcConfig)1 ConsensusCommitConfig (com.scalar.db.transaction.consensuscommit.ConsensusCommitConfig)1