Search in sources :

Example 6 with RMState

use of org.ow2.proactive.resourcemanager.common.RMState in project scheduling by ow2-proactive.

the class TestLocalInfrastructureRestartDownNodesPolicy method testRestartDownNodesPolicyWithRemoveNode.

/**
 * This test ensures that when a node has been manually removed it is not redeployed by the policy
 */
@Test
public void testRestartDownNodesPolicyWithRemoveNode() throws Exception {
    nodeSourceName = "Node_source_2";
    RMTHelper.log("Test 2 - restart down nodes policy with a node removed");
    createNodeSourceWithNodes(nodeSourceName, new Object[] { "ALL", "ALL", "10000" });
    RMState stateTest1 = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, stateTest1.getFreeNodesNumber());
    NodeSet ns = resourceManager.getNodes(new Criteria(defaultDescriptorNodesNb));
    for (Node n : ns) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    }
    // remove the first node
    Node nodeToRemove = ns.remove(0);
    resourceManager.removeNode(nodeToRemove.getNodeInformation().getURL(), true);
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, nodeToRemove.getNodeInformation().getURL());
    RMTHelper.log("Node removed.");
    stateTest1 = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb - 1, stateTest1.getTotalNodesNumber());
    String nodeUrl = ns.get(0).getNodeInformation().getURL();
    // Nodes will be redeployed only if we kill the whole runtime
    rmHelper.killRuntime(nodeUrl);
    // one node is down - the policy should detect it and redeploy
    for (int i = 0; i < defaultDescriptorNodesNb - 1; i++) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, ns.get(i).getNodeInformation().getURL());
    }
    RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeUrl);
    assertEquals(NodeState.DOWN, ev.getNodeState());
    // one node is down - the policy should detect it and redeploy
    for (int i = 0; i < defaultDescriptorNodesNb - 1; i++) {
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    }
    // now one node less should be deployed
    assertEquals(defaultDescriptorNodesNb - 1, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb - 1, stateTest1.getTotalAliveNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node) Criteria(org.ow2.proactive.utils.Criteria) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 7 with RMState

use of org.ow2.proactive.resourcemanager.common.RMState in project scheduling by ow2-proactive.

the class TestSSHInfrastructureV2 method testSSHInfrastructureV2.

@Test
public void testSSHInfrastructureV2() throws Exception {
    nsname = "testSSHInfra";
    resourceManager = this.rmHelper.getResourceManager();
    RMTHelper.log("Test - Create SSH infrastructure on ssh://localhost on port " + this.port);
    resourceManager.createNodeSource(nsname, SSHInfrastructureV2.class.getName(), infraParams, StaticPolicy.class.getName(), policyParameters, NODES_NOT_RECOVERABLE);
    this.rmHelper.waitForNodeSourceCreation(nsname, NB_NODES, this.rmHelper.getMonitorsHandler());
    RMTHelper.log("Checking scheduler state after node source creation");
    RMState s = resourceManager.getState();
    assertEquals(NB_NODES, s.getTotalNodesNumber());
    assertEquals(NB_NODES, s.getFreeNodesNumber());
}
Also used : StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) SSHInfrastructureV2(org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2) RMState(org.ow2.proactive.resourcemanager.common.RMState) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 8 with RMState

use of org.ow2.proactive.resourcemanager.common.RMState in project scheduling by ow2-proactive.

the class TestSSHInfrastructureV2RestartDownNodesPolicy method testSSHInfrastructureV2WithRestartDownNodes.

