Search in sources :

Example 21 with DatabaseConfig

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

the class ConsensusCommitConfigTest method constructor_PropertiesWithDeprecatedIsolationLevelGiven_ShouldLoadProperly.

@Test
public void constructor_PropertiesWithDeprecatedIsolationLevelGiven_ShouldLoadProperly() {
    // Arrange
    Properties props = new Properties();
    props.setProperty("scalar.db.isolation_level", Isolation.SERIALIZABLE.toString());
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getIsolation()).isEqualTo(Isolation.SERIALIZABLE);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 22 with DatabaseConfig

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

the class ConsensusCommitConfigTest method constructor_UnsupportedSerializableStrategyGiven_ShouldThrowIllegalArgumentException.

@Test
public void constructor_UnsupportedSerializableStrategyGiven_ShouldThrowIllegalArgumentException() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.SERIALIZABLE_STRATEGY, "NO_STRATEGY");
    // Act Assert
    assertThatThrownBy(() -> new ConsensusCommitConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 23 with DatabaseConfig

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

the class ConsensusCommitConfigTest method constructor_UnsupportedIsolationGiven_ShouldThrowIllegalArgumentException.

@Test
public void constructor_UnsupportedIsolationGiven_ShouldThrowIllegalArgumentException() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.ISOLATION_LEVEL, "READ_COMMITTED");
    // Act Assert
    assertThatThrownBy(() -> new ConsensusCommitConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 24 with DatabaseConfig

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

the class ConsensusCommitConfigTest method constructor_ParallelExecutionRelatedPropertiesGiven_ShouldLoadProperly.

@Test
public void constructor_ParallelExecutionRelatedPropertiesGiven_ShouldLoadProperly() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(ConsensusCommitConfig.PARALLEL_EXECUTOR_COUNT, "100");
    props.setProperty(ConsensusCommitConfig.PARALLEL_PREPARATION_ENABLED, "true");
    props.setProperty(ConsensusCommitConfig.PARALLEL_VALIDATION_ENABLED, "true");
    props.setProperty(ConsensusCommitConfig.PARALLEL_COMMIT_ENABLED, "true");
    props.setProperty(ConsensusCommitConfig.PARALLEL_ROLLBACK_ENABLED, "true");
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getParallelExecutorCount()).isEqualTo(100);
    assertThat(config.isParallelPreparationEnabled()).isEqualTo(true);
    assertThat(config.isParallelValidationEnabled()).isEqualTo(true);
    assertThat(config.isParallelCommitEnabled()).isEqualTo(true);
    assertThat(config.isParallelRollbackEnabled()).isEqualTo(true);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 25 with DatabaseConfig

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

the class ConsensusCommitConfigTest method constructor_NoPropertiesGiven_ShouldLoadAsDefaultValues.

@Test
public void constructor_NoPropertiesGiven_ShouldLoadAsDefaultValues() {
    // Arrange
    Properties props = new Properties();
    // Act
    ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getIsolation()).isEqualTo(Isolation.SNAPSHOT);
    assertThat(config.getSerializableStrategy()).isEqualTo(SerializableStrategy.EXTRA_READ);
    assertThat(config.getCoordinatorNamespace()).isNotPresent();
    assertThat(config.getParallelExecutorCount()).isEqualTo(ConsensusCommitConfig.DEFAULT_PARALLEL_EXECUTOR_COUNT);
    assertThat(config.isParallelPreparationEnabled()).isEqualTo(false);
    assertThat(config.isParallelValidationEnabled()).isEqualTo(false);
    assertThat(config.isParallelCommitEnabled()).isEqualTo(false);
    assertThat(config.isParallelRollbackEnabled()).isEqualTo(false);
    assertThat(config.isAsyncCommitEnabled()).isEqualTo(false);
    assertThat(config.isAsyncRollbackEnabled()).isEqualTo(false);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

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