use of org.kie.server.api.model.instance.SolverInstance in project droolsjbpm-integration by kiegroup.
the class PrometheusCustomExtensionIntegrationTest method testExecuteSolver.
@Test(timeout = 15_000)
public void testExecuteSolver() throws Exception {
String solverId = "my-solver";
SolverInstance solverInstance = solverClient.createSolver(CONTAINER_ID_CLOUD_BALANCE, solverId, SOLVER_CONFIG);
assertNotNull(solverInstance);
assertEquals(SolverInstance.SolverStatus.NOT_SOLVING, solverInstance.getStatus());
// the following status starts the solver
Object planningProblem = loadPlanningProblem(5, 15);
solverClient.solvePlanningProblem(CONTAINER_ID_CLOUD_BALANCE, solverId, planningProblem);
solverInstance = solverClient.getSolver(CONTAINER_ID_CLOUD_BALANCE, solverId);
// solver should finish in 5 seconds, but we wait up to 15s before timing out
final long SOLVER_STATUS_CHECK_PERIOD = 1000L;
while (solverInstance.getStatus() == SolverInstance.SolverStatus.SOLVING) {
solverInstance = solverClient.getSolver(CONTAINER_ID_CLOUD_BALANCE, solverId);
assertNotNull(solverInstance);
Thread.sleep(SOLVER_STATUS_CHECK_PERIOD);
}
assertEquals(SolverInstance.SolverStatus.NOT_SOLVING, solverInstance.getStatus());
solverClient.disposeSolver(CONTAINER_ID_CLOUD_BALANCE, solverId);
assertThat(getMetrics()).contains("random_gauge_phase_lifecycle_best_solution_time_millis", "solver_id=\"my-solver\"");
}
Aggregations