|
@@ -244,8 +244,11 @@ public class TestDynamoDBMetadataStore extends MetadataStoreTestBase {
|
|
verifyTableInitialized(tableName);
|
|
verifyTableInitialized(tableName);
|
|
assertNotNull(ddbms.getTable());
|
|
assertNotNull(ddbms.getTable());
|
|
assertEquals(tableName, ddbms.getTable().getTableName());
|
|
assertEquals(tableName, ddbms.getTable().getTableName());
|
|
- assertEquals("DynamoDB table should be in the same region as S3 bucket",
|
|
|
|
- s3afs.getBucketLocation(tableName),
|
|
|
|
|
|
+ String expectedRegion = conf.get(Constants.S3GUARD_DDB_REGION_KEY,
|
|
|
|
+ s3afs.getBucketLocation(tableName));
|
|
|
|
+ assertEquals("DynamoDB table should be in configured region or the same" +
|
|
|
|
+ " region as S3 bucket",
|
|
|
|
+ expectedRegion,
|
|
ddbms.getRegion());
|
|
ddbms.getRegion());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -259,6 +262,8 @@ public class TestDynamoDBMetadataStore extends MetadataStoreTestBase {
|
|
final String tableName = "testInitializeWithConfiguration";
|
|
final String tableName = "testInitializeWithConfiguration";
|
|
final Configuration conf = getFileSystem().getConf();
|
|
final Configuration conf = getFileSystem().getConf();
|
|
conf.unset(Constants.S3GUARD_DDB_TABLE_NAME_KEY);
|
|
conf.unset(Constants.S3GUARD_DDB_TABLE_NAME_KEY);
|
|
|
|
+ String savedRegion = conf.get(Constants.S3GUARD_DDB_REGION_KEY,
|
|
|
|
+ getFileSystem().getBucketLocation());
|
|
conf.unset(Constants.S3GUARD_DDB_REGION_KEY);
|
|
conf.unset(Constants.S3GUARD_DDB_REGION_KEY);
|
|
try {
|
|
try {
|
|
DynamoDBMetadataStore ddbms = new DynamoDBMetadataStore();
|
|
DynamoDBMetadataStore ddbms = new DynamoDBMetadataStore();
|
|
@@ -275,8 +280,7 @@ public class TestDynamoDBMetadataStore extends MetadataStoreTestBase {
|
|
} catch (IllegalArgumentException ignored) {
|
|
} catch (IllegalArgumentException ignored) {
|
|
}
|
|
}
|
|
// config region
|
|
// config region
|
|
- conf.set(Constants.S3GUARD_DDB_REGION_KEY,
|
|
|
|
- getFileSystem().getBucketLocation());
|
|
|
|
|
|
+ conf.set(Constants.S3GUARD_DDB_REGION_KEY, savedRegion);
|
|
try (DynamoDBMetadataStore ddbms = new DynamoDBMetadataStore()) {
|
|
try (DynamoDBMetadataStore ddbms = new DynamoDBMetadataStore()) {
|
|
ddbms.initialize(conf);
|
|
ddbms.initialize(conf);
|
|
verifyTableInitialized(tableName);
|
|
verifyTableInitialized(tableName);
|
|
@@ -390,7 +394,9 @@ public class TestDynamoDBMetadataStore extends MetadataStoreTestBase {
|
|
@Test
|
|
@Test
|
|
public void testTableVersionRequired() throws Exception {
|
|
public void testTableVersionRequired() throws Exception {
|
|
final DynamoDBMetadataStore ddbms = createContract().getMetadataStore();
|
|
final DynamoDBMetadataStore ddbms = createContract().getMetadataStore();
|
|
- Table table = verifyTableInitialized(BUCKET);
|
|
|
|
|
|
+ String tableName = getFileSystem().getConf().get(Constants
|
|
|
|
+ .S3GUARD_DDB_TABLE_NAME_KEY, BUCKET);
|
|
|
|
+ Table table = verifyTableInitialized(tableName);
|
|
table.deleteItem(VERSION_MARKER_PRIMARY_KEY);
|
|
table.deleteItem(VERSION_MARKER_PRIMARY_KEY);
|
|
|
|
|
|
// create existing table
|
|
// create existing table
|
|
@@ -405,7 +411,9 @@ public class TestDynamoDBMetadataStore extends MetadataStoreTestBase {
|
|
@Test
|
|
@Test
|
|
public void testTableVersionMismatch() throws Exception {
|
|
public void testTableVersionMismatch() throws Exception {
|
|
final DynamoDBMetadataStore ddbms = createContract().getMetadataStore();
|
|
final DynamoDBMetadataStore ddbms = createContract().getMetadataStore();
|
|
- Table table = verifyTableInitialized(BUCKET);
|
|
|
|
|
|
+ String tableName = getFileSystem().getConf().get(Constants
|
|
|
|
+ .S3GUARD_DDB_TABLE_NAME_KEY, BUCKET);
|
|
|
|
+ Table table = verifyTableInitialized(tableName);
|
|
table.deleteItem(VERSION_MARKER_PRIMARY_KEY);
|
|
table.deleteItem(VERSION_MARKER_PRIMARY_KEY);
|
|
Item v200 = createVersionMarker(VERSION_MARKER, 200, 0);
|
|
Item v200 = createVersionMarker(VERSION_MARKER, 200, 0);
|
|
table.putItem(v200);
|
|
table.putItem(v200);
|