Skip to content

Commit 43e0bf8

Browse files
Making tests opt-out instead of opt-in and update TestVectorRunner
JUnit5 doesn't support test suites yet (see junit-team/junit5#744) and the existing test suites do not support the new JUnit5 tests that are being used for keyrings. This change removes the test suites, and configures Maven to include all tests except those marked with certain JUnit tags. Additionally, this change updates the TestVectorRunner to also test Keyrings and removes the redundant XCompat tests.
1 parent 7ec91d6 commit 43e0bf8

17 files changed

+208
-661
lines changed

pom.xml

+30-10
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<dependency>
5656
<groupId>org.junit.jupiter</groupId>
57-
<artifactId>junit-jupiter-engine</artifactId>
57+
<artifactId>junit-jupiter</artifactId>
5858
<version>5.5.2</version>
5959
<scope>test</scope>
6060
</dependency>
@@ -208,30 +208,50 @@
208208
<artifactId>maven-surefire-plugin</artifactId>
209209
<version>2.22.0</version>
210210
<configuration>
211-
<includes>
212-
<include>**/AllTestsSuite.java</include>
213-
</includes>
211+
<excludedGroups>slow</excludedGroups>
214212
</configuration>
215213
</plugin>
216214
</plugins>
217215
</build>
218216
</profile>
219217

218+
<!-- This test profile is intended to assist in rapid development; it filters out some of the slower,
219+
more exhaustive tests in the overall test suite to allow for a rapid edit-test cycle. -->
220220
<profile>
221221
<id>fast-tests-only</id>
222-
<activation>
223-
<activeByDefault>false</activeByDefault>
224-
</activation>
225222
<build>
226223
<plugins>
227224
<plugin>
228225
<groupId>org.apache.maven.plugins</groupId>
229226
<artifactId>maven-surefire-plugin</artifactId>
230227
<version>2.22.0</version>
231228
<configuration>
232-
<includes>
233-
<include>**/FastTestsOnlySuite.java</include>
234-
</includes>
229+
<excludedGroups>slow, integration</excludedGroups>
230+
<systemPropertyVariables>
231+
<fastTestsOnly>true</fastTestsOnly>
232+
</systemPropertyVariables>
233+
<!-- Require that this fast suite completes relatively quickly. If you're seeing
234+
this timeout get hit, it's time to pare down tests some more. As a general rule of
235+
thumb, we should avoid any single test taking more than 10s, and try to keep the
236+
number of such slow tests to a minimum. -->
237+
<forkedProcessTimeoutInSeconds>120</forkedProcessTimeoutInSeconds>
238+
</configuration>
239+
</plugin>
240+
</plugins>
241+
</build>
242+
</profile>
243+
244+
<!-- This test profile will run only the integration tests. -->
245+
<profile>
246+
<id>integration</id>
247+
<build>
248+
<plugins>
249+
<plugin>
250+
<groupId>org.apache.maven.plugins</groupId>
251+
<artifactId>maven-surefire-plugin</artifactId>
252+
<version>2.22.0</version>
253+
<configuration>
254+
<groups>integration</groups>
235255
</configuration>
236256
</plugin>
237257
</plugins>

src/test/java/com/amazonaws/crypto/examples/BasicEncryptionExampleTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313

1414
package com.amazonaws.crypto.examples;
1515

16+
import com.amazonaws.encryptionsdk.TestUtils;
1617
import com.amazonaws.encryptionsdk.kms.AwsKmsCmkId;
1718
import com.amazonaws.encryptionsdk.kms.KMSTestFixtures;
19+
import org.junit.jupiter.api.Tag;
1820
import org.junit.jupiter.api.Test;
1921

22+
@Tag(TestUtils.TAG_INTEGRATION)
2023
class BasicEncryptionExampleTest {
2124

2225
@Test

src/test/java/com/amazonaws/crypto/examples/EscrowedEncryptExampleTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
package com.amazonaws.crypto.examples;
1515

16+
import com.amazonaws.encryptionsdk.TestUtils;
1617
import com.amazonaws.encryptionsdk.kms.AwsKmsCmkId;
1718
import com.amazonaws.encryptionsdk.kms.KMSTestFixtures;
19+
import org.junit.jupiter.api.Tag;
1820
import org.junit.jupiter.api.Test;
1921

2022
import java.security.GeneralSecurityException;
2123

24+
@Tag(TestUtils.TAG_INTEGRATION)
2225
class EscrowedEncryptExampleTest {
2326

2427
@Test

src/test/java/com/amazonaws/encryptionsdk/AllTestsSuite.java

-63
This file was deleted.

src/test/java/com/amazonaws/encryptionsdk/AwsCryptoTest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
package com.amazonaws.encryptionsdk;
1515

16-
import static com.amazonaws.encryptionsdk.FastTestsOnlySuite.isFastTestSuiteActive;
1716
import static com.amazonaws.encryptionsdk.TestUtils.assertNullChecks;
1817
import static com.amazonaws.encryptionsdk.TestUtils.assertThrows;
18+
import static com.amazonaws.encryptionsdk.TestUtils.isFastTestsOnly;
1919
import static java.util.Collections.singletonMap;
2020
import static org.junit.Assert.assertArrayEquals;
2121
import static org.junit.Assert.assertEquals;
@@ -203,7 +203,7 @@ public void encryptDecrypt() {
203203
for (int j = 0; j < bytesToTest.length; j++) {
204204
final int byteSize = bytesToTest[j];
205205

206-
if (byteSize > 500_000 && isFastTestSuiteActive()) {
206+
if (byteSize > 500_000 && isFastTestsOnly()) {
207207
continue;
208208
}
209209

@@ -232,7 +232,7 @@ public void encryptDecryptWithBadSignature() {
232232
for (int j = 0; j < bytesToTest.length; j++) {
233233
final int byteSize = bytesToTest[j];
234234

235-
if (byteSize > 500_000 && isFastTestSuiteActive()) {
235+
if (byteSize > 500_000 && isFastTestsOnly()) {
236236
continue;
237237
}
238238

@@ -258,7 +258,7 @@ public void encryptDecryptWithParsedCiphertext() {
258258
for (int j = 0; j < bytesToTest.length; j++) {
259259
final int byteSize = bytesToTest[j];
260260

261-
if (byteSize > 500_000 && isFastTestSuiteActive()) {
261+
if (byteSize > 500_000 && isFastTestsOnly()) {
262262
continue;
263263
}
264264

@@ -467,7 +467,7 @@ public void estimateCiphertextSize() {
467467
for (int j = 0; j < bytesToTest.length; j++) {
468468
final int byteSize = bytesToTest[j];
469469

470-
if (byteSize > 500_000 && isFastTestSuiteActive()) {
470+
if (byteSize > 500_000 && isFastTestsOnly()) {
471471
continue;
472472
}
473473

src/test/java/com/amazonaws/encryptionsdk/CryptoInputStreamTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static com.amazonaws.encryptionsdk.TestUtils.assertThrows;
1717
import static com.amazonaws.encryptionsdk.TestUtils.insecureRandomBytes;
18+
import static com.amazonaws.encryptionsdk.TestUtils.isFastTestsOnly;
1819
import static com.amazonaws.encryptionsdk.internal.TestIOUtils.getSha256Hash;
1920
import static org.junit.Assert.assertArrayEquals;
2021
import static org.junit.Assert.assertEquals;
@@ -163,7 +164,7 @@ public static Collection<Object[]> encryptDecryptParams() {
163164
// Our bytesToTest and readLenVals arrays tend to have the bigger numbers towards the end - we'll chop off
164165
// the last few as they take the longest and don't really add that much more coverage.
165166
int skipLastNSizes;
166-
if (!FastTestsOnlySuite.isFastTestSuiteActive()) {
167+
if (!isFastTestsOnly()) {
167168
skipLastNSizes = 0;
168169
} else if (firstAlgorithm) {
169170
// We'll run more tests for the first algorithm in the list - but not go quite so far as running the

src/test/java/com/amazonaws/encryptionsdk/CryptoOutputStreamTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
package com.amazonaws.encryptionsdk;
1515

1616
import static com.amazonaws.encryptionsdk.AwsCrypto.getDefaultFrameSize;
17-
import static com.amazonaws.encryptionsdk.FastTestsOnlySuite.isFastTestSuiteActive;
1817
import static com.amazonaws.encryptionsdk.TestUtils.assertThrows;
1918
import static com.amazonaws.encryptionsdk.TestUtils.insecureRandomBytes;
19+
import static com.amazonaws.encryptionsdk.TestUtils.isFastTestsOnly;
2020
import static com.amazonaws.encryptionsdk.TestUtils.toByteArray;
2121
import static com.amazonaws.encryptionsdk.internal.TestIOUtils.getSha256Hash;
2222
import static org.junit.Assert.assertArrayEquals;
@@ -163,7 +163,7 @@ public static Collection<Object[]> encryptDecryptParams() {
163163
int[] bytesToTest = { 0, 1, frameSize - 1, frameSize, frameSize + 1, (int) (frameSize * 1.5),
164164
frameSize * 2, 1000000 };
165165

166-
if (isFastTestSuiteActive()) {
166+
if (isFastTestsOnly()) {
167167
// Exclude the last two sizes, as they're the slowest
168168
bytesToTest = Arrays.copyOfRange(bytesToTest, 0, bytesToTest.length - 2);
169169
}
@@ -173,7 +173,7 @@ public static Collection<Object[]> encryptDecryptParams() {
173173
final int byteSize = bytesToTest[j];
174174
int[] readLenVals = { byteSize - 1, byteSize, byteSize + 1, byteSize * 2, 1000000 };
175175

176-
if (isFastTestSuiteActive()) {
176+
if (isFastTestsOnly()) {
177177
// Only test one read() call buffer length in the fast tests. This greatly cuts down on
178178
// the combinatorial explosion of test cases here.
179179
readLenVals = Arrays.copyOfRange(readLenVals, 0, 1);

src/test/java/com/amazonaws/encryptionsdk/FastTestsOnlySuite.java

-89
This file was deleted.

src/test/java/com/amazonaws/encryptionsdk/IntegrationTestSuite.java

-15
This file was deleted.

src/test/java/com/amazonaws/encryptionsdk/SlowTestCategory.java

-14
This file was deleted.

0 commit comments

Comments
 (0)