protected void disposeAllContainers() { ServiceResponse<KieContainerResourceList> response = client.listContainers(); Assert.assertEquals(ServiceResponse.ResponseType.SUCCESS, response.getType()); List<KieContainerResource> containers = response.getResult().getContainers(); if (containers != null) { for (KieContainerResource container : containers) { client.disposeContainer(container.getContainerId()); } } }
/* * The first call to the server takes usually much longer because the JVM needs to load all the classes, JAXRS subsystem gets * initialized, etc. The first test sometimes fails, more frequently on slow machines. * * This method creates dummy container and then immediately destroys it. This should warm-up the server enough * so that the subsequent calls are faster. */ private static void warmUpServer() throws Exception { logger.info( "Warming-up the server by creating dummy container and then immediately destroying it..."); KieServicesConfiguration config = createKieServicesRestConfiguration(); // specify higher timeout, the default is too small config.setTimeout(30000); KieServicesClient client = KieServicesFactory.newKieServicesClient(config); ReleaseId warmUpReleaseId = new ReleaseId("org.kie.server.testing", "server-warm-up", "42"); createAndDeployKJar(warmUpReleaseId); assertSuccess( client.createContainer( "warm-up-kjar", new KieContainerResource("warm-up-kjar", warmUpReleaseId))); assertSuccess(client.disposeContainer("warm-up-kjar")); logger.info("Server warm-up done."); }
@Override public String call() { String payload = "<batch-execution lookup=\"kbase1.stateless\">\n" + " <insert out-identifier=\"person1\">\n" + " <org.kie.server.testing.Person>\n" + " <firstname>Darth</firstname>\n" + " </org.kie.server.testing.Person>\n" + " </insert>\n" + "</batch-execution>"; long threadId = Thread.currentThread().getId(); ServiceResponse<String> reply; for (int i = 0; i < NR_OF_REQUESTS_PER_THREAD; i++) { logger.trace("Container call #{}, thread-id={}", i, threadId); reply = client.executeCommands(CONTAINER_ID, payload); logger.trace("Container reply for request #{}: {}, thread-id={}", i, reply, threadId); assertEquals(ServiceResponse.ResponseType.SUCCESS, reply.getType()); } return "SUCCESS"; }