Skip to content

Commit

Permalink
Attempt more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
triceo committed Feb 25, 2025
1 parent d3feab6 commit 08d5e1f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.Test;

import io.micrometer.core.instrument.MeterRegistry;
Expand Down Expand Up @@ -59,7 +58,7 @@ void testRuining() {
assertDoesNotThrow(() -> solver.solve(problem));
}

@RepeatedTest(2)
@Test
void testRuiningWithMetric() {
var meterRegistry = new TestMeterRegistry();
Metrics.addRegistry(meterRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
Expand Down Expand Up @@ -426,7 +427,7 @@ void solveMetrics() {
SolverFactory<TestdataSolution> solverFactory = SolverFactory.create(solverConfig);

var solver = solverFactory.buildSolver();
((DefaultSolver<TestdataSolution>) solver).setMonitorTagMap(Map.of("solver.id", "solveMetrics"));
((DefaultSolver<TestdataSolution>) solver).setMonitorTagMap(Map.of("solver.id", UUID.randomUUID().toString()));
meterRegistry.publish();

var solution = new TestdataSolution("s1");
Expand Down Expand Up @@ -566,7 +567,7 @@ void solveBestScoreMetrics() {
SolverFactory<TestdataHardSoftScoreSolution> solverFactory = SolverFactory.create(solverConfig);

var solver = solverFactory.buildSolver();
((DefaultSolver<TestdataHardSoftScoreSolution>) solver).setMonitorTagMap(Map.of("solver.id", "solveMetrics"));
((DefaultSolver<TestdataHardSoftScoreSolution>) solver).setMonitorTagMap(Map.of("solver.id", UUID.randomUUID().toString()));
meterRegistry.publish();
var solution = new TestdataHardSoftScoreSolution("s1");
solution.setValueList(Arrays.asList(new TestdataValue("none"), new TestdataValue("reward")));
Expand Down Expand Up @@ -670,7 +671,7 @@ void solveStepScoreMetrics() {
SolverFactory<TestdataHardSoftScoreSolution> solverFactory = SolverFactory.create(solverConfig);

var solver = solverFactory.buildSolver();
((DefaultSolver<TestdataHardSoftScoreSolution>) solver).setMonitorTagMap(Map.of("solver.id", "solveMetrics"));
((DefaultSolver<TestdataHardSoftScoreSolution>) solver).setMonitorTagMap(Map.of("solver.id", UUID.randomUUID().toString()));
var step = new AtomicInteger(-1);

((DefaultSolver<TestdataHardSoftScoreSolution>) solver)
Expand Down Expand Up @@ -750,7 +751,7 @@ void solveMetricsError() {
SolverFactory<TestdataSolution> solverFactory = SolverFactory.create(solverConfig);

var solver = solverFactory.buildSolver();
((DefaultSolver<TestdataSolution>) solver).setMonitorTagMap(Map.of("solver.id", "solveMetricsError"));
((DefaultSolver<TestdataSolution>) solver).setMonitorTagMap(Map.of("solver.id", UUID.randomUUID().toString()));
meterRegistry.publish();

var solution = new TestdataSolution("s1");
Expand All @@ -759,9 +760,8 @@ void solveMetricsError() {

meterRegistry.publish();

assertThatCode(() -> {
solver.solve(solution);
}).hasStackTraceContaining("Thrown exception in constraint provider");
assertThatCode(() -> solver.solve(solution))
.hasStackTraceContaining("Thrown exception in constraint provider");

meterRegistry.getClock().addSeconds(1);
meterRegistry.publish();
Expand Down

0 comments on commit 08d5e1f

Please sign in to comment.