-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
KAFKA-14396: De-flake memory tests with new TestUtils.restrictMemory #12995
base: trunk
Are you sure you want to change the base?
KAFKA-14396: De-flake memory tests with new TestUtils.restrictMemory #12995
Conversation
Rather than relying on measuring Runtime::freeMemory() and calling System.gc(), tests which want to assert that there are to excessive allocations should execute in a restricted-memory environment. In order to do this, add a new TestUtil method which intentionally consumes memory in a way that allows tests to assert that the code under test does not over-allocate or leak memory. This is a temporary effect on a single JVM, and is reverted as soon as the test code completes. Apply this fix to MemoryRecordsBuilderTest::testBuffersDereferencedOnClose(), which now fails if the eponymous close() call is omitted. Signed-off-by: Greg Harris <greg.harris@aiven.io>
Also something I noticed through removing the close() call: none and gzip each pass the test, despite never having close() called. |
The challenge is that the JVM continues to be reused for several tests afterwards. Once you get an OOM, it can leave lasting effects. |
Signed-off-by: Greg Harris <greg.harris@aiven.io>
@ijuma Thanks for pointing that out. I never noticed any effects of the OOMEs on the persistent JVM or other tests, but if I'm trying to de-flake the tests, introducing a new kind of flakiness that's even harder to debug is certainly not a good idea. I've taken the high memory-pressure tests that I know of, and moved them from the This means that these specific tests (three once i'm finished) will no longer be run as part of Thanks! |
Signed-off-by: Greg Harris <greg.harris@aiven.io>
Signed-off-by: Greg Harris <greg.harris@aiven.io>
Rather than relying on measuring Runtime::freeMemory() and calling System.gc(), tests which want to assert that there are no excessive allocations should execute in a restricted-memory environment.
In order to do this, add a new TestUtil method which intentionally consumes memory in a way that allows tests to assert that the code under test does not over-allocate or leak memory. This is a temporary effect on a single JVM, and is reverted as soon as the test code completes.
Apply this fix to MemoryRecordsBuilderTest::testBuffersDereferencedOnClose(), which now fails if the eponymous close() call is omitted.
Signed-off-by: Greg Harris greg.harris@aiven.io
Committer Checklist (excluded from commit message)