mirror of https://github.com/halo-dev/halo
Fix concurrent issue during bundle file concurrent generation testing (#6043)
#### What type of PR is this? /kind failing-test /area core /milestone 2.17.x #### What this PR does / why we need it: I wrongly invoked `Arraylist#add`(probes) method in multi threads. So the unit test was unstable and might encounter the problem as follows: ```java Expected :1 Actual :0 <Click to see difference> org.opentest4j.AssertionFailedError: expected: <1> but was: <0> at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197) at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:166) at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:161) at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:632) at run.halo.app.core.extension.service.impl.PluginServiceImplTest$BundleCacheTest.concurrentComputeBundleFileIfAbsent(PluginServiceImplTest.java:460) ``` See https://github.com/halo-dev/halo/actions/runs/9382059472/job/25832681545 for more. This PR moves the invocation outside thread tasks. #### Does this PR introduce a user-facing change? ```release-note None ```pull/6049/head
parent
2841ff8282
commit
e446054813
|
@ -432,17 +432,20 @@ class PluginServiceImplTest {
|
|||
|
||||
var probes = new ArrayList<PublisherProbe<DataBuffer>>();
|
||||
List<? extends Future<?>> futures = IntStream.range(0, 10)
|
||||
.mapToObj(i -> executorService.submit(() -> {
|
||||
.mapToObj(i -> {
|
||||
var fakeContent = Mono.<DataBuffer>just(sharedInstance.wrap(
|
||||
("fake-content-" + i).getBytes(UTF_8)
|
||||
));
|
||||
var probe = PublisherProbe.of(fakeContent);
|
||||
probes.add(probe);
|
||||
cache.computeIfAbsent("fake-version", probe.mono())
|
||||
.as(StepVerifier::create)
|
||||
.expectNextCount(1)
|
||||
.verifyComplete();
|
||||
}))
|
||||
return executorService.submit(
|
||||
() -> {
|
||||
cache.computeIfAbsent("fake-version", probe.mono())
|
||||
.as(StepVerifier::create)
|
||||
.expectNextCount(1)
|
||||
.verifyComplete();
|
||||
});
|
||||
})
|
||||
.toList();
|
||||
executorService.shutdown();
|
||||
futures.forEach(future -> {
|
||||
|
|
Loading…
Reference in New Issue