Configure mokitor Server mock as stubOnly (#8861)
A recent patch moved the internal unit tests to mokito, allowing deep mocking to easily setup a mocked server instance. While this change is useful, the server's Server#getItemFactory methods is one of the hottest paths during unit testing, being called numerous times by material tests. As mokito mocks keep track of each invocation to allow for verifications of invocations down the line, the server mock allocates a huge amount of memory to keep track of all invocations, ultimately leading to an OOM exception. The previous solution solved this by increasing the tests memory to 2 GB, however as of right now simply configuring the server mock as "stubOnly", properly prevents the overflow of invocation records as none of the unit test code relies on invocation verification.
This commit is contained in:
parent
8427c88987
commit
d9699b5935
3 changed files with 6 additions and 7 deletions
|
@ -18,10 +18,10 @@ index 064a0c5b2a4b379ceec84652ff1e004d57419115..218a0db30ac8e4403da4ee50ca0a67ca
|
|||
runtimeOnly("mysql:mysql-connector-java:8.0.29")
|
||||
diff --git a/src/test/java/io/papermc/paper/testing/DummyServer.java b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..286790061c9d81c872108ef63e1a1aba2fbec809
|
||||
index 0000000000000000000000000000000000000000..c6503ff76f56bab5f383f0ca17d137155e9be447
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
@@ -0,0 +1,66 @@
|
||||
@@ -0,0 +1,67 @@
|
||||
+package io.papermc.paper.testing;
|
||||
+
|
||||
+import java.util.logging.Logger;
|
||||
|
@ -38,6 +38,7 @@ index 0000000000000000000000000000000000000000..286790061c9d81c872108ef63e1a1aba
|
|||
+import org.bukkit.plugin.PluginManager;
|
||||
+import org.bukkit.plugin.SimplePluginManager;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.mockito.Mockito;
|
||||
+
|
||||
+import static org.mockito.Mockito.any;
|
||||
+import static org.mockito.Mockito.mock;
|
||||
|
@ -52,7 +53,7 @@ index 0000000000000000000000000000000000000000..286790061c9d81c872108ef63e1a1aba
|
|||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final Server dummyServer = mock(Server.class);
|
||||
+ final Server dummyServer = mock(Server.class, Mockito.withSettings().stubOnly());
|
||||
+
|
||||
+ final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
+ when(dummyServer.getLogger()).thenReturn(logger);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue