Skip to content

Commit 7fc4eaf

Browse files
Merge branch 'main' into reuse-install_smithy_dafny_codegen_dependencies-actions
2 parents 80dddf0 + ab622af commit 7fc4eaf

42 files changed

Lines changed: 236 additions & 43 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Examples/runtimes/java/DDBECwithSDKV2/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dependencies {
7373
implementation("software.amazon.awssdk:dynamodb")
7474
implementation("software.amazon.awssdk:dynamodb-enhanced")
7575
implementation("software.amazon.awssdk:kms")
76-
76+
7777
testImplementation("org.testng:testng:7.5")
7878
}
7979

Examples/runtimes/java/DDBECwithSDKV2/src/test/java/AsymmetricEncryptedItemTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class AsymmetricEncryptedItemTest {
1313
final String partitionKeyValue = "AsymmetricExample-" + UUID.randomUUID();
1414
final String sortKeyValue = "0";
1515

16-
@Test
16+
@Test(retryAnalyzer = RetryAnalyzer.class)
1717
public void testAsymmetricEncryption() throws Exception {
1818
try (final DynamoDbClient ddbClient = DynamoDbClient.create()) {
1919
AsymmetricEncryptedItem.encryptRecord(

Examples/runtimes/java/DDBECwithSDKV2/src/test/java/AwsKmsEncryptedItemTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class AwsKmsEncryptedItemTest {
1414
final String partitionKeyName = "partition_key";
1515
final String sortKeyName = "sort_key";
1616

17-
@Test
17+
@Test(retryAnalyzer = RetryAnalyzer.class)
1818
public void testAwsKmsEncryption() throws Exception {
1919
try (final DynamoDbClient ddbClient = DynamoDbClient.create()) {
2020
AwsKmsEncryptedItem.encryptRecord(
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
import java.util.logging.Logger;
5+
import org.testng.IRetryAnalyzer;
6+
import org.testng.ITestResult;
7+
8+
// RetryAnalyzer is intentionally duplicated across all examples project as exampels are intentionally self-contained
9+
// so users of the library can copy a single project without pulling in shared infrastructure.
10+
public class RetryAnalyzer implements IRetryAnalyzer {
11+
12+
private static final Logger logger = Logger.getLogger(
13+
RetryAnalyzer.class.getName()
14+
);
15+
private int retryCount = 0;
16+
private static final int maxRetryCount = 3;
17+
18+
@Override
19+
public boolean retry(ITestResult result) {
20+
if (retryCount < maxRetryCount) {
21+
retryCount++;
22+
logger.info(
23+
String.format(
24+
"Retrying test '%s' - attempt %d/%d",
25+
result.getName(),
26+
retryCount,
27+
maxRetryCount
28+
)
29+
);
30+
try {
31+
Thread.sleep(5000L * (long) Math.pow(2, retryCount - 1)); // simple exponential backoff
32+
} catch (InterruptedException e) {
33+
Thread.currentThread().interrupt();
34+
}
35+
return true;
36+
}
37+
return false;
38+
}
39+
}

Examples/runtimes/java/DDBECwithSDKV2/src/test/java/SymmetricEncryptedItemTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class SymmetricEncryptedItemTest {
1616
final String partitionKeyValue = "SymmetricExample-" + UUID.randomUUID();
1717
final String sortKeyValue = "0";
1818

19-
@Test
19+
@Test(retryAnalyzer = RetryAnalyzer.class)
2020
public void testSymmetricEncryption() throws Exception {
2121
// Generate random keys
2222
final SecureRandom secureRandom = new SecureRandom();
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.amazon.cryptography.examples;
5+
6+
import java.util.logging.Logger;
7+
import org.testng.IRetryAnalyzer;
8+
import org.testng.ITestResult;
9+
10+
// RetryAnalyzer is intentionally duplicated across all examples project as exampels are intentionally self-contained
11+
// so users of the library can copy a single project without pulling in shared infrastructure.
12+
public class RetryAnalyzer implements IRetryAnalyzer {
13+
14+
private static final Logger logger = Logger.getLogger(
15+
RetryAnalyzer.class.getName()
16+
);
17+
private int retryCount = 0;
18+
private static final int maxRetryCount = 3;
19+
20+
@Override
21+
public boolean retry(ITestResult result) {
22+
if (retryCount < maxRetryCount) {
23+
retryCount++;
24+
logger.info(
25+
String.format(
26+
"Retrying test '%s' - attempt %d/%d",
27+
result.getName(),
28+
retryCount,
29+
maxRetryCount
30+
)
31+
);
32+
try {
33+
Thread.sleep(5000L * (long) Math.pow(2, retryCount - 1)); // simple exponential backoff
34+
} catch (InterruptedException e) {
35+
Thread.currentThread().interrupt();
36+
}
37+
return true;
38+
}
39+
return false;
40+
}
41+
}

Examples/runtimes/java/DynamoDbEncryption/src/test/java/software/amazon/cryptography/examples/TestBasicPutGetExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class TestBasicPutGetExample {
77

8-
@Test
8+
@Test(retryAnalyzer = RetryAnalyzer.class)
99
public void TestPutGet() {
1010
final String partitionKeyValue = "BasicPutGetExample" + UUID.randomUUID();
1111
BasicPutGetExample.PutItemGetItem(

Examples/runtimes/java/DynamoDbEncryption/src/test/java/software/amazon/cryptography/examples/TestCreateKeyStoreKeyExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class TestCreateKeyStoreKeyExample {
88

9-
@Test
9+
@Test(retryAnalyzer = RetryAnalyzer.class)
1010
public void TestCreateKeyStoreKeyExample() {
1111
String keyId = CreateKeyStoreKeyExample.KeyStoreCreateKey(
1212
TestUtils.TEST_KEYSTORE_NAME,

Examples/runtimes/java/DynamoDbEncryption/src/test/java/software/amazon/cryptography/examples/TestCreateKeyStoreTableExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class TestCreateKeyStoreTableExample {
66

7-
@Test
7+
@Test(retryAnalyzer = RetryAnalyzer.class)
88
public void TestCreateKeyStoreTableExample() {
99
CreateKeyStoreTableExample.KeyStoreCreateTable(
1010
TestUtils.TEST_KEYSTORE_NAME,

Examples/runtimes/java/DynamoDbEncryption/src/test/java/software/amazon/cryptography/examples/TestGetEncryptedDataKeyDescriptionExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
public class TestGetEncryptedDataKeyDescriptionExample {
77

8-
@Test
8+
@Test(retryAnalyzer = RetryAnalyzer.class)
99
public void TestGetEncryptedDataKeyDescription() {
1010
final String partitionKeyValue =
1111
"GetEncryptedDataKeyDescriptionExample" + UUID.randomUUID();

0 commit comments

Comments
 (0)