-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor integration tests for Consensus Commit
- Loading branch information
Showing
26 changed files
with
663 additions
and
794 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...rage/cassandra/ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCassandra.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.scalar.db.storage.cassandra; | ||
|
||
import com.scalar.db.transaction.consensuscommit.ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
public class ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCassandra | ||
extends ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
@Override | ||
protected Properties getProperties(String testName) { | ||
return CassandraEnv.getProperties(testName); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCreationOptions() { | ||
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1"); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...sandra/TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCassandra.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.scalar.db.storage.cassandra; | ||
|
||
import com.scalar.db.transaction.consensuscommit.TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
public class TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCassandra | ||
extends TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
@Override | ||
protected Properties getProperties(String testName) { | ||
return CassandraEnv.getProperties(testName); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCreationOptions() { | ||
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1"); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...db/storage/cosmos/ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCosmos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.scalar.db.storage.cosmos; | ||
|
||
import com.scalar.db.transaction.consensuscommit.ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Properties; | ||
|
||
public class ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCosmos | ||
extends ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
|
||
@Override | ||
protected Properties getProperties(String testName) { | ||
return CosmosEnv.getProperties(testName); | ||
} | ||
|
||
@Override | ||
protected String getNamespace() { | ||
String namespace = super.getNamespace(); | ||
Optional<String> databasePrefix = CosmosEnv.getDatabasePrefix(); | ||
return databasePrefix.map(prefix -> prefix + namespace).orElse(namespace); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCreationOptions() { | ||
return CosmosEnv.getCreationOptions(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ge/cosmos/TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCosmos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.scalar.db.storage.cosmos; | ||
|
||
import com.scalar.db.transaction.consensuscommit.TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Properties; | ||
|
||
public class TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithCosmos | ||
extends TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
|
||
@Override | ||
protected Properties getProperties(String testName) { | ||
return CosmosEnv.getProperties(testName); | ||
} | ||
|
||
@Override | ||
protected String getNamespace() { | ||
String namespace = super.getNamespace(); | ||
Optional<String> databasePrefix = CosmosEnv.getDatabasePrefix(); | ||
return databasePrefix.map(prefix -> prefix + namespace).orElse(namespace); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCreationOptions() { | ||
return CosmosEnv.getCreationOptions(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...db/storage/dynamo/ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithDynamo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.scalar.db.storage.dynamo; | ||
|
||
import com.scalar.db.transaction.consensuscommit.ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
public class ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithDynamo | ||
extends ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
|
||
@Override | ||
protected Properties getProperties(String testName) { | ||
return DynamoEnv.getProperties(testName); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCreationOptions() { | ||
return DynamoEnv.getCreationOptions(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...ge/dynamo/TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithDynamo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.scalar.db.storage.dynamo; | ||
|
||
import com.scalar.db.transaction.consensuscommit.TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
|
||
public class TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithDynamo | ||
extends TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
|
||
@Override | ||
protected Properties getProperties(String testName) { | ||
return DynamoEnv.getProperties(testName); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCreationOptions() { | ||
return DynamoEnv.getCreationOptions(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...torage/jdbc/ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithJdbcDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.scalar.db.storage.jdbc; | ||
|
||
import com.scalar.db.transaction.consensuscommit.ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Properties; | ||
|
||
public class ConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithJdbcDatabase | ||
extends ConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
|
||
@Override | ||
protected Properties getProperties(String testName) { | ||
return JdbcEnv.getProperties(testName); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...dbc/TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithJdbcDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.scalar.db.storage.jdbc; | ||
|
||
import com.scalar.db.transaction.consensuscommit.TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase; | ||
import java.util.Properties; | ||
|
||
public class TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestWithJdbcDatabase | ||
extends TwoPhaseConsensusCommitWithIncludeMetadataEnabledIntegrationTestBase { | ||
|
||
@Override | ||
protected Properties getProperties(String testName) { | ||
return JdbcEnv.getProperties(testName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 3 additions & 56 deletions
59
...va/com/scalar/db/transaction/consensuscommit/ConsensusCommitAdminIntegrationTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,21 @@ | ||
package com.scalar.db.transaction.consensuscommit; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.scalar.db.api.DistributedTransactionAdmin; | ||
import com.scalar.db.api.DistributedTransactionAdminIntegrationTestBase; | ||
import com.scalar.db.api.TableMetadata; | ||
import com.scalar.db.config.DatabaseConfig; | ||
import com.scalar.db.exception.storage.ExecutionException; | ||
import com.scalar.db.service.TransactionFactory; | ||
import java.util.Properties; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public abstract class ConsensusCommitAdminIntegrationTestBase | ||
extends DistributedTransactionAdminIntegrationTestBase { | ||
private DistributedTransactionAdmin adminWithIncludeMetadataEnabled; | ||
|
||
@Override | ||
protected void initialize(String testName) throws Exception { | ||
Properties includeMetadataEnabledProperties = getPropsWithIncludeMetadataEnabled(testName); | ||
adminWithIncludeMetadataEnabled = | ||
TransactionFactory.create(includeMetadataEnabledProperties).getTransactionAdmin(); | ||
} | ||
|
||
@AfterAll | ||
@Override | ||
public void afterAll() throws Exception { | ||
super.afterAll(); | ||
|
||
adminWithIncludeMetadataEnabled.close(); | ||
} | ||
|
||
@Override | ||
protected final Properties getProperties(String testName) { | ||
Properties properties = new Properties(); | ||
properties.putAll(getProps(testName)); | ||
if (!properties.containsKey(DatabaseConfig.TRANSACTION_MANAGER)) { | ||
properties.setProperty(DatabaseConfig.TRANSACTION_MANAGER, "consensus-commit"); | ||
|
||
// Add testName as a coordinator namespace suffix | ||
String coordinatorNamespace = | ||
properties.getProperty( | ||
ConsensusCommitConfig.COORDINATOR_NAMESPACE, Coordinator.NAMESPACE); | ||
properties.setProperty( | ||
ConsensusCommitConfig.COORDINATOR_NAMESPACE, coordinatorNamespace + "_" + testName); | ||
} | ||
return properties; | ||
} | ||
|
||
protected abstract Properties getProps(String testName); | ||
// Add testName as a coordinator namespace suffix | ||
ConsensusCommitIntegrationTestUtils.addSuffixToCoordinatorNamespace(properties, testName); | ||
|
||
protected Properties getPropsWithIncludeMetadataEnabled(String testName) { | ||
Properties properties = getProperties(testName); | ||
properties.setProperty(ConsensusCommitConfig.INCLUDE_METADATA_ENABLED, "true"); | ||
return properties; | ||
} | ||
|
||
@Test | ||
public void | ||
getTableMetadata_WhenIncludeMetadataIsEnabled_ShouldReturnCorrectMetadataWithTransactionMetadataColumns() | ||
throws ExecutionException { | ||
// Arrange | ||
TableMetadata transactionTableMetadata = | ||
ConsensusCommitUtils.buildTransactionTableMetadata(TABLE_METADATA); | ||
|
||
// Act | ||
TableMetadata tableMetadata = | ||
adminWithIncludeMetadataEnabled.getTableMetadata(getNamespace1(), TABLE1); | ||
|
||
// Assert | ||
assertThat(tableMetadata).isEqualTo(transactionTableMetadata); | ||
} | ||
protected abstract Properties getProps(String testName); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.