-
Notifications
You must be signed in to change notification settings - Fork 3k
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
More EvictableCache tests #14502
More EvictableCache tests #14502
Conversation
2095bf9
to
23a484c
Compare
|
||
assertThat(loads.get()) | ||
// At most two loads per key (one before expiration and potential one more after ttl elapsed) | ||
.isLessThanOrEqualTo(6); // TODO should be 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being addressed by #14476
cache.getUnchecked(11); | ||
cache.getUnchecked(22); | ||
while (stopwatch.elapsed(MILLISECONDS) <= ttl) { | ||
assertThat(loads.get()).isBetween(2, 6); // TODO should be always 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is being addressed by #14476
23a484c
to
0dd7857
Compare
lib/trino-collect/src/test/java/io/trino/collect/cache/TestEvictableCache.java
Show resolved
Hide resolved
assertEquals(((EvictableCache<?, ?>) cache).tokensCount(), maximumSize); | ||
|
||
// Ensure cache is effective, i.e. some entries preserved | ||
int lastKey = 10_000 - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extract 10_000 to variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i chose not to apply this one, hope it's fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah :)
lib/trino-collect/src/test/java/io/trino/collect/cache/TestEvictableCache.java
Outdated
Show resolved
Hide resolved
// Ensure cache is effective, i.e. no new load | ||
int lastKey = 10_000 - 1; | ||
assertEquals((Object) cache.get(lastKey), "abc" + lastKey); | ||
assertEquals(loads.get(), 10_000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract 10_000
lib/trino-collect/src/test/java/io/trino/collect/cache/TestEvictableLoadingCache.java
Outdated
Show resolved
Hide resolved
It was recently discovered we lack a test ensuring that time-based cache has it's entries evicted, and not e.g. using unbounded amount of memory.
0dd7857
to
02a4626
Compare
AC |
ticker.increment(ttl, MILLISECONDS); | ||
// Should be reloaded | ||
assertEquals(cache.get(key, () -> "new value"), "new value"); | ||
// TODO (https://github.com/trinodb/trino/issues/14545) tokensCount should be 1; 0 means we lost the token for a live entry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #14545
In #14476 (comment) it became apparent we have no tests ensuring no memory leak in EvictableCache. This PR improves test coverage around that.