Skip to content

Commit

Permalink
Take write lock on global provider in EvpKeyFactoryTest
Browse files Browse the repository at this point in the history
We've recently seen some internal dry-run build failures, likely due to
increased concurrency on beefy internal build hosts (see [here][1] and
[here][2]). These failures manifested with this tell-tale signature:

```
  JUnit Jupiter:EvpKeyFactoryTest:ecPrivate(KeyPair, String, boolean):EC-521, Translate: false
    MethodSource [className = 'com.amazon.nativejcebindings.test.EvpKeyFactoryTest', methodName = 'ecPrivate', methodParameterTypes = 'java.security.KeyPair, java.lang.String, boolean']
    => org.opentest4j.AssertionFailedError: expected: <sun.security.ec.ECPrivateKeyImpl@ffff6867> but was: <com.amazon.nativejcebindings.EvpEcPrivateKey@ffff65db>
...
       com.amazon.nativejcebindings.test.EvpKeyFactoryTest.getSamples(EvpKeyFactoryTest.java:414)
       com.amazon.nativejcebindings.test.EvpKeyFactoryTest.ecPrivate(EvpKeyFactoryTest.java:298)
       java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
  JUnit Jupiter:EvpKeyFactoryTest:ecPrivate(KeyPair, String, boolean):EC-521, Translate: true
    MethodSource [className = 'com.amazon.nativejcebindings.test.EvpKeyFactoryTest', methodName = 'ecPrivate', methodParameterTypes = 'java.security.KeyPair, java.lang.String, boolean']
    => org.opentest4j.AssertionFailedError: expected: <sun.security.ec.ECPrivateKeyImpl@ffff6867> but was: <com.amazon.nativejcebindings.EvpEcPrivateKey@ffff65db>
...
       com.amazon.nativejcebindings.test.EvpKeyFactoryTest.getSamples(EvpKeyFactoryTest.java:414)
       com.amazon.nativejcebindings.test.EvpKeyFactoryTest.ecPrivate(EvpKeyFactoryTest.java:298)
       java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
  JUnit Jupiter:EvpKeyFactoryTest:ecPrivateKeySpec(KeyPair, String):EC-521
    MethodSource [className = 'com.amazon.nativejcebindings.test.EvpKeyFactoryTest', methodName = 'ecPrivateKeySpec', methodParameterTypes = 'java.security.KeyPair, java.lang.String']
    => org.opentest4j.AssertionFailedError: Encoded ==> array lengths differ, expected: <97> but was: <98>
...
       com.amazon.nativejcebindings.test.EvpKeyFactoryTest.getSamples(EvpKeyFactoryTest.java:484)
       com.amazon.nativejcebindings.test.EvpKeyFactoryTest.ecPrivateKeySpec(EvpKeyFactoryTest.java:314)
       java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
```

So, we take a write lock on the global provider to ensure no other
concurrently executing test is polluting the EvpKeyFactoryTest's JVM
provider state.

[1]: https://build.amazon.com/6039753402
[2]: https://build.amazon.com/6039762971
  • Loading branch information
WillChilds-Klein committed Jul 8, 2022
1 parent b91e2df commit 63f3fe2
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
@ExtendWith(TestResultLogger.class)
@Execution(ExecutionMode.CONCURRENT)
@ResourceLock(value = TestUtil.RESOURCE_GLOBAL, mode = ResourceAccessMode.READ)
@ResourceLock(value = TestUtil.RESOURCE_PROVIDER, mode = ResourceAccessMode.READ_WRITE)
public class EvpKeyFactoryTest {
private static final Set<String> ALGORITHMS = new HashSet<>();
private static final Map<String, List<Arguments>> KEYPAIRS = new HashMap<>();
Expand Down

0 comments on commit 63f3fe2

Please sign in to comment.