Search in sources :

Example 11 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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 12 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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 13 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore 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)

Example 14 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.

the class TestAddRemoveAll method testCreateNodeSource.

@Test
public void testCreateNodeSource() throws Exception {
    ResourceManager resourceManager = rmHelper.getResourceManager();
    int pingFrequency = 6000;
    log("Add/RemoveAll");
    resourceManager.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
    resourceManager.setNodeSourcePingFrequency(pingFrequency, nsName);
    testNode = rmHelper.createNode(nodeName);
    Node nodeToAdd = testNode.getNode();
    resourceManager.addNode(nodeToAdd.getNodeInformation().getURL(), nsName).getBooleanValue();
    // at this time, nodes maybe fully added in the nodesource but not in the core
    // the next removal may fail for some nodes that are not known by the core...
    resourceManager.removeNodeSource(nsName, true);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nsName);
    Thread.sleep(pingFrequency * 2);
    if (resourceManager.getState().getTotalNodesNumber() != 0) {
        log("The removeAll method in RMCore didn't removed all nodes");
        fail();
    } else {
        log("The removeAll method in RMCore did its job well");
    }
}
Also used : DefaultInfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) Node(org.objectweb.proactive.core.node.Node) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMFunctionalTest(functionaltests.utils.RMFunctionalTest) Test(org.junit.Test)

Example 15 with RMCore

use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.

the class NonBlockingCoreTest method action.

@Test
public void action() throws Exception {
    String rmconf = new File(PAResourceManagerProperties.getAbsolutePath(getClass().getResource("/functionaltests/config/functionalTRMProperties-long-selection-script-timeout.ini").getFile())).getAbsolutePath();
    rmHelper.startRM(rmconf);
    ResourceManager resourceManager = rmHelper.getResourceManager();
    int initialNodeNumber = 2;
    rmHelper.createNodeSource("NonBlockingCoreTest1", initialNodeNumber);
    long coreScriptExecutionTimeout = PAResourceManagerProperties.RM_SELECT_SCRIPT_TIMEOUT.getValueAsLong();
    long scriptSleepingTime = coreScriptExecutionTimeout * 2;
    log("Selecting node with timeout script");
    // create the static selection script object
    final SelectionScript sScript = new SelectionScript(new File(selectionScriptWithtimeOutPath.toURI()), new String[] { Long.toString(scriptSleepingTime) }, false);
    // mandatory to use RMUser AO, otherwise, getAtMostNode we be send in
    // RMAdmin request queue
    final RMAuthentication auth = rmHelper.getRMAuth();
    final Credentials cred = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), auth.getPublicKey());
    // cannot connect twice from the same active object
    // so creating another thread
    Thread t = new Thread() {

        public void run() {
            ResourceManager rm2;
            try {
                rm2 = auth.login(cred);
                nodes = rm2.getAtMostNodes(2, sScript);
            } catch (LoginException e) {
            }
        }
    };
    t.start();
    String nodeName = "node_non_blocking_test";
    testNode = RMTHelper.createNode(nodeName);
    String nodeUrl = testNode.getNode().getNodeInformation().getURL();
    log("Adding node " + nodeUrl);
    resourceManager.addNode(nodeUrl);
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, nodeUrl);
    // waiting for node to be in free state, it is in configuring state when
    // added...
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertEquals(resourceManager.getState().getTotalNodesNumber(), initialNodeNumber + 1);
    assertEquals(resourceManager.getState().getFreeNodesNumber(), initialNodeNumber + 1);
    // preemptive removal is useless for this case, because node is free
    log("Removing node " + nodeUrl);
    resourceManager.removeNode(nodeUrl, false);
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, nodeUrl);
    assertEquals(resourceManager.getState().getTotalNodesNumber(), initialNodeNumber);
    assertEquals(resourceManager.getState().getFreeNodesNumber(), initialNodeNumber);
    String nsName = "NonBlockingCoreTest";
    log("Creating a node source " + nsName);
    int nsNodesNumber = 1;
    rmHelper.createNodeSource(nsName, nsNodesNumber);
    assertEquals(resourceManager.getState().getTotalNodesNumber(), nsNodesNumber + initialNodeNumber);
    assertEquals(resourceManager.getState().getFreeNodesNumber(), nsNodesNumber + initialNodeNumber);
    log("Removing node source " + nsName);
    resourceManager.removeNodeSource(nsName, true);
    boolean selectionInProgress = PAFuture.isAwaited(nodes);
    if (!selectionInProgress) {
        // normally we are looking for 2 nodes with timeout script,
        // so the selection procedure has to finish not earlier than
        // coreScriptExecutionTimeout * nodesNumber
        // it should be sufficient to perform all admin operations
        // concurrently
        // 
        // if the core is blocked admin operations will be performed after
        // selection
        fail("Blocked inside RMCore");
    } else {
        log("No blocking inside RMCore");
    }
    t.interrupt();
}
Also used : SelectionScript(org.ow2.proactive.scripting.SelectionScript) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) File(java.io.File) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest) SelectionScriptTimeOutTest(functionaltests.selectionscript.SelectionScriptTimeOutTest)

Aggregations

Test (org.junit.Test)17 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)11 RMCore (org.ow2.proactive.resourcemanager.core.RMCore)8 Criteria (org.ow2.proactive.utils.Criteria)8 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)7 Client (org.ow2.proactive.resourcemanager.authentication.Client)7 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)7 NodeSet (org.ow2.proactive.utils.NodeSet)7 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)6 Node (org.objectweb.proactive.core.node.Node)5 MutableInteger (org.objectweb.proactive.core.util.MutableInteger)5 RMException (org.ow2.proactive.resourcemanager.exception.RMException)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Matchers.anyString (org.mockito.Matchers.anyString)4 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)4 TopologyManager (org.ow2.proactive.resourcemanager.selection.topology.TopologyManager)4 Throwables.getStackTraceAsString (com.google.common.base.Throwables.getStackTraceAsString)3 KeyException (java.security.KeyException)3 HashMap (java.util.HashMap)3