Skip to content

Commit dbbc14e

Browse files
committed
Fixes for tests
Fix DynamoDB tests to wait for active Fixed bash scenario.
1 parent 3e67a33 commit dbbc14e

File tree

10 files changed

+58
-18
lines changed

10 files changed

+58
-18
lines changed

.doc_gen/metadata/dynamodb_metadata.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ dynamodb_CreateTable:
8181
- description:
8282
snippet_tags:
8383
- dynamodb.cpp.create_table.code
84+
- description: Code that waits for the table to become active.
85+
snippet_tags:
86+
- cpp.example_code.dynamodb.scenario.waitTableActive
87+
8488
Go:
8589
versions:
8690
- sdk_version: 2
@@ -628,6 +632,9 @@ dynamodb_PutItem:
628632
- description:
629633
snippet_tags:
630634
- dynamodb.cpp.put_item.code
635+
- description: Code that waits for the table to become active.
636+
snippet_tags:
637+
- cpp.example_code.dynamodb.scenario.waitTableActive
631638
Go:
632639
versions:
633640
- sdk_version: 2
@@ -890,6 +897,9 @@ dynamodb_UpdateItem:
890897
- description:
891898
snippet_tags:
892899
- dynamodb.cpp.update_item.code
900+
- description: Code that waits for the table to become active.
901+
snippet_tags:
902+
- cpp.example_code.dynamodb.scenario.waitTableActive
893903
Go:
894904
versions:
895905
- sdk_version: 2
@@ -1774,6 +1784,22 @@ dynamodb_BatchExecuteStatement:
17741784
- cpp.example_code.dynamodb.BatchExecuteStatement.Delete
17751785
services:
17761786
dynamodb: {BatchExecuteStatement}
1787+
dynamodb_UpdateTable:
1788+
languages:
1789+
C++:
1790+
versions:
1791+
- sdk_version: 1
1792+
github: cpp/example_code/dynamodb
1793+
sdkguide:
1794+
excerpts:
1795+
- description:
1796+
snippet_tags:
1797+
- dynamodb.cpp.update_table.code
1798+
- description: Code that waits for the table to become active.
1799+
snippet_tags:
1800+
- cpp.example_code.dynamodb.scenario.waitTableActive
1801+
services:
1802+
dynamodb: {UpdateTable}
17771803
dynamodb_Usage_DaxDemo:
17781804
title: Accelerate &DDB; reads with &DAX; using an &AWS; SDK
17791805
title_abbrev: Accelerate reads with &DAX;

aws-cli/bash-linux/s3/s3_getting_started.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ function s3_getting_started() {
5050
echo_repeat "*" 88
5151
echo "Welcome to the Amazon S3 getting started demo."
5252
echo_repeat "*" 88
53-
53+
echo "A unique bucket will be created by appending a Universally Unique Identifier to a bucket name prefix."
54+
echo -n "Enter a prefix for the S3 bucket that will be used in this deemo: "
55+
get_input
56+
bucket_name_prefix=$get_input_result
5457
local bucket_name
55-
bucket_name=$(generate_random_name "amzn-s3-demo-bucket")
58+
bucket_name=$(generate_random_name $bucket_name_prefix)
5659

5760
local region_code
5861
region_code=$(aws configure get region)

cpp/example_code/dynamodb/batch_write_item.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,10 @@ bool AwsDoc::DynamoDB::batchWriteItem(const Aws::String &jsonFilePath,
115115
std::cerr << "Error with DynamoDB::BatchWriteItem. "
116116
<< outcome.GetError().GetMessage()
117117
<< std::endl;
118+
return false;
118119
}
119120

120-
return true;
121+
return outcome.IsSuccess();
121122
}
122123

123124
//! Convert requests in JSON format to a vector of WriteRequest objects.

cpp/example_code/dynamodb/create_table.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ bool AwsDoc::DynamoDB::createTable(const Aws::String &tableName,
6868
else {
6969
std::cerr << "Failed to create table: " << outcome.GetError().GetMessage()
7070
<< std::endl;
71+
return false;
7172
}
7273

73-
return outcome.IsSuccess();
74+
return waitTableActive(tableName, dynamoClient);
7475
}
7576
// snippet-end:[dynamodb.cpp.create_table.code]
7677