@Test
public void testSSHInfrastructureV2WithRestartDownNodes() throws Exception {
    nsname = "testSSHInfraRestart";
    resourceManager = this.rmHelper.getResourceManager();
    RMTHelper.log("Test - Create SSH infrastructure with RestartDownNodes policy on ssh://localhost on port " + TestSSHInfrastructureV2.port);
    resourceManager.createNodeSource(nsname, SSHInfrastructureV2.class.getName(), TestSSHInfrastructureV2.infraParams, RestartDownNodesPolicy.class.getName(), TestSSHInfrastructureV2.policyParameters, NODES_NOT_RECOVERABLE);
    RMMonitorsHandler monitorsHandler = this.rmHelper.getMonitorsHandler();
    this.rmHelper.waitForNodeSourceCreation(nsname, NB_NODES, monitorsHandler);
    RMState s = resourceManager.getState();
    assertEquals(NB_NODES, s.getTotalNodesNumber());
    assertEquals(NB_NODES, s.getFreeNodesNumber());
    NodeSet nodeset = resourceManager.getNodes(new Criteria(NB_NODES));
    if (nodeset.size() != NB_NODES) {
        RMTHelper.log("Illegal state : the infrastructure could not deploy nodes or they died immediately. Ending test");
        throw new RuntimeException("Illegal state : the infrastructure could not deploy nodes or they died immediately. Ending test");
    }
    for (Node n : nodeset) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 60000, monitorsHandler);
    }
    String nodeUrl = nodeset.get(0).getNodeInformation().getURL();
    RMTHelper.log("Killing nodes");
    // Nodes will be redeployed only if we kill the whole runtime
    rmHelper.killRuntime(nodeUrl);
    RMTHelper.log("Wait for down nodes detection by the rm");
    for (Node n : nodeset) {
        RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 120000, monitorsHandler);
        assertEquals(NodeState.DOWN, ev.getNodeState());
    }
    for (Node n : nodeset) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL(), 120000, monitorsHandler);
    }
    RMTHelper.log("Dumping events not consumed yet");
    monitorsHandler.dumpEvents();
    RMTHelper.log("Wait for nodes restart by the policy");
    rmHelper.waitForAnyMultipleNodeEvent(RMEventType.NODE_ADDED, NB_NODES, monitorsHandler);
    for (int i = 0; i < NB_NODES; i++) {
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED, monitorsHandler);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED, monitorsHandler);
        rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, monitorsHandler);
    }
    RMTHelper.log("Final checks on the scheduler state");
    nodeset = resourceManager.getNodes(new Criteria(NB_NODES));
    for (Node n : nodeset) {
        System.out.println("NODE::" + n.getNodeInformation().getURL());
    }
    s = resourceManager.getState();
    assertEquals(NB_NODES, s.getTotalNodesNumber());
    // check amount of all nodes that are not down
    assertEquals(NB_NODES, s.getTotalAliveNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) RestartDownNodesPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.RestartDownNodesPolicy) Node(org.objectweb.proactive.core.node.Node) SSHInfrastructureV2(org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2) Criteria(org.ow2.proactive.utils.Criteria) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) RMMonitorsHandler(functionaltests.monitor.RMMonitorsHandler) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 9 with RMState

use of org.ow2.proactive.resourcemanager.common.RMState in project scheduling by ow2-proactive.

the class RMCoreTest method testGetState.

@Test
public void testGetState() {
    RMState rmState = rmCore.getState();
    assertEquals(6, rmState.getTotalNodesNumber());
    assertEquals(3, rmState.getFreeNodesNumber());
    // there are 6 nodes, 3 are down, as a consequence 3 are expected as alive
    assertEquals(3, rmState.getTotalAliveNodesNumber());
}
Also used : RMState(org.ow2.proactive.resourcemanager.common.RMState) Test(org.junit.Test)

Example 10 with RMState

use of org.ow2.proactive.resourcemanager.common.RMState in project scheduling by ow2-proactive.

the class TestLocalInfrastructureRestartDownNodesPolicy method testRestartDownNodesPolicy.

@Test
public void testRestartDownNodesPolicy() throws Exception {
    nodeSourceName = "Node_source_1";
    RMTHelper.log("Test 1 - restart down nodes policy");
    createNodeSourceWithNodes(nodeSourceName, new Object[] { "ALL", "ALL", "10000" });
    RMState stateTest1 = resourceManager.getState();
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, stateTest1.getFreeNodesNumber());
    NodeSet ns = resourceManager.getNodes(new Criteria(defaultDescriptorNodesNb));
    for (Node n : ns) {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    }
    String nodeUrl = ns.get(0).getNodeInformation().getURL();
    // Nodes will be redeployed only if we kill the whole runtime
    rmHelper.killRuntime(nodeUrl);
    RMNodeEvent ev = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeUrl);
    assertEquals(NodeState.DOWN, ev.getNodeState());
    // one node is down - the policy should detect it and redeploy
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalNodesNumber());
    assertEquals(defaultDescriptorNodesNb, stateTest1.getTotalAliveNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Node(org.objectweb.proactive.core.node.Node) Criteria(org.ow2.proactive.utils.Criteria) RMState(org.ow2.proactive.resourcemanager.common.RMState) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Aggregations

RMState (org.ow2.proactive.resourcemanager.common.RMState)14 Test (org.junit.Test)9 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)6 Node (org.objectweb.proactive.core.node.Node)4 NodeSet (org.ow2.proactive.utils.NodeSet)4 RMStateNodeUrls (org.ow2.proactive.resourcemanager.common.RMStateNodeUrls)3 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)3 Criteria (org.ow2.proactive.utils.Criteria)3 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)2 SSHInfrastructureV2 (org.ow2.proactive.resourcemanager.nodesource.infrastructure.SSHInfrastructureV2)2 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)2 NotConnectedRestException (org.ow2.proactive_grid_cloud_portal.scheduler.exception.NotConnectedRestException)2 RMMonitorsHandler (functionaltests.monitor.RMMonitorsHandler)1 RestartDownNodesPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.RestartDownNodesPolicy)1 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)1