michaelsembwever commented on code in PR #3429:
URL: https://github.com/apache/cassandra/pull/3429#discussion_r1685431238
##########
test/distributed/org/apache/cassandra/distributed/test/ResourceLeakTest.java:
##########
@@ -169,17 +175,35 @@ static void testJmx(Cluster cluster)
}
}
- void doTest(int numClusterNodes, Consumer<IInstanceConfig> updater) throws
Throwable
+ void checkForInstanceClassLoaderLeaks(int maxAllowableInstances, int loop)
throws IOException, InterruptedException {
+ for (int i = 0;
InstanceClassLoader.getApproximateLiveLoaderCount(true) > maxAllowableInstances
&& i < 10; i++) {
+ Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
+ }
+ int approximateLiveLoaderCount =
InstanceClassLoader.getApproximateLiveLoaderCount(true);
+ if (approximateLiveLoaderCount > maxAllowableInstances) {
+ dumpResources(String.format("InstanceClassLoader max reached at
loop %d", loop));
+ Assert.assertThat("InstanceClassLoader leak detected",
+ approximateLiveLoaderCount,
+ lessThanOrEqualTo(maxAllowableInstances));
+ }
+ }
+
+ void doTest(Consumer<IInstanceConfig> updater) throws Throwable
{
- doTest(numClusterNodes, updater, ignored -> {});
+ doTest(updater, ignored -> {});
}
- void doTest(int numClusterNodes, Consumer<IInstanceConfig> updater,
Consumer<Cluster> actionToPerform) throws Throwable
+ void doTest(Consumer<IInstanceConfig> updater, Consumer<Cluster>
actionToPerform) throws Throwable
{
for (int loop = 0; loop < numTestLoops; loop++)
{
System.out.println(String.format("========== Starting loop %03d
========", loop));
- try (Cluster cluster = (Cluster)
builder().withNodes(numClusterNodes).withConfig(updater).start())
+ Cluster.Builder builder = builder();
+ try (Cluster cluster = (Cluster)
builder.withNodes(numClusterNodes).withConfig(updater)
+ // DO NOT COMMIT
+ // Intentionally broken by removing `oshi.jna` to
demonstrate the test failing
+// .withSharedClasses(builder.getSharedClasses().and(name
-> !name.startsWith("oshi.jna.")))
+ .start())
Review Comment:
nit…
```
// DO NOT COMMIT UNCOMMENTED
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]