cpp/example_code/dynamodb/create_table_composite_key.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ bool AwsDoc::DynamoDB::createTableWithCompositeKey(const Aws::String &tableName,
7979
else {
8080
std::cerr << "Failed to create table:" << outcome.GetError().GetMessage()
8181
<< std::endl;
82+
return false;
8283
}
8384

84-
return outcome.IsSuccess();
85+
return waitTableActive(tableName, dynamoClient);
8586
}
8687
// snippet-end:[dynamodb.cpp.create_table_composite_key.code]
8788

cpp/example_code/dynamodb/dynamodb_samples.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <aws/core/client/ClientConfiguration.h>
88
#include <aws/dynamodb/model/AttributeValue.h>
9+
#include <aws/dynamodb/DynamoDBClient.h>
910

1011
namespace AwsDoc {
1112
namespace DynamoDB {
@@ -262,11 +263,11 @@ namespace AwsDoc {
262263
/*!
263264
\sa waitTableActive()
264265
\param waitTableActive: The DynamoDB table's name.
265-
\param clientConfiguration: AWS client configuration.
266+
\param dynamoClient: A DynamoDB client.
266267
\return bool: Function succeeded.
267268
*/
268269
bool waitTableActive(const Aws::String &tableName,
269-
const Aws::Client::ClientConfiguration &clientConfiguration);
270+
const Aws::DynamoDB::DynamoDBClient &dynamoClient);
270271
//! Command line prompt/response utility function.
271272
/*!
272273
\\sa askQuestion()

cpp/example_code/dynamodb/dynamodb_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ bool AwsDoc::DynamoDB::deleteMoviesDynamoDBTable(
146146
/*!
147147
\sa waitTableActive()
148148
\param waitTableActive: The DynamoDB table's name.
149-
\param clientConfiguration: AWS client configuration.
149+
\param dynamoClient: A DynamoDB client.
150150
\return bool: Function succeeded.
151151
*/
152152
bool AwsDoc::DynamoDB::waitTableActive(const Aws::String &tableName,
153-
const Aws::Client::ClientConfiguration &clientConfiguration) {
154-
Aws::DynamoDB::DynamoDBClient dynamoClient(clientConfiguration);
153+
const Aws::DynamoDB::DynamoDBClient &dynamoClient) {
154+
155155
// Repeatedly call DescribeTable until table is ACTIVE.
156156
const int MAX_QUERIES = 20;
157157
Aws::DynamoDB::Model::DescribeTableRequest request;

cpp/example_code/dynamodb/put_item.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ bool AwsDoc::DynamoDB::putItem(const Aws::String &tableName,
6969
}
7070
else {
7171
std::cerr << outcome.GetError().GetMessage() << std::endl;
72+
return false;
7273
}
7374

74-
return outcome.IsSuccess();
75+
return waitTableActive(tableName, dynamoClient);
7576
}
7677

7778
// snippet-end:[dynamodb.cpp.put_item.code]

cpp/example_code/dynamodb/update_item.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ bool AwsDoc::DynamoDB::updateItem(const Aws::String &tableName,
8080
request);
8181
if (outcome.IsSuccess()) {
8282
std::cout << "Item was updated" << std::endl;
83-
}
84-
else {
83+
} else {
8584
std::cerr << outcome.GetError().GetMessage() << std::endl;
85+
return false;
8686
}
8787

88-
return outcome.IsSuccess();
88+
return waitTableActive(tableName, dynamoClient);
8989
}
9090
// snippet-end:[dynamodb.cpp.update_item.code]
9191

cpp/example_code/dynamodb/update_table.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,18 @@ bool AwsDoc::DynamoDB::updateTable(const Aws::String &tableName,
6060
request);
6161
if (outcome.IsSuccess()) {
6262
std::cout << "Successfully updated the table." << std::endl;
63-
}
64-
else {
65-
std::cerr << outcome.GetError().GetMessage() << std::endl;
63+
} else {
64+
const Aws::DynamoDB::DynamoDBError &error = outcome.GetError();
65+
if (error.GetErrorType() == Aws::DynamoDB::DynamoDBErrors::VALIDATION &&
66+
error.GetMessage().find("The provisioned throughput for the table will not change") != std::string::npos) {
67+
std::cout << "The provisioned throughput for the table will not change." << std::endl;
68+
} else {
69+
std::cerr << outcome.GetError().GetMessage() << std::endl;
70+
return false;
71+
}
6672
}
6773

68-
return outcome.IsSuccess();
74+
return waitTableActive(tableName, dynamoClient);
6975
}
7076
// snippet-end:[dynamodb.cpp.update_table.code]
7177

0 commit comments

Comments
 (0)