Skip to content

Commit 61dd00f

Browse files
committed
Fix DynamoEnv to provide a single getProperties method
1 parent 45385d6 commit 61dd00f

File tree

3 files changed

+8
-34
lines changed

3 files changed

+8
-34
lines changed

core/src/integration-test/java/com/scalar/db/storage/dynamo/DynamoAdminPermissionIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public class DynamoAdminPermissionIntegrationTest
1212
extends DistributedStorageAdminPermissionIntegrationTestBase {
1313
@Override
1414
protected Properties getProperties(String testName) {
15-
return DynamoEnv.getPropertiesForNonEmulator(testName);
15+
return DynamoEnv.getProperties(testName);
1616
}
1717

1818
@Override
1919
protected Properties getPropertiesForNormalUser(String testName) {
20-
return DynamoEnv.getPropertiesForNonEmulator(testName);
20+
return DynamoEnv.getProperties(testName);
2121
}
2222

2323
@Override

core/src/integration-test/java/com/scalar/db/storage/dynamo/DynamoEnv.java

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ public final class DynamoEnv {
1010
private static final String PROP_DYNAMO_REGION = "scalardb.dynamo.region";
1111
private static final String PROP_DYNAMO_ACCESS_KEY_ID = "scalardb.dynamo.access_key_id";
1212
private static final String PROP_DYNAMO_SECRET_ACCESS_KEY = "scalardb.dynamo.secret_access_key";
13+
private static final String PROP_DYNAMO_EMULATOR = "scalardb.dynamo.emulator";
1314
private static final String PROP_DYNAMO_CREATE_OPTIONS = "scalardb.dynamo.create_options";
1415

1516
private static final String DEFAULT_DYNAMO_ENDPOINT_OVERRIDE = "http://localhost:8000";
1617
private static final String DEFAULT_DYNAMO_REGION = "us-west-2";
1718
private static final String DEFAULT_DYNAMO_ACCESS_KEY_ID = "fakeMyKeyId";
1819
private static final String DEFAULT_DYNAMO_SECRET_ACCESS_KEY = "fakeSecretAccessKey";
20+
private static final String DEFAULT_DYNAMO_EMULATOR = "true";
1921

2022
private static final ImmutableMap<String, String> DEFAULT_DYNAMO_CREATE_OPTIONS =
2123
ImmutableMap.of(DynamoAdmin.NO_SCALING, "true", DynamoAdmin.NO_BACKUP, "true");
@@ -30,9 +32,10 @@ public static Properties getProperties(String testName) {
3032
System.getProperty(PROP_DYNAMO_ACCESS_KEY_ID, DEFAULT_DYNAMO_ACCESS_KEY_ID);
3133
String secretAccessKey =
3234
System.getProperty(PROP_DYNAMO_SECRET_ACCESS_KEY, DEFAULT_DYNAMO_SECRET_ACCESS_KEY);
35+
String isEmulator = System.getProperty(PROP_DYNAMO_EMULATOR, DEFAULT_DYNAMO_EMULATOR);
3336

3437
Properties properties = new Properties();
35-
if (endpointOverride != null) {
38+
if (isEmulator.equals("true") && endpointOverride != null) {
3639
properties.setProperty(DynamoConfig.ENDPOINT_OVERRIDE, endpointOverride);
3740
}
3841
properties.setProperty(DatabaseConfig.CONTACT_POINTS, region);
@@ -51,35 +54,6 @@ public static Properties getProperties(String testName) {
5154
return properties;
5255
}
5356

54-
/**
55-
* Returns properties for tests that require real DynamoDB (not the emulator) to be used.
56-
*
57-
* <p>These properties are used in tests that require real DynamoDB (not the emulator) to be used.
58-
*/
59-
public static Properties getPropertiesForNonEmulator(String testName) {
60-
String region = System.getProperty(PROP_DYNAMO_REGION, DEFAULT_DYNAMO_REGION);
61-
String accessKeyId =
62-
System.getProperty(PROP_DYNAMO_ACCESS_KEY_ID, DEFAULT_DYNAMO_ACCESS_KEY_ID);
63-
String secretAccessKey =
64-
System.getProperty(PROP_DYNAMO_SECRET_ACCESS_KEY, DEFAULT_DYNAMO_SECRET_ACCESS_KEY);
65-
66-
Properties properties = new Properties();
67-
properties.setProperty(DatabaseConfig.CONTACT_POINTS, region);
68-
properties.setProperty(DatabaseConfig.USERNAME, accessKeyId);
69-
properties.setProperty(DatabaseConfig.PASSWORD, secretAccessKey);
70-
properties.setProperty(DatabaseConfig.STORAGE, "dynamo");
71-
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN, "true");
72-
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_FILTERING, "true");
73-
properties.setProperty(DatabaseConfig.CROSS_PARTITION_SCAN_ORDERING, "false");
74-
75-
// Add testName as a metadata namespace suffix
76-
properties.setProperty(
77-
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
78-
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);
79-
80-
return properties;
81-
}
82-
8357
public static Map<String, String> getCreationOptions() {
8458
String createOptionsString = System.getProperty(PROP_DYNAMO_CREATE_OPTIONS);
8559
if (createOptionsString == null) {

core/src/integration-test/java/com/scalar/db/storage/dynamo/DynamoPermissionIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ public class DynamoPermissionIntegrationTest
99
extends DistributedStoragePermissionIntegrationTestBase {
1010
@Override
1111
protected Properties getProperties(String testName) {
12-
return DynamoEnv.getPropertiesForNonEmulator(testName);
12+
return DynamoEnv.getProperties(testName);
1313
}
1414

1515
@Override
1616
protected Properties getPropertiesForNormalUser(String testName) {
17-
return DynamoEnv.getPropertiesForNonEmulator(testName);
17+
return DynamoEnv.getProperties(testName);
1818
}
1919

2020
@Override

0 commit comments

Comments
 (0)