Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadic test failing with OOM #4053

Merged
merged 4 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/test-on-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ jobs:
mvn -Dtest=$TESTS clean compile test
fi
env:
JVM_OPTS: "-XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -XX:HeapDumpPath=${{ runner.temp }}/heapdump-${{ matrix.redis_version }}.hprof"
TESTS: ${{ github.event.inputs.specific_test || '' }}
- name: Upload Heap Dumps
if: failure()
uses: actions/upload-artifact@v4
with:
name: heap-dumps-${{ matrix.redis_version }}
path: ${{ runner.temp }}/heapdump-${{ matrix.redis_version }}.hprof
retention-days: 5
- name: Upload Surefire Dump File
uses: actions/upload-artifact@v3
with:
name: surefire-dumpstream
path: target/surefire-reports/*.dumpstream
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<argLine>${JVM_OPTS}</argLine>
<systemPropertyVariables>
<redis-hosts>${redis-hosts}</redis-hosts>
</systemPropertyVariables>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ public void withExpirationRefreshRatio_testJedisAuthXManagerTriggersEvict() thro
AuthXManager jedisAuthXManager = new AuthXManager(tokenManager);

AtomicInteger numberOfEvictions = new AtomicInteger(0);
ConnectionPool pool = new ConnectionPool(hnp,

try (ConnectionPool pool = new ConnectionPool(hnp,
endpoint.getClientConfigBuilder().authXManager(jedisAuthXManager).build()) {
@Override
public void evict() throws Exception {
numberOfEvictions.incrementAndGet();
super.evict();
}
};

await().pollInterval(ONE_HUNDRED_MILLISECONDS).atMost(FIVE_HUNDRED_MILLISECONDS)
.until(numberOfEvictions::get, Matchers.greaterThanOrEqualTo(1));
}) {
await().pollInterval(ONE_HUNDRED_MILLISECONDS).atMost(FIVE_HUNDRED_MILLISECONDS)
.until(numberOfEvictions::get, Matchers.greaterThanOrEqualTo(1));
}
}

public void withLowerRefreshBounds_testJedisAuthXManagerTriggersEvict() throws Exception {
Expand All @@ -97,17 +98,18 @@ public void withLowerRefreshBounds_testJedisAuthXManagerTriggersEvict() throws E
AuthXManager jedisAuthXManager = new AuthXManager(tokenManager);

AtomicInteger numberOfEvictions = new AtomicInteger(0);
ConnectionPool pool = new ConnectionPool(endpoint.getHostAndPort(),

try (ConnectionPool pool = new ConnectionPool(endpoint.getHostAndPort(),
endpoint.getClientConfigBuilder().authXManager(jedisAuthXManager).build()) {
@Override
public void evict() throws Exception {
numberOfEvictions.incrementAndGet();
super.evict();
}
};

await().pollInterval(ONE_HUNDRED_MILLISECONDS).atMost(FIVE_HUNDRED_MILLISECONDS)
.until(numberOfEvictions::get, Matchers.greaterThanOrEqualTo(1));
}) {
await().pollInterval(ONE_HUNDRED_MILLISECONDS).atMost(FIVE_HUNDRED_MILLISECONDS)
.until(numberOfEvictions::get, Matchers.greaterThanOrEqualTo(1));
}
}

public static class TokenManagerConfigWrapper extends TokenManagerConfig {
Expand Down Expand Up @@ -227,8 +229,12 @@ public void testAuthXManagerReceivesNewToken()
return null;
}).when(manager).authenticateConnections(any());

manager.start();
assertEquals(tokenHolder[0].getValue(), "tokenVal");
try {
manager.start();
assertEquals(tokenHolder[0].getValue(), "tokenVal");
} finally {
manager.stop();
}
}

@Test
Expand Down Expand Up @@ -292,14 +298,18 @@ public void testTokenManagerWithFailingTokenRequest()
TokenManager tokenManager = new TokenManager(identityProvider, new TokenManagerConfig(0.7F, 200,
2000, new TokenManagerConfig.RetryPolicy(numberOfRetries - 1, 100)));

TokenListener listener = mock(TokenListener.class);
tokenManager.start(listener, false);
requesLatch.await();
await().pollDelay(ONE_HUNDRED_MILLISECONDS).atMost(FIVE_HUNDRED_MILLISECONDS)
.untilAsserted(() -> verify(listener).onTokenRenewed(argument.capture()));
verify(identityProvider, times(numberOfRetries)).requestToken();
verify(listener, never()).onError(any());
assertEquals("tokenValX", argument.getValue().getValue());
try {
TokenListener listener = mock(TokenListener.class);
tokenManager.start(listener, false);
requesLatch.await();
await().pollDelay(ONE_HUNDRED_MILLISECONDS).atMost(FIVE_HUNDRED_MILLISECONDS)
.untilAsserted(() -> verify(listener).onTokenRenewed(argument.capture()));
verify(identityProvider, times(numberOfRetries)).requestToken();
verify(listener, never()).onError(any());
assertEquals("tokenValX", argument.getValue().getValue());
} finally {
tokenManager.stop();
}
}

@Test
Expand Down Expand Up @@ -328,15 +338,19 @@ public void testTokenManagerWithHangingTokenRequest()
executionTimeout, new TokenManagerConfig.RetryPolicy(numberOfRetries, 100)));

AuthXManager manager = spy(new AuthXManager(tokenManager));
AuthXEventListener listener = mock(AuthXEventListener.class);
manager.setListener(listener);
manager.start();
requesLatch.await();
verify(listener, never()).onIdentityProviderError(any());
verify(listener, never()).onConnectionAuthenticationError(any());

await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> {
verify(manager, times(1)).authenticateConnections(any());
});
try {
AuthXEventListener listener = mock(AuthXEventListener.class);
manager.setListener(listener);
manager.start();
requesLatch.await();
verify(listener, never()).onIdentityProviderError(any());
verify(listener, never()).onConnectionAuthenticationError(any());

await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> {
verify(manager, times(1)).authenticateConnections(any());
});
} finally {
manager.stop();
}
}
}
Loading