Skip to content

Commit 5401b04

Browse files
authored
chore: Examples run serially. Examples wait for GSI. No extra checkout (#561)
1 parent 403dfac commit 5401b04

File tree

4 files changed

+50
-27
lines changed

4 files changed

+50
-27
lines changed

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/searchableencryption/CompoundBeaconSearchableEncryptionExample.java

+23-10
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,29 @@ public static void PutAndQueryItemWithCompoundBeacon(DynamoDbClient ddb, String
298298
.expressionAttributeValues(expressionAttributeValues)
299299
.build();
300300

301-
QueryResponse queryResponse = ddb.query(queryRequest);
302-
List<Map<String, AttributeValue>> attributeValues = queryResponse.items();
303-
// Validate query was returned successfully
304-
assert 200 == queryResponse.sdkHttpResponse().statusCode();
305-
// Validate only 1 item was returned: the item we just put
306-
assert attributeValues.size() == 1;
307-
Map<String, AttributeValue> returnedItem = attributeValues.get(0);
308-
// Validate the item has the expected attributes
309-
assert returnedItem.get("inspector_id_last4").s().equals("5678");
310-
assert returnedItem.get("unit").s().equals("011899988199");
301+
// GSIs do not update instantly
302+
// so if the results come back empty
303+
// we retry after a short sleep
304+
for (int i=0; i<10; ++i) {
305+
QueryResponse queryResponse = ddb.query(queryRequest);
306+
List<Map<String, AttributeValue>> attributeValues = queryResponse.items();
307+
// Validate query was returned successfully
308+
assert 200 == queryResponse.sdkHttpResponse().statusCode();
309+
310+
// if no results, sleep and try again
311+
if (attributeValues.size() == 0) {
312+
try {Thread.sleep(20);} catch (Exception e) {}
313+
continue;
314+
}
315+
316+
// Validate only 1 item was returned: the item we just put
317+
assert attributeValues.size() == 1;
318+
Map<String, AttributeValue> returnedItem = attributeValues.get(0);
319+
// Validate the item has the expected attributes
320+
assert returnedItem.get("inspector_id_last4").s().equals("5678");
321+
assert returnedItem.get("unit").s().equals("011899988199");
322+
break;
323+
}
311324
}
312325

313326
public static void main(final String[] args) {

Examples/runtimes/java/DynamoDbEncryption/src/main/java/software/amazon/cryptography/examples/searchableencryption/VirtualBeaconSearchableEncryptionExample.java

+23-10
Original file line numberDiff line numberDiff line change
@@ -407,16 +407,29 @@ public static void PutItemQueryItemWithVirtualBeacon(String ddbTableName, String
407407
.expressionAttributeValues(expressionAttributeValues)
408408
.build();
409409

410-
final QueryResponse queryResponse = ddb.query(queryRequest);
411-
List<Map<String, AttributeValue>> attributeValues = queryResponse.items();
412-
// Validate query was returned successfully
413-
assert 200 == queryResponse.sdkHttpResponse().statusCode();
414-
// Validate only 1 item was returned: the item with the expected attributes
415-
assert attributeValues.size() == 1;
416-
final Map<String, AttributeValue> returnedItem = attributeValues.get(0);
417-
// Validate the item has the expected attributes
418-
assert returnedItem.get("state").s().equals("CA");
419-
assert returnedItem.get("hasTestResult").bool().equals(true);
410+
// GSIs do not update instantly
411+
// so if the results come back empty
412+
// we retry after a short sleep
413+
for (int i=0; i<10; ++i) {
414+
final QueryResponse queryResponse = ddb.query(queryRequest);
415+
List<Map<String, AttributeValue>> attributeValues = queryResponse.items();
416+
// Validate query was returned successfully
417+
assert 200 == queryResponse.sdkHttpResponse().statusCode();
418+
419+
// if no results, sleep and try again
420+
if (attributeValues.size() == 0) {
421+
try {Thread.sleep(20);} catch (Exception e) {}
422+
continue;
423+
}
424+
425+
// Validate only 1 item was returned: the item with the expected attributes
426+
assert attributeValues.size() == 1;
427+
final Map<String, AttributeValue> returnedItem = attributeValues.get(0);
428+
// Validate the item has the expected attributes
429+
assert returnedItem.get("state").s().equals("CA");
430+
assert returnedItem.get("hasTestResult").bool().equals(true);
431+
break;
432+
}
420433
}
421434

422435
public static void main(final String[] args) {

codebuild/release/release-prod.yml

-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
version: 0.2
55

66
env:
7-
variables:
8-
BRANCH: "main"
97
parameter-store:
108
ACCOUNT: /CodeBuild/AccountId
119
secrets-manager:
@@ -31,7 +29,6 @@ phases:
3129
- cd aws-database-encryption-sdk-dynamodb-java/
3230
pre_build:
3331
commands:
34-
- git checkout $BRANCH
3532
- aws secretsmanager get-secret-value --region us-west-2 --secret-id Maven-GPG-Keys-Release --query SecretBinary --output text | base64 -d > ~/mvn_gpg.tgz
3633
- tar -xvf ~/mvn_gpg.tgz -C ~
3734
# Create default location where GPG looks for creds and keys

codebuild/release/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ batch:
2828

2929
- identifier: validate_staging_corretto11
3030
depend-on:
31-
- release_staging
31+
- validate_staging_corretto8
3232
buildspec: codebuild/staging/validate-staging.yml
3333
env:
3434
variables:
@@ -38,7 +38,7 @@ batch:
3838

3939
- identifier: validate_staging_corretto17
4040
depend-on:
41-
- release_staging
41+
- validate_staging_corretto11
4242
buildspec: codebuild/staging/validate-staging.yml
4343
env:
4444
variables:
@@ -73,7 +73,7 @@ batch:
7373

7474
- identifier: validate_release_corretto11
7575
depend-on:
76-
- upload_to_sonatype
76+
- validate_release_corretto8
7777
buildspec: codebuild/release/validate-release.yml
7878
env:
7979
variables:
@@ -83,7 +83,7 @@ batch:
8383

8484
- identifier: validate_release_corretto17
8585
depend-on:
86-
- upload_to_sonatype
86+
- validate_release_corretto11
8787
buildspec: codebuild/release/validate-release.yml
8888
env:
8989
variables:

0 commit comments

Comments
 (0)