Skip to content

Commit c751356

Browse files
chore(ci): add retries to tests (#507)
1 parent de00ef1 commit c751356

File tree

55 files changed

+533
-525
lines changed

Some content is hidden

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

55 files changed

+533
-525
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
shell: bash
4646

4747
- name: Test
48+
env:
49+
AWS_RETRY_MODE: adaptive
50+
AWS_MAX_ATTEMPTS: '5'
4851
run: |
4952
export AWS_S3EC_TEST_ALT_KMS_KEY_ARN=arn:aws:kms:${{ vars.CI_AWS_REGION }}:${{ secrets.CI_AWS_ACCOUNT_ID }}:key/${{ vars.CI_ALT_KMS_KEY_ID }}
5053
export AWS_S3EC_TEST_ALT_ROLE_ARN=arn:aws:iam::${{ secrets.CI_AWS_ACCOUNT_ID }}:role/service-role/${{ vars.CI_ALT_ROLE }}

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@
120120

121121
<!-- Test Dependencies -->
122122
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
123+
<dependency>
124+
<groupId>org.junit-pioneer</groupId>
125+
<artifactId>junit-pioneer</artifactId>
126+
<version>1.9.1</version>
127+
<scope>test</scope>
128+
</dependency>
123129
<dependency>
124130
<groupId>org.mockito</groupId>
125131
<artifactId>mockito-core</artifactId>

src/test/java/software/amazon/encryption/s3/AdditionalDecryptionKeyMaterialTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package software.amazon.encryption.s3;
44

55
import org.junit.jupiter.api.BeforeAll;
6-
import org.junit.jupiter.api.Test;
6+
import org.junitpioneer.jupiter.RetryingTest;
77
import software.amazon.awssdk.core.ResponseBytes;
88
import software.amazon.awssdk.core.sync.RequestBody;
99
import software.amazon.awssdk.services.s3.S3Client;
@@ -65,7 +65,7 @@ public static void setUp() throws NoSuchAlgorithmException {
6565
* Test AES keyring with null additionalDecryptionKeyMaterial map.
6666
* This tests the default behavior when no additional key material is provided.
6767
*/
68-
@Test
68+
@RetryingTest(3)
6969
public void testAesKeyringWithNullAdditionalKeyMaterial() {
7070
final String objectKey = appendTestSuffix("aes-null-additional-key-material");
7171
final String input = "AES with null additional key material";
@@ -129,7 +129,7 @@ public void testAesKeyringWithNullAdditionalKeyMaterial() {
129129
* Test AES keyring with empty additionalDecryptionKeyMaterial map.
130130
* This tests the behavior when an empty map is provided.
131131
*/
132-
@Test
132+
@RetryingTest(3)
133133
public void testAesKeyringWithEmptyAdditionalKeyMaterial() {
134134
final String objectKey = appendTestSuffix("aes-empty-additional-key-material");
135135
final String input = "AES with empty additional key material";
@@ -194,7 +194,7 @@ public void testAesKeyringWithEmptyAdditionalKeyMaterial() {
194194
* Test AES keyring with a singleton additionalDecryptionKeyMaterial map.
195195
* This tests the behavior when a single additional key material is provided.
196196
*/
197-
@Test
197+
@RetryingTest(3)
198198
public void testAesKeyringWithSingletonAdditionalKeyMaterial() {
199199
final String objectKey = appendTestSuffix("aes-singleton-additional-key-material");
200200
final String input = "AES with singleton additional key material";
@@ -265,7 +265,7 @@ public void testAesKeyringWithSingletonAdditionalKeyMaterial() {
265265
* Test AES keyring with multiple entries in the additionalDecryptionKeyMaterial map.
266266
* This tests the behavior when multiple additional key materials are provided.
267267
*/
268-
@Test
268+
@RetryingTest(3)
269269
public void testAesKeyringWithMultipleAdditionalKeyMaterials() {
270270
final String objectKey = appendTestSuffix("aes-multiple-additional-key-materials");
271271
final String input = "AES with multiple additional key materials";
@@ -348,7 +348,7 @@ public void testAesKeyringWithMultipleAdditionalKeyMaterials() {
348348
* Test AES keyring with additionalDecryptionKeyMaterial that doesn't match.
349349
* This tests the behavior when no matching key material is found and it should fall back to the default key.
350350
*/
351-
@Test
351+
@RetryingTest(3)
352352
public void testAesKeyringWithNonMatchingAdditionalKeyMaterial() {
353353
final String objectKey = appendTestSuffix("aes-non-matching-additional-key-material");
354354
final String input = "AES with non-matching additional key material";
@@ -423,7 +423,7 @@ public void testAesKeyringWithNonMatchingAdditionalKeyMaterial() {
423423
* Test AES keyring with additionalDecryptionKeyMaterial that doesn't match and a wrong default key.
424424
* This tests the behavior when no matching key material is found and the default key is also wrong.
425425
*/
426-
@Test
426+
@RetryingTest(3)
427427
public void testAesKeyringWithNonMatchingAdditionalKeyMaterialAndWrongDefaultKey() {
428428
final String objectKey = appendTestSuffix("aes-non-matching-additional-key-material-wrong-default");
429429
final String input = "AES with non-matching additional key material and wrong default key";
@@ -494,7 +494,7 @@ public void testAesKeyringWithNonMatchingAdditionalKeyMaterialAndWrongDefaultKey
494494
* Test RSA keyring with null additionalDecryptionKeyMaterial map.
495495
* This tests the default behavior when no additional key material is provided.
496496
*/
497-
@Test
497+
@RetryingTest(3)
498498
public void testRsaKeyringWithNullAdditionalKeyMaterial() {
499499
final String objectKey = appendTestSuffix("rsa-null-additional-key-material");
500500
final String input = "RSA with null additional key material";
@@ -564,7 +564,7 @@ public void testRsaKeyringWithNullAdditionalKeyMaterial() {
564564
* Test RSA keyring with empty additionalDecryptionKeyMaterial map.
565565
* This tests the behavior when an empty map is provided.
566566
*/
567-
@Test
567+
@RetryingTest(3)
568568
public void testRsaKeyringWithEmptyAdditionalKeyMaterial() {
569569
final String objectKey = appendTestSuffix("rsa-empty-additional-key-material");
570570
final String input = "RSA with empty additional key material";
@@ -635,7 +635,7 @@ public void testRsaKeyringWithEmptyAdditionalKeyMaterial() {
635635
* Test RSA keyring with a singleton additionalDecryptionKeyMaterial map.
636636
* This tests the behavior when a single additional key material is provided.
637637
*/
638-
@Test
638+
@RetryingTest(3)
639639
public void testRsaKeyringWithSingletonAdditionalKeyMaterial() {
640640
final String objectKey = appendTestSuffix("rsa-singleton-additional-key-material");
641641
final String input = "RSA with singleton additional key material";
@@ -715,7 +715,7 @@ public void testRsaKeyringWithSingletonAdditionalKeyMaterial() {
715715
* Test RSA keyring with multiple entries in the additionalDecryptionKeyMaterial map.
716716
* This tests the behavior when multiple additional key materials are provided.
717717
*/
718-
@Test
718+
@RetryingTest(3)
719719
public void testRsaKeyringWithMultipleAdditionalKeyMaterials() {
720720
final String objectKey = appendTestSuffix("rsa-multiple-additional-key-materials");
721721
final String input = "RSA with multiple additional key materials";
@@ -810,7 +810,7 @@ public void testRsaKeyringWithMultipleAdditionalKeyMaterials() {
810810
* Test RSA keyring with additionalDecryptionKeyMaterial that doesn't match.
811811
* This tests the behavior when no matching key material is found and it should fall back to the default key.
812812
*/
813-
@Test
813+
@RetryingTest(3)
814814
public void testRsaKeyringWithNonMatchingAdditionalKeyMaterial() {
815815
final String objectKey = appendTestSuffix("rsa-non-matching-additional-key-material");
816816
final String input = "RSA with non-matching additional key material";
@@ -894,7 +894,7 @@ public void testRsaKeyringWithNonMatchingAdditionalKeyMaterial() {
894894
* Test RSA keyring with additionalDecryptionKeyMaterial that doesn't match and a wrong default key.
895895
* This tests the behavior when no matching key material is found and the default key is also wrong.
896896
*/
897-
@Test
897+
@RetryingTest(3)
898898
public void testRsaKeyringWithNonMatchingAdditionalKeyMaterialAndWrongDefaultKey() {
899899
final String objectKey = appendTestSuffix("rsa-non-matching-additional-key-material-wrong-default");
900900
final String input = "RSA with non-matching additional key material and wrong default key";

src/test/java/software/amazon/encryption/s3/ParameterMalleabilityTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package software.amazon.encryption.s3;
22

33
import org.junit.jupiter.api.BeforeAll;
4-
import org.junit.jupiter.api.Test;
4+
import org.junitpioneer.jupiter.RetryingTest;
55
import software.amazon.awssdk.core.ResponseInputStream;
66
import software.amazon.awssdk.core.sync.RequestBody;
77
import software.amazon.awssdk.services.s3.S3Client;
@@ -30,7 +30,7 @@ public static void setUp() throws NoSuchAlgorithmException {
3030
AES_KEY = keyGen.generateKey();
3131
}
3232

33-
@Test
33+
@RetryingTest(3)
3434
public void contentEncryptionDowngradeAttackFails() {
3535
final String objectKey = appendTestSuffix("content-downgrade-attack-fails");
3636
S3Client s3Client = S3EncryptionClient.builderV4()
@@ -74,7 +74,7 @@ public void contentEncryptionDowngradeAttackFails() {
7474
s3Client.close();
7575
}
7676

77-
@Test
77+
@RetryingTest(3)
7878
public void keyWrapRemovalAttackFails() {
7979
final String objectKey = appendTestSuffix("keywrap-removal-attack-fails");
8080
S3Client s3Client = S3EncryptionClient.builderV4()
@@ -116,7 +116,7 @@ public void keyWrapRemovalAttackFails() {
116116
s3Client.close();
117117
}
118118

119-
@Test
119+
@RetryingTest(3)
120120
public void keyWrapDowngradeAesWrapAttackFails() {
121121
final String objectKey = appendTestSuffix("keywrap-downgrade-aeswrap-attack-fails");
122122
S3Client s3Client = S3EncryptionClient.builderV4()
@@ -159,7 +159,7 @@ public void keyWrapDowngradeAesWrapAttackFails() {
159159
s3Client.close();
160160
}
161161

162-
@Test
162+
@RetryingTest(3)
163163
public void keyWrapDowngradeAesAttackFails() {
164164
final String objectKey = appendTestSuffix("keywrap-downgrade-aes-attack-fails");
165165
S3Client s3Client = S3EncryptionClient.builderV4()

0 commit comments

Comments
 (0)