use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.
the class TestExecRemote method action.
@Test
public void action() throws Exception {
final String miscDir = System.getProperty("pa.rm.home") + File.separator + "samples" + File.separator + "scripts" + File.separator + "misc" + File.separator;
boolean isLinux = OperatingSystem.getOperatingSystem().equals(OperatingSystem.unix);
final String valueToEcho = "111";
String nsName = "TestExecRemote";
rmHelper.createNodeSource(nsName);
RMInitialState state = ((RMMonitorEventReceiver) rmHelper.getResourceManager()).getInitialState();
String hostname = state.getNodeEvents().get(0).getHostName();
HashSet<String> nodesUrls = new HashSet<>();
for (RMNodeEvent ne : state.getNodeEvents()) {
nodesUrls.add(ne.getNodeUrl());
}
simpleScript(nodesUrls);
selectionScript(nodesUrls);
processBuilderScript(miscDir, isLinux, valueToEcho, nodesUrls);
processBuilderWithDSScript(miscDir, isLinux, valueToEcho, nodesUrls);
scriptOnNodeSource(nsName, nodesUrls);
scriptOnHost(hostname);
}
use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.
the class NodesRecoveryPropertyTest method startRmAndCheckInitialState.
private void startRmAndCheckInitialState(String rmConfigPath, boolean nodesRecoverable) throws Exception {
// start RM
startRmWithConfig(rmConfigPath);
assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isTrue();
assertThat(rmHelper.isRMStarted()).isTrue();
// check the initial state of the RM
assertThat(resourceManager.getState().getAllNodes().size()).isEqualTo(0);
if (nodesRecoverable) {
rmHelper.createNodeSourceWithNodesRecoverable(NODE_SOURCE_NAME, NODE_NUMBER);
} else {
rmHelper.createNodeSource(NODE_SOURCE_NAME, NODE_NUMBER);
}
RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) resourceManager;
List<RMNodeSourceEvent> nodeSourceEventPerNodeSource = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
assertThat(nodeSourceEventPerNodeSource.size()).isEqualTo(1);
assertThat(nodeSourceEventPerNodeSource.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
assertThat(resourceManagerMonitor.getState().getAllNodes().size()).isEqualTo(NODE_NUMBER);
}
use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.
the class RecoverLocalInfrastructureTest method restartRmAndCheckFinalState.
private void restartRmAndCheckFinalState(boolean nodesShouldBeRecreated) throws Exception {
// restart RM
this.rmHelper = new RMTHelper();
this.startRmWithConfig(RESTART_CONFIG);
assertThat(PAResourceManagerProperties.RM_PRESERVE_NODES_ON_SHUTDOWN.getValueAsBoolean()).isFalse();
assertThat(this.rmHelper.isRMStarted()).isTrue();
// re-snapshot the RM state
RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) this.resourceManager;
List<RMNodeSourceEvent> nodeSourceEvent = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
// the node source has been recovered on restart: we should have one node source with the same name
assertThat(nodeSourceEvent.size()).isEqualTo(1);
assertThat(nodeSourceEvent.get(0).getSourceName()).isEqualTo(NODE_SOURCE_NAME);
// wait for nodes to be recreated if needed
if (nodesShouldBeRecreated) {
this.rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_STATE_CHANGED, NODE_NUMBER);
}
}
use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.
the class RecoverLocalInfrastructureTest method createNodeSourceAndCheckState.
private void createNodeSourceAndCheckState() throws Exception {
this.rmHelper.createNodeSourceWithNodesRecoverable(NODE_SOURCE_NAME, NODE_NUMBER);
RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) this.resourceManager;
List<RMNodeSourceEvent> nodeSourceEventPerNodeSource = resourceManagerMonitor.getInitialState().getNodeSourceEvents();
assertThat(nodeSourceEventPerNodeSource.size()).isEqualTo(1);
RMNodeSourceEvent rmNodeSourceEvent = nodeSourceEventPerNodeSource.get(0);
assertThat(rmNodeSourceEvent.getSourceName()).isEqualTo(NODE_SOURCE_NAME);
assertThat(rmNodeSourceEvent.getNodeSourceStatus()).isEqualTo(NodeSourceStatus.NODES_DEPLOYED.toString());
assertThat(resourceManagerMonitor.getState().getAllNodes().size()).isEqualTo(NODE_NUMBER);
}
use of functionaltests.monitor.RMMonitorEventReceiver in project scheduling by ow2-proactive.
the class RecoverLocalInfrastructureTest method checkNodesStateAfterRecovery.
private void checkNodesStateAfterRecovery(int expectedNumberOfNodes) {
RMMonitorEventReceiver resourceManagerMonitor = (RMMonitorEventReceiver) this.resourceManager;
// the nodes should have been recovered too, and should be alive
Set<String> allNodes = resourceManagerMonitor.getState().getAllNodes();
assertThat(allNodes.size()).isEqualTo(expectedNumberOfNodes);
Set<String> nodeSourceNames = new HashSet<>();
nodeSourceNames.add(NODE_SOURCE_NAME);
Set<String> aliveNodeUrls = this.resourceManager.listAliveNodeUrls(nodeSourceNames);
assertThat(aliveNodeUrls.size()).isEqualTo(expectedNumberOfNodes);
if (expectedNumberOfNodes > 0) {
// the recovered nodes should be usable, try to lock/unlock them to see
BooleanWrapper lockSucceeded = this.resourceManager.lockNodes(allNodes);
assertThat(lockSucceeded).isEqualTo(new BooleanWrapper(true));
BooleanWrapper unlockSucceeded = this.resourceManager.unlockNodes(allNodes);
assertThat(unlockSucceeded).isEqualTo(new BooleanWrapper(true));
}
}
Aggregations