Jenkins中的契约提供程序JVM内存不足错误

b09cbbtk  于 2023-06-21  发布在  Jenkins
关注(0)|答案(3)|浏览(120)

我们正在使用pact-jvm-provider依赖项进行pact-verification,它在本地工作正常,但当我在Jenkins管道中运行mvn test命令时,出现内存不足错误。

Verification Failed - Uncaught exception during scan
19:52:33  
19:52:33  Failures:
19:52:33  
19:52:33  0) ItemsAssigned Event
19:52:33        Uncaught exception during scan
19:52:33  
19:52:33  [ERROR] Tests run: 7, Failures: 1, Errors: 6, Skipped: 0, Time elapsed: 35.366 s <<< FAILURE! - in VerifyDecanterGoodsSupplierEventContract
19:52:33  [ERROR] goods-supplier - ItemsAssigned Event  Time elapsed: 35.079 s  <<< FAILURE!
19:52:33  java.lang.AssertionError: 

19:52:33  0 - Uncaught exception during scan
19:52:33  java.lang.OutOfMemoryError: Java heap space
19:52:33    at nonapi.io.github.classgraph.fastzipfilereader.FastZipEntry$1.<init>(FastZipEntry.java:273)
19:52:33    at nonapi.io.github.classgraph.fastzipfilereader.FastZipEntry.open(FastZipEntry.java:268)
19:52:33    at io.github.classgraph.ClasspathElementZip$1.open(ClasspathElementZip.java:300)
19:52:33    at io.github.classgraph.ClasspathElementZip$1.openOrRead(ClasspathElementZip.java:316)
19:52:33    at io.github.classgraph.Classfile.<init>(Classfile.java:1465)
19:52:33    at io.github.classgraph.Scanner$ClassfileScannerWorkUnitProcessor.processWorkUnit(Scanner.java:599)
19:52:33    at io.github.classgraph.Scanner$ClassfileScannerWorkUnitProcessor.processWorkUnit(Scanner.java:547)
19:52:33    at nonapi.io.github.classgraph.concurrency.WorkQueue.runWorkLoop(WorkQueue.java:245)
19:52:33    at nonapi.io.github.classgraph.concurrency.WorkQueue.runWorkQueue(WorkQueue.java:161)
19:52:33    at io.github.classgraph.Scanner.processWorkUnits(Scanner.java:337)
19:52:33    at io.github.classgraph.Scanner.performScan(Scanner.java:826)
19:52:33    at io.github.classgraph.Scanner.openClasspathElementsThenScan(Scanner.java:964)
19:52:33    at io.github.classgraph.Scanner.call(Scanner.java:999)
19:52:33    at io.github.classgraph.Scanner.call(Scanner.java:74)
19:52:33    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
19:52:33    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
19:52:33    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
19:52:33    at java.base/java.lang.Thread.run(Thread.java:834)
nkoocmlb

nkoocmlb1#

通过应用以下解决方案来解决上述协议提供商合同问题:

之前

我使用的是AmqpTarget()默认构造函数,它扫描了所有的java类。
public int findDuplicate = new Duplicate();

之后

现在我在AmqpTarget构造函数中给出特定的包名称
public final Target target = new AmqpTarget(Collections.singletonList(“com.example.service.pact.provider.event”));
问题现在解决了。

4si2a6ki

4si2a6ki2#

Jenkins有多少内存?看起来有一些扫描插件(与Pact无关)正在运行,并且在这样做时内存不足。
我猜你的笔记本电脑比Jenkins有更多的内存(Jenkins可能也在运行其他作业),而且资源不足。

f5emj3cl

f5emj3cl3#

MessageTestTarget应该用来缩小类扫描的范围。例如:

@BeforeEach
void before(PactVerificationContext context) {
    context.setTarget(new MessageTestTarget(
         Collections.singletonList(getClass().getPackage().getName())));        
}

相关问题