Skip to content

Commit

Permalink
- fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
atakavci committed Dec 9, 2024
1 parent 1ec5239 commit 7d3a0ae
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,17 @@ public void withCertificate_azureServicePrincipalIntegrationTest() {
public void renewalDuringOperationsTest() throws InterruptedException, ExecutionException {
// set the stage with consecutive get/set operations with unique keys which takes at least for 2000 ms with a jedispooled instace,
// configure token manager to renew token approximately every 100ms
// wait till all operations are completed and verify that token was renewed at least 20 times after initial token acquisition
// wait till all operations are completed and verify that token was renewed at least 10 times after initial token acquisition
// Additional note: Assumptions made on the time taken for token renewal and operations are based on the current implementation and may vary in future
// Assumptions:
// - TTL of token is 2 hour
// - expirationRefreshRatio is 0.000001F
// - renewal delay is 7 ms each time a token is acquired
// - each auth command takes 40 ms in total to complete(considering the cloud test environments)
// - each auth command would need to wait for an ongoing customer operation(GET/SET/DEL) to complete, which would take another 40 ms
// - each renewal happens in 40+40+7 = 87 ms
// - total number of renewals would be 2000 / 87 = 22.9885 ~ 23
// - to avoid a flaky test results, we will consider approximately half of it as 10 renewals
TokenAuthConfig tokenAuthConfig = EntraIDTokenAuthConfigBuilder.builder()
.clientId(testCtx.getClientId()).secret(testCtx.getClientSecret())
.authority(testCtx.getAuthority()).scopes(testCtx.getRedisScopes())
Expand Down Expand Up @@ -228,7 +238,7 @@ public void renewalDuringOperationsTest() throws InterruptedException, Execution
task.get();
}

verify(hook, atLeast(20)).accept(any());
verify(hook, atLeast(10)).accept(any());
executor.shutdown();
}
}
Expand Down Expand Up @@ -299,7 +309,7 @@ public void connectionAuthWithExpiredTokenTest() {
IdentityProvider idp = new EntraIDIdentityProviderConfig(
new ServicePrincipalInfo(testCtx.getClientId(), testCtx.getClientSecret(),
testCtx.getAuthority()),
testCtx.getRedisScopes(),1000).getProvider();
testCtx.getRedisScopes(), 1000).getProvider();

IdentityProvider mockIdentityProvider = mock(IdentityProvider.class);
AtomicReference<Token> token = new AtomicReference<>();
Expand Down

0 comments on commit 7d3a0ae

Please sign in to comment.