Skip to content

Commit

Permalink
Fix based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
brfrn169 committed Dec 6, 2023
1 parent 5075d33 commit 7b053c5
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public final class CassandraEnv {

private CassandraEnv() {}

public static Properties getProperties(@SuppressWarnings("unused") String testName) {
public static Properties getProperties(String testName) {
String contactPoints =
System.getProperty(PROP_CASSANDRA_CONTACT_POINTS, DEFAULT_CASSANDRA_CONTACT_POINTS);
String username = System.getProperty(PROP_CASSANDRA_USERNAME, DEFAULT_CASSANDRA_USERNAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ public static Properties getProperties(String testName) {
String password = System.getProperty(PROP_COSMOS_PASSWORD);
Optional<String> databasePrefix = getDatabasePrefix();

Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, contactPoint);
props.setProperty(DatabaseConfig.PASSWORD, password);
props.setProperty(DatabaseConfig.STORAGE, "cosmos");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "false");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "false");
Properties properties = new Properties();
properties.setProperty(DatabaseConfig.CONTACT_POINTS, contactPoint);
properties.setProperty(DatabaseConfig.PASSWORD, password);
properties.setProperty(DatabaseConfig.STORAGE, "cosmos");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "false");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "false");

if (databasePrefix.isPresent()) {
// Add the prefix and testName as a metadata database suffix
props.setProperty(
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
databasePrefix.get() + DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

props.setProperty(
properties.setProperty(
ConsensusCommitConfig.COORDINATOR_NAMESPACE,
databasePrefix.get() + Coordinator.NAMESPACE);
} else {
// Add testName as a metadata database suffix
props.setProperty(
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);
}

return props;
return properties;
}

public static Optional<String> getDatabasePrefix() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,24 @@ public static Properties getProperties(String testName) {
String secretAccessKey =
System.getProperty(PROP_DYNAMO_SECRET_ACCESS_KEY, DEFAULT_DYNAMO_SECRET_ACCESS_KEY);

Properties props = new Properties();
Properties properties = new Properties();
if (endpointOverride != null) {
props.setProperty(DynamoConfig.ENDPOINT_OVERRIDE, endpointOverride);
properties.setProperty(DynamoConfig.ENDPOINT_OVERRIDE, endpointOverride);
}
props.setProperty(DatabaseConfig.CONTACT_POINTS, region);
props.setProperty(DatabaseConfig.USERNAME, accessKeyId);
props.setProperty(DatabaseConfig.PASSWORD, secretAccessKey);
props.setProperty(DatabaseConfig.STORAGE, "dynamo");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "false");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "false");
properties.setProperty(DatabaseConfig.CONTACT_POINTS, region);
properties.setProperty(DatabaseConfig.USERNAME, accessKeyId);
properties.setProperty(DatabaseConfig.PASSWORD, secretAccessKey);
properties.setProperty(DatabaseConfig.STORAGE, "dynamo");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "false");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "false");

// Add testName as a metadata namespace suffix
props.setProperty(
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

return props;
return properties;
}

public static Map<String, String> getCreationOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ public static Properties getProperties(String testName) {
String username = System.getProperty(PROP_JDBC_USERNAME, DEFAULT_JDBC_USERNAME);
String password = System.getProperty(PROP_JDBC_PASSWORD, DEFAULT_JDBC_PASSWORD);

Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, jdbcUrl);
props.setProperty(DatabaseConfig.USERNAME, username);
props.setProperty(DatabaseConfig.PASSWORD, password);
props.setProperty(DatabaseConfig.STORAGE, "jdbc");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "true");
props.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "true");
Properties properties = new Properties();
properties.setProperty(DatabaseConfig.CONTACT_POINTS, jdbcUrl);
properties.setProperty(DatabaseConfig.USERNAME, username);
properties.setProperty(DatabaseConfig.PASSWORD, password);
properties.setProperty(DatabaseConfig.STORAGE, "jdbc");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "true");
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "true");

// Add testName as a metadata schema suffix
props.setProperty(
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

return props;
return properties;
}

public static boolean isSqlite() {
Properties props = new Properties();
props.setProperty(
Properties properties = new Properties();
properties.setProperty(
DatabaseConfig.CONTACT_POINTS, System.getProperty(PROP_JDBC_URL, DEFAULT_JDBC_URL));
props.setProperty(DatabaseConfig.STORAGE, "jdbc");
return JdbcUtils.isSqlite(new JdbcConfig(new DatabaseConfig(props)));
properties.setProperty(DatabaseConfig.STORAGE, "jdbc");
return JdbcUtils.isSqlite(new JdbcConfig(new DatabaseConfig(properties)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public class ConsensusCommitNullMetadataIntegrationTestWithMultiStorage

@Override
protected Properties getProperties(String testName) {
Properties props = new Properties();
props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
Properties properties = new Properties();
properties.setProperty(DatabaseConfig.STORAGE, "multi-storage");

// Define storages, cassandra and jdbc
props.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");
properties.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");

Properties propertiesForCassandra = MultiStorageEnv.getPropertiesForCassandra(testName);
for (String propertyName : propertiesForCassandra.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".cassandra."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -30,7 +30,7 @@ protected Properties getProperties(String testName) {

Properties propertiesForJdbc = MultiStorageEnv.getPropertiesForJdbc(testName);
for (String propertyName : propertiesForJdbc.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".jdbc."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -39,7 +39,7 @@ protected Properties getProperties(String testName) {

// Define namespace mapping from namespace1 to cassandra, from namespace2 to jdbc, and from
// the coordinator namespace to cassandra
props.setProperty(
properties.setProperty(
MultiStorageConfig.NAMESPACE_MAPPING,
getNamespace1()
+ ":cassandra,"
Expand All @@ -49,9 +49,14 @@ protected Properties getProperties(String testName) {
+ ":cassandra");

// The default storage is cassandra
props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");
properties.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");

return props;
// Add testName as a metadata schema suffix
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

return properties;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public class ConsensusCommitSpecificIntegrationTestWithMultiStorage

@Override
protected Properties getProperties(String testName) {
Properties props = new Properties();
props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
Properties properties = new Properties();
properties.setProperty(DatabaseConfig.STORAGE, "multi-storage");

// Define storages, cassandra and jdbc
props.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");
properties.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");

Properties propertiesForCassandra = MultiStorageEnv.getPropertiesForCassandra(testName);
for (String propertyName : propertiesForCassandra.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".cassandra."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -30,7 +30,7 @@ protected Properties getProperties(String testName) {

Properties propertiesForJdbc = MultiStorageEnv.getPropertiesForJdbc(testName);
for (String propertyName : propertiesForJdbc.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".jdbc."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -39,7 +39,7 @@ protected Properties getProperties(String testName) {

// Define namespace mapping from namespace1 to cassandra, from namespace2 to jdbc, and from
// the coordinator namespace to cassandra
props.setProperty(
properties.setProperty(
MultiStorageConfig.NAMESPACE_MAPPING,
getNamespace1()
+ ":cassandra,"
Expand All @@ -49,9 +49,14 @@ protected Properties getProperties(String testName) {
+ ":cassandra");

// The default storage is cassandra
props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");
properties.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");

return props;
// Add testName as a metadata schema suffix
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

return properties;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ private void initJdbcAdmin() throws ExecutionException {
}

private void initMultiStorageAdmin() {
Properties props = new Properties();
props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
Properties properties = new Properties();
properties.setProperty(DatabaseConfig.STORAGE, "multi-storage");

// Define storages, cassandra and jdbc
props.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");
properties.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");

Properties propertiesForCassandra = MultiStorageEnv.getPropertiesForCassandra(TEST_NAME);
for (String propertyName : propertiesForCassandra.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".cassandra."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -118,7 +118,7 @@ private void initMultiStorageAdmin() {

Properties propertiesForJdbc = MultiStorageEnv.getPropertiesForJdbc(TEST_NAME);
for (String propertyName : propertiesForJdbc.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".jdbc."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -127,18 +127,23 @@ private void initMultiStorageAdmin() {

// Define table mapping from table1 in namespace1 to cassandra, and from table2 in namespace1 to
// jdbc
props.setProperty(
properties.setProperty(
MultiStorageConfig.TABLE_MAPPING,
NAMESPACE1 + "." + TABLE1 + ":cassandra," + NAMESPACE1 + "." + TABLE2 + ":jdbc");

// Define namespace mapping from namespace2 and namespace3 to jdbc
props.setProperty(
properties.setProperty(
MultiStorageConfig.NAMESPACE_MAPPING, NAMESPACE2 + ":jdbc," + NAMESPACE3 + ":jdbc");

// The default storage is cassandra
props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");
properties.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");

DatabaseConfig databaseConfig = new DatabaseConfig(props);
// Add testName as a metadata schema suffix
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + TEST_NAME);

DatabaseConfig databaseConfig = new DatabaseConfig(properties);
multiStorageAdmin = new MultiStorageAdmin(databaseConfig);

systemNamespaceName = databaseConfig.getSystemNamespaceName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ private Map<String, String> getCreationOptions() {
}

private void initMultiStorage() {
Properties props = new Properties();
props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
Properties properties = new Properties();
properties.setProperty(DatabaseConfig.STORAGE, "multi-storage");

// Define storages, cassandra and jdbc
props.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");
properties.setProperty(MultiStorageConfig.STORAGES, "cassandra,jdbc");

Properties propertiesForCassandra = MultiStorageEnv.getPropertiesForCassandra(TEST_NAME);
for (String propertyName : propertiesForCassandra.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".cassandra."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
Expand All @@ -119,25 +119,30 @@ private void initMultiStorage() {

Properties propertiesForJdbc = MultiStorageEnv.getPropertiesForJdbc(TEST_NAME);
for (String propertyName : propertiesForJdbc.stringPropertyNames()) {
props.setProperty(
properties.setProperty(
MultiStorageConfig.STORAGES
+ ".jdbc."
+ propertyName.substring(DatabaseConfig.PREFIX.length()),
propertiesForJdbc.getProperty(propertyName));
}

// Define table mapping from table1 to cassandra, and from table2 to jdbc
props.setProperty(
properties.setProperty(
MultiStorageConfig.TABLE_MAPPING,
NAMESPACE1 + "." + TABLE1 + ":cassandra," + NAMESPACE1 + "." + TABLE2 + ":jdbc");

// Define namespace mapping from namespace2 to jdbc
props.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, NAMESPACE2 + ":jdbc");
properties.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, NAMESPACE2 + ":jdbc");

// The default storage is cassandra
props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");
properties.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");

multiStorage = new MultiStorage(new DatabaseConfig(props));
// Add testName as a metadata schema suffix
properties.setProperty(
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + TEST_NAME);

multiStorage = new MultiStorage(new DatabaseConfig(properties));
}

@BeforeEach
Expand Down
Loading

0 comments on commit 7b053c5

Please sign in to comment.