You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by fa...@apache.org on 2017/02/16 23:26:39 UTC
hadoop git commit: HADOOP-14046 Metastore destruction test creates
table w/o version. Contributed by Sean Mackrory
Repository: hadoop
Updated Branches:
refs/heads/HADOOP-13345 94287ce70 -> 8b37b6a96
HADOOP-14046 Metastore destruction test creates table w/o version. Contributed by Sean Mackrory
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/8b37b6a9
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/8b37b6a9
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/8b37b6a9
Branch: refs/heads/HADOOP-13345
Commit: 8b37b6a96ce3d66d5621ff3b4d8538c98b106907
Parents: 94287ce
Author: Aaron Fabbri <fa...@apache.org>
Authored: Thu Feb 16 15:25:53 2017 -0800
Committer: Aaron Fabbri <fa...@apache.org>
Committed: Thu Feb 16 15:25:53 2017 -0800
----------------------------------------------------------------------
.../s3a/s3guard/ITestS3GuardToolDynamoDB.java | 120 ++++++-------------
1 file changed, 37 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/8b37b6a9/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestS3GuardToolDynamoDB.java
----------------------------------------------------------------------
diff --git a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestS3GuardToolDynamoDB.java b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestS3GuardToolDynamoDB.java
index 4480044..fb0efd1 100644
--- a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestS3GuardToolDynamoDB.java
+++ b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/s3guard/ITestS3GuardToolDynamoDB.java
@@ -20,10 +20,6 @@ package org.apache.hadoop.fs.s3a.s3guard;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Table;
-import com.amazonaws.services.dynamodbv2.model.AttributeDefinition;
-import com.amazonaws.services.dynamodbv2.model.CreateTableRequest;
-import com.amazonaws.services.dynamodbv2.model.KeySchemaElement;
-import com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput;
import com.amazonaws.services.dynamodbv2.model.ResourceNotFoundException;
import org.apache.hadoop.fs.s3a.S3AFileSystem;
import org.apache.hadoop.fs.s3a.s3guard.S3GuardTool.DestroyMetadata;
@@ -31,7 +27,6 @@ import org.apache.hadoop.fs.s3a.s3guard.S3GuardTool.InitMetadata;
import org.junit.Test;
import java.io.IOException;
-import java.util.Collection;
import java.util.Random;
import static org.apache.hadoop.fs.s3a.s3guard.S3GuardTool.SUCCESS;
@@ -66,91 +61,50 @@ public class ITestS3GuardToolDynamoDB extends S3GuardToolTestBase {
}
@Test
- public void testInitDynamoDBMetadataStore() throws IOException {
- final String testS3Url = getTestPath("init");
- String testTableName = "initDynamoDBMetadataStore" +
- new Random().nextInt();
-
- InitMetadata cmd = new InitMetadata(getFs().getConf());
- Table table = null;
-
- try {
- String[] args = new String[]{
- "init", "-m", "dynamodb://" + testTableName, testS3Url
- };
- assertEquals("Init command did not exit successfully - see output",
- SUCCESS, cmd.run(args));
- // Verify the existence of the dynamodb table.
- try {
- MetadataStore ms = getMetadataStore();
- assertTrue("metadata store should be DynamoDBMetadataStore",
- ms instanceof DynamoDBMetadataStore);
- DynamoDBMetadataStore dynamoMs = (DynamoDBMetadataStore) ms;
- DynamoDB db = dynamoMs.getDynamoDB();
- table = db.getTable(testTableName);
- table.describe();
- } catch (ResourceNotFoundException e) {
- fail(String.format("DynamoDB table %s does not exist",
- testTableName));
- }
- } finally {
- // Clean the table.
- try {
- if (table != null) {
- table.delete();
- }
- } catch (ResourceNotFoundException e) {
- // Ignore
- }
- }
- }
-
- @Test
- public void testDestroyDynamoDBMetadataStore()
- throws IOException, InterruptedException {
- final String testS3Url = getTestPath("destroy");
- String testTableName = "destroyDynamoDBMetadataStore" +
- new Random().nextInt();
-
+ public void testDynamoDBInitDestroyCycle() throws IOException,
+ InterruptedException {
+ String testTableName = "testDynamoDBInitDestroy" + new Random().nextInt();
+ String testS3Url = getTestPath(testTableName);
S3AFileSystem fs = getFs();
- DestroyMetadata cmd = new DestroyMetadata(fs.getConf());
-
- // Pre-alloc DynamoDB table.
- DynamoDB db = DynamoDBMetadataStore.createDynamoDB(fs);
- try {
- Table table = db.getTable(testTableName);
- table.delete();
- table.waitForDelete();
- } catch (ResourceNotFoundException e) {
- // Ignore.
- }
- Collection<KeySchemaElement> elements =
- PathMetadataDynamoDBTranslation.keySchema();
- Collection<AttributeDefinition> attrs =
- PathMetadataDynamoDBTranslation.attributeDefinitions();
- ProvisionedThroughput pt = new ProvisionedThroughput(100L, 200L);
- Table table = db.createTable(new CreateTableRequest()
- .withAttributeDefinitions(attrs)
- .withKeySchema(elements)
- .withTableName(testTableName)
- .withProvisionedThroughput(pt));
+ DynamoDB db = null;
try {
- table.waitForActive();
- assertTrue("Table does not exist", exist(db, testTableName));
+ // Initialize MetadataStore
+ InitMetadata initCmd = new InitMetadata(fs.getConf());
+ assertEquals("Init command did not exit successfully - see output",
+ SUCCESS, initCmd.run(new String[]{
+ "init", "-m", "dynamodb://" + testTableName, testS3Url
+ }));
+ // Verify it exists
+ MetadataStore ms = getMetadataStore();
+ assertTrue("metadata store should be DynamoDBMetadataStore",
+ ms instanceof DynamoDBMetadataStore);
+ DynamoDBMetadataStore dynamoMs = (DynamoDBMetadataStore) ms;
+ db = dynamoMs.getDynamoDB();
+ assertTrue(String.format("%s does not exist", testTableName),
+ exist(db, testTableName));
- String[] args = new String[]{
- "destroy", "-m", "dynamodb://" + testTableName, testS3Url
- };
+ // Destroy MetadataStore
+ DestroyMetadata destroyCmd = new DestroyMetadata(fs.getConf());
assertEquals("Destroy command did not exit successfully - see output",
- SUCCESS, cmd.run(args));
+ SUCCESS, destroyCmd.run(new String[]{
+ "destroy", "-m", "dynamodb://" + testTableName, testS3Url
+ }));
+ // Verify it does not exist
assertFalse(String.format("%s still exists", testTableName),
exist(db, testTableName));
+ } catch (ResourceNotFoundException e) {
+ fail(String.format("DynamoDB table %s does not exist", testTableName));
} finally {
- if (table != null) {
- try {
- table.delete();
- table.waitForDelete();
- } catch (ResourceNotFoundException e) {}
+ System.out.println("Warning! Table may have not been cleaned up: " +
+ testTableName);
+ if (db != null) {
+ Table table = db.getTable(testTableName);
+ if (table != null) {
+ try {
+ table.delete();
+ table.waitForDelete();
+ } catch (ResourceNotFoundException e) { /* Ignore */ }
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org