Search in sources :

Example 26 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class TestRMProxy method requestReleaseAllNodes.

private void requestReleaseAllNodes(RMProxy proxy, ResourceManager rm) throws Exception {
    log("Request and release all nodes");
    List<NodeSet> nodeSets = new ArrayList<>();
    for (int i = 0; i < NODES_NUMBER; i++) {
        nodeSets.add(proxy.getNodes(new Criteria(1)));
    }
    for (NodeSet nodeSet : nodeSets) {
        waitWhenNodeSetAcquired(nodeSet, 1);
        proxy.releaseNodes(nodeSet);
    }
    waitWhenNodesAreReleased(NODES_NUMBER);
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) ArrayList(java.util.ArrayList) Criteria(org.ow2.proactive.utils.Criteria)

Example 27 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class TestRMProxy method testSplitNodeSet.

private void testSplitNodeSet(RMProxy proxy, ResourceManager rm) throws Exception {
    log("Request as single NodeSet, release it as two NodeSets");
    NodeSet nodeSet = proxy.getNodes(new Criteria(3));
    waitWhenNodeSetAcquired(nodeSet, 3);
    assertEquals(NODES_NUMBER - 3, rm.getState().getFreeNodesNumber());
    NodeSet nodeSet1 = new NodeSet();
    nodeSet1.add(nodeSet.remove(0));
    NodeSet nodeSet2 = new NodeSet();
    nodeSet2.add(nodeSet.remove(0));
    nodeSet2.add(nodeSet.remove(0));
    proxy.releaseNodes(nodeSet1);
    waitWhenNodesAreReleased(1);
    assertEquals(NODES_NUMBER - 2, rm.getState().getFreeNodesNumber());
    proxy.releaseNodes(nodeSet2);
    waitWhenNodesAreReleased(2);
    assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria)

Example 28 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class SelectionManagerTest method testSelectNodesWith10Node.

@Test
public void testSelectNodesWith10Node() {
    RMCore rmCore = newMockedRMCore(10);
    SelectionManager selectionManager = createSelectionManager(rmCore);
    Criteria crit = new Criteria(10);
    crit.setTopology(TopologyDescriptor.ARBITRARY);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(true);
    Client mockedClient = mock(Client.class);
    NodeSet nodeSet = selectionManager.selectNodes(crit, mockedClient);
    assertEquals(10, nodeSet.size());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Test(org.junit.Test)

Example 29 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class SelectionManagerTest method selectWithDifferentPermissions.

@Test
public void selectWithDifferentPermissions() throws Exception {
    PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER.updateProperty("10");
    System.out.println("PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER=" + PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER);
    System.setSecurityManager(securityManagerRejectingUser());
    RMCore.topologyManager = mock(TopologyManager.class);
    RMCore rmCore = mock(RMCore.class);
    when(RMCore.topologyManager.getHandler(Matchers.<TopologyDescriptor>any())).thenReturn(selectAllTopology());
    SelectionManager selectionManager = createSelectionManager(rmCore);
    ArrayList<RMNode> freeNodes = new ArrayList<>();
    freeNodes.add(createMockedNode("admin"));
    freeNodes.add(createMockedNode("user"));
    when(rmCore.getFreeNodes()).thenReturn(freeNodes);
    Criteria criteria = new Criteria(2);
    criteria.setTopology(TopologyDescriptor.ARBITRARY);
    Subject subject = Subjects.create("admin");
    NodeSet nodes = selectionManager.selectNodes(criteria, new Client(subject, false));
    assertEquals(1, nodes.size());
}
Also used : TopologyManager(org.ow2.proactive.resourcemanager.selection.topology.TopologyManager) RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) ArrayList(java.util.ArrayList) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Subject(javax.security.auth.Subject) Test(org.junit.Test)

Example 30 with NodeSet

use of org.ow2.proactive.utils.NodeSet in project scheduling by ow2-proactive.

the class SelectionManagerTest method testSelectNodesWith1Node.

@Test
public void testSelectNodesWith1Node() {
    RMCore rmCore = newMockedRMCore(1);
    SelectionManager selectionManager = createSelectionManager(rmCore);
    Criteria crit = new Criteria(1);
    crit.setTopology(TopologyDescriptor.ARBITRARY);
    crit.setScripts(null);
    crit.setBlackList(null);
    crit.setBestEffort(true);
    Client mockedClient = mock(Client.class);
    NodeSet nodeSet = selectionManager.selectNodes(crit, mockedClient);
    assertEquals(1, nodeSet.size());
}
Also used : RMCore(org.ow2.proactive.resourcemanager.core.RMCore) NodeSet(org.ow2.proactive.utils.NodeSet) Criteria(org.ow2.proactive.utils.Criteria) Client(org.ow2.proactive.resourcemanager.authentication.Client) Test(org.junit.Test)

Aggregations

NodeSet (org.ow2.proactive.utils.NodeSet)51 Test (org.junit.Test)28 Criteria (org.ow2.proactive.utils.Criteria)23 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)20 Node (org.objectweb.proactive.core.node.Node)18 ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)17 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)12 ArrayList (java.util.ArrayList)11 HashMap (java.util.HashMap)11 SelectionScript (org.ow2.proactive.scripting.SelectionScript)10 File (java.io.File)9 TestNode (functionaltests.utils.TestNode)8 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)7 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)5 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)5 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)4 RMState (org.ow2.proactive.resourcemanager.common.RMState)4 IOException (java.io.IOException)3 Permission (java.security.Permission)3 HashSet (java.util.HashSet)3