Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1014,16 +1014,17 @@ private void assertInitializedJobs(List<SolverJob<TestdataSolution>> jobs)
@Test
@Timeout(60)
void submitMoreProblemsThanCpus_allGetSolved() throws InterruptedException, ExecutionException {
// Use twice the amount of problems than available processors.
var problemCount = Runtime.getRuntime().availableProcessors() * 2;
try (var solverManager = createSolverManagerTestableByDifferentConsumers()) {
var parallelSolverCount = 2;
// Keep the test invariant: submit more jobs than CPUs.
var problemCount = Math.max(parallelSolverCount * 2, Runtime.getRuntime().availableProcessors() + 1);
try (var solverManager = createSolverManagerTestableByDifferentConsumers(parallelSolverCount)) {
assertSolveWithoutConsumer(problemCount, solverManager);
assertSolveWithConsumer(problemCount, solverManager, true);
assertSolveWithConsumer(problemCount, solverManager, false);
}
}

private SolverManager<TestdataSolution> createSolverManagerTestableByDifferentConsumers() {
private SolverManager<TestdataSolution> createSolverManagerTestableByDifferentConsumers(int parallelSolverCount) {
var solverConfig = PlannerTestUtils.buildSolverConfig(TestdataSolution.class, TestdataEntity.class)
.withPhases(IntStream.of(0, 1)
.mapToObj(x -> new CustomPhaseConfig().withCustomPhaseCommands(
Expand All @@ -1037,7 +1038,8 @@ private SolverManager<TestdataSolution> createSolverManagerTestableByDifferentCo
context.executeAndCalculateScore(move);
}))
.toArray(PhaseConfig[]::new));
return createDefaultSolverManager(solverConfig);
return createSolverManager(solverConfig,
new SolverManagerConfig().withParallelSolverCount(Integer.toString(parallelSolverCount)));
}

private void assertSolveWithoutConsumer(int problemCount, SolverManager<TestdataSolution> solverManager)
Expand Down
Loading