Search in sources :

Example 26 with SolverInstance

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\"");
}
Also used : SolverInstance(org.kie.server.api.model.instance.SolverInstance) KieServerBaseIntegrationTest(org.kie.server.integrationtests.shared.basetests.KieServerBaseIntegrationTest) RestJmsSharedBaseIntegrationTest(org.kie.server.integrationtests.shared.basetests.RestJmsSharedBaseIntegrationTest) Test(org.junit.Test)

Aggregations

SolverInstance (org.kie.server.api.model.instance.SolverInstance)26 Test (org.junit.Test)11 ServiceResponse (org.kie.server.api.model.ServiceResponse)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 HashMap (java.util.HashMap)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 Variant (javax.ws.rs.core.Variant)3 ExecutionServerCommand (org.kie.camel.container.api.ExecutionServerCommand)3 CommandScript (org.kie.server.api.commands.CommandScript)3 Header (org.kie.server.remote.rest.common.Header)3 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)3 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)3 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)3 GET (javax.ws.rs.GET)2 CreateSolverCommand (org.kie.server.api.commands.optaplanner.CreateSolverCommand)2 GetSolverCommand (org.kie.server.api.commands.optaplanner.GetSolverCommand)2