Search in sources :

Example 51 with DatabaseConfig

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

the class DynamoConfigTest method constructor_PropertiesWithoutTableMetadataNamespaceGiven_ShouldLoadProperly.

@Test
public void constructor_PropertiesWithoutTableMetadataNamespaceGiven_ShouldLoadProperly() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_REGION);
    props.setProperty(DatabaseConfig.USERNAME, ANY_ACCESS_KEY_ID);
    props.setProperty(DatabaseConfig.PASSWORD, ANY_SECRET_ACCESS_ID);
    props.setProperty(DatabaseConfig.STORAGE, DYNAMO_STORAGE);
    props.setProperty(DynamoConfig.ENDPOINT_OVERRIDE, ANY_ENDPOINT_OVERRIDE);
    // Act
    DynamoConfig config = new DynamoConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getRegion()).isEqualTo(ANY_REGION);
    assertThat(config.getAccessKeyId()).isEqualTo(ANY_ACCESS_KEY_ID);
    assertThat(config.getSecretAccessKey()).isEqualTo(ANY_SECRET_ACCESS_ID);
    assertThat(config.getEndpointOverride().isPresent()).isTrue();
    assertThat(config.getEndpointOverride().get()).isEqualTo(ANY_ENDPOINT_OVERRIDE);
    assertThat(config.getTableMetadataNamespace()).isNotPresent();
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 52 with DatabaseConfig

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

the class DynamoConfigTest method constructor_AllPropertiesGiven_ShouldLoadProperly.

@Test
public void constructor_AllPropertiesGiven_ShouldLoadProperly() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_REGION);
    props.setProperty(DatabaseConfig.USERNAME, ANY_ACCESS_KEY_ID);
    props.setProperty(DatabaseConfig.PASSWORD, ANY_SECRET_ACCESS_ID);
    props.setProperty(DatabaseConfig.STORAGE, DYNAMO_STORAGE);
    props.setProperty(DynamoConfig.ENDPOINT_OVERRIDE, ANY_ENDPOINT_OVERRIDE);
    props.setProperty(DynamoConfig.TABLE_METADATA_NAMESPACE, ANY_TABLE_METADATA_NAMESPACE);
    // Act
    DynamoConfig config = new DynamoConfig(new DatabaseConfig(props));
    // Assert
    assertThat(config.getRegion()).isEqualTo(ANY_REGION);
    assertThat(config.getAccessKeyId()).isEqualTo(ANY_ACCESS_KEY_ID);
    assertThat(config.getSecretAccessKey()).isEqualTo(ANY_SECRET_ACCESS_ID);
    assertThat(config.getEndpointOverride().isPresent()).isTrue();
    assertThat(config.getEndpointOverride().get()).isEqualTo(ANY_ENDPOINT_OVERRIDE);
    assertThat(config.getTableMetadataNamespace()).isPresent();
    assertThat(config.getTableMetadataNamespace().get()).isEqualTo(ANY_TABLE_METADATA_NAMESPACE);
}
Also used : Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) Test(org.junit.jupiter.api.Test)

Example 53 with DatabaseConfig

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

the class CosmosConfigTest method constructor_WithoutStorage_ShouldThrowIllegalArgumentException.

@Test
public void constructor_WithoutStorage_ShouldThrowIllegalArgumentException() {
    // Arrange
    Properties props = new Properties();
    props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_ENDPOINT);
    props.setProperty(DatabaseConfig.PASSWORD, ANY_KEY);
    props.setProperty(CosmosConfig.TABLE_METADATA_DATABASE, ANY_TABLE_METADATA_DATABASE);
    // Act Assert
    assertThatThrownBy(() -> new CosmosConfig(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 54 with DatabaseConfig

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

the class ConsensusCommitSpecificIntegrationTestBase method beforeAll.

@BeforeAll
public void beforeAll() throws Exception {
    initialize();
    Properties properties = TestUtils.addSuffix(getProperties(), TEST_NAME);
    StorageFactory factory = StorageFactory.create(properties);
    admin = factory.getAdmin();
    databaseConfig = new DatabaseConfig(properties);
    consensusCommitConfig = new ConsensusCommitConfig(databaseConfig);
    consensusCommitAdmin = new ConsensusCommitAdmin(admin, consensusCommitConfig);
    namespace1 = getNamespace1();
    namespace2 = getNamespace2();
    createTables();
    originalStorage = factory.getStorage();
    parallelExecutor = new ParallelExecutor(consensusCommitConfig);
}
Also used : StorageFactory(com.scalar.db.service.StorageFactory) Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 55 with DatabaseConfig

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

the class TwoPhaseConsensusCommitSpecificIntegrationTestBase method beforeAll.

@BeforeAll
public void beforeAll() throws Exception {
    initialize();
    Properties properties = TestUtils.addSuffix(getProperties(), TEST_NAME);
    namespace = getNamespace();
    StorageFactory factory = StorageFactory.create(properties);
    admin = factory.getAdmin();
    DatabaseConfig databaseConfig = new DatabaseConfig(properties);
    ConsensusCommitConfig consensusCommitConfig = new ConsensusCommitConfig(databaseConfig);
    consensusCommitAdmin = new ConsensusCommitAdmin(admin, consensusCommitConfig);
    createTables();
    storage = factory.getStorage();
    initManagerAndCoordinator(databaseConfig, consensusCommitConfig);
}
Also used : StorageFactory(com.scalar.db.service.StorageFactory) Properties(java.util.Properties) DatabaseConfig(com.scalar.db.config.DatabaseConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

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