diff options
author | Bjarne Koll <[email protected]> | 2023-02-21 17:18:49 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2023-02-21 17:18:49 +0100 |
commit | d9699b5935da1c10b1dd57648336b19e56746840 (patch) | |
tree | c5b9685c2c350349a800b282853cc2799bac429a /patches/server/0004-Test-changes.patch | |
parent | 8427c889879576f351cd10301dff37b8354b4d00 (diff) | |
download | Paper-d9699b5935da1c10b1dd57648336b19e56746840.tar.gz Paper-d9699b5935da1c10b1dd57648336b19e56746840.zip |
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.
Diffstat (limited to 'patches/server/0004-Test-changes.patch')
-rw-r--r-- | patches/server/0004-Test-changes.patch | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/patches/server/0004-Test-changes.patch b/patches/server/0004-Test-changes.patch index bdbc536649..249ce8aa70 100644 --- a/patches/server/0004-Test-changes.patch +++ b/patches/server/0004-Test-changes.patch @@ -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); |