use of org.kie.server.controller.api.model.events.ServerInstanceUpdated in project kie-wb-common by kiegroup.
the class StandaloneControllerMultinodeIT method testAvailableRestEndpoint.
/**
* This creates a multiinstance node where
* instance 1 deploys the workbench
* instance 2 deploys kie-server
* after checking that the instance 2 manual is instantiated and working
* it kills the server (only working in linux for now) -> on windows it will stop the app server gracefully
* instance 2 is killed and the health check detects the problem
* notifies back to the test that the kie server is disconnected (CountDownLatch in the EventHandler)
*/
@Test
@RunAsClient
@OperateOnDeployment("workbench")
public void testAvailableRestEndpoint() throws Exception {
String url = new URL("http://localhost:8080/workbench/websocket/controller").toExternalForm();
URL serverUrl = new URL("http://localhost:8230/kie-server/services/rest/server");
CountDownLatch serverDown = new CountDownLatch(1);
CountDownLatch kieServerTemplateUp = new CountDownLatch(1);
CountDownLatch kieServerInstanceUp = new CountDownLatch(1);
EventHandler customWSEventHandler = new EventHandler() {
@Override
public void onServerInstanceConnected(ServerInstanceConnected serverInstanceConnected) {
LOGGER.info("onServerInstanceConnected :" + serverInstanceConnected);
}
@Override
public void onServerInstanceDeleted(ServerInstanceDeleted serverInstanceDeleted) {
LOGGER.info("onServerInstanceDeleted :" + serverInstanceDeleted);
}
@Override
public void onServerInstanceDisconnected(ServerInstanceDisconnected serverInstanceDisconnected) {
LOGGER.info("onServerInstanceDisconnected :" + serverInstanceDisconnected);
serverDown.countDown();
}
@Override
public void onServerTemplateDeleted(ServerTemplateDeleted serverTemplateDeleted) {
LOGGER.info("onServerTemplateDeleted :" + serverTemplateDeleted);
}
@Override
public void onServerTemplateUpdated(ServerTemplateUpdated serverTemplateUpdated) {
LOGGER.info("onServerTemplateUpdated :" + serverTemplateUpdated);
kieServerTemplateUp.countDown();
}
@Override
public void onServerInstanceUpdated(ServerInstanceUpdated serverInstanceUpdated) {
LOGGER.info("onServerInstanceUpdated :" + serverInstanceUpdated);
kieServerInstanceUp.countDown();
}
@Override
public void onContainerSpecUpdated(ContainerSpecUpdated containerSpecUpdated) {
LOGGER.info("onContainerSpecUpdated :" + containerSpecUpdated);
}
};
deployer.deploy("kie-server");
assertTrue(ping(serverUrl));
// the use of manually deployment is the only way to guarantee that the web context is completely deployed
// and not causing a race condition when the controller ping the server and severing the connection
deployer.deploy("workbench");
try (WebSocketKieServerControllerClient client = (WebSocketKieServerControllerClient) KieServerControllerClientFactory.newWebSocketClient(url, USER, PASSWORD, customWSEventHandler)) {
kieServerTemplateUp.await(100, TimeUnit.SECONDS);
kieServerInstanceUp.await(100, TimeUnit.SECONDS);
ServerInstanceKeyList list = client.getServerInstances(KIE_SERVER_ID);
assertEquals(1, list.getServerInstanceKeys().length);
// kill the secondary node
controller.kill(SECONDARY_NODE);
serverDown.await(100, TimeUnit.SECONDS);
assertFalse(ping(serverUrl));
list = client.getServerInstances(KIE_SERVER_ID);
assertEquals(0, list.getServerInstanceKeys().length);
}
}
use of org.kie.server.controller.api.model.events.ServerInstanceUpdated in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testOnInstanceUpdatedWhenContainerSpecServerTemplateNotEqualServerInstanceUpdatedServerTemplate.
@Test
public void testOnInstanceUpdatedWhenContainerSpecServerTemplateNotEqualServerInstanceUpdatedServerTemplate() {
ServerInstanceUpdated serverInstanceUpdated = mock(ServerInstanceUpdated.class);
ServerInstance serverInstance = mock(ServerInstance.class);
when(serverInstanceUpdated.getServerInstance()).thenReturn(serverInstance);
when(serverInstance.getServerTemplateId()).thenReturn(serverTemplateKey + "1");
presenter.onInstanceUpdated(serverInstanceUpdated);
verify(runtimeManagementService, times(0)).getContainersByContainerSpec(any(), any());
}
use of org.kie.server.controller.api.model.events.ServerInstanceUpdated in project kie-wb-common by kiegroup.
the class ServerTemplatePresenterTest method testOnServerInstanceUpdatedWithoutCurrentServer.
@Test
public void testOnServerInstanceUpdatedWithoutCurrentServer() {
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateId", "ServerTemplateName");
final ServerInstance serverInstance = new ServerInstance(serverTemplate.getId(), "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
presenter.onServerInstanceUpdated(new ServerInstanceUpdated(serverInstance));
verify(view, never()).addServerInstance(Mockito.<String>any(), Mockito.<String>any(), Mockito.<String>any(), any(Command.class));
}
use of org.kie.server.controller.api.model.events.ServerInstanceUpdated in project kie-wb-common by kiegroup.
the class RemotePresenterTest method testOnInstanceUpdateWithoutSelect.
@Test
public void testOnInstanceUpdateWithoutSelect() {
final ServerInstance serverInstance = new ServerInstance("templateId", "serverName", "serverInstanceId", "url", "1.0", Collections.<Message>emptyList(), Collections.<Container>emptyList());
presenter.onInstanceUpdate(new ServerInstanceUpdated(serverInstance));
verify(view, never()).clear();
verify(view, never()).setServerName(anyString());
verify(view, never()).setServerURL(anyString());
verify(view, never()).setEmptyView(any(RemoteEmptyView.class));
}
use of org.kie.server.controller.api.model.events.ServerInstanceUpdated in project kie-wb-common by kiegroup.
the class ContainerPresenterTest method testOnInstanceUpdatedWhenContainerSpecIsNull.
@Test
public void testOnInstanceUpdatedWhenContainerSpecIsNull() {
ServerInstanceUpdated serverInstanceUpdated = mock(ServerInstanceUpdated.class);
ContainerSpec containerSpec = null;
presenter.setContainerSpec(containerSpec);
presenter.onInstanceUpdated(serverInstanceUpdated);
verify(runtimeManagementService, times(0)).getContainersByContainerSpec(any(), any());
}
Aggregations