Search in sources :

Example 36 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager in project scheduling by ow2-proactive.

the class TestConcurrentUsers method testConcurrency.

@Test
public void testConcurrency() throws Exception {
    ResourceManager resourceManager = rmHelper.getResourceManager();
    String nsName = "TestConcurrentUsers";
    String node1Name = "node1";
    testNode = rmHelper.createNode(node1Name);
    String node1URL = testNode.getNode().getNodeInformation().getURL();
    resourceManager.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
    resourceManager.addNode(node1URL, nsName);
    // waiting for node adding event
    rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, node1URL);
    // waiting for the node to be free
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    assertTrue(resourceManager.getState().getTotalNodesNumber() == 1);
    assertTrue(resourceManager.getState().getFreeNodesNumber() == 1);
    log("Test 1 - releasing of the foreign node");
    // acquiring a node
    final NodeSet ns = resourceManager.getAtMostNodes(1, null);
    // waiting for node busy event
    RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node1URL);
    assertEquals(evt.getNodeState(), NodeState.BUSY);
    assertEquals(ns.size(), 1);
    assertTrue(resourceManager.getState().getTotalNodesNumber() == 1);
    assertTrue(resourceManager.getState().getFreeNodesNumber() == 0);
    Thread t = new Thread() {

        @Override
        public void run() {
            try {
                Credentials cred = Credentials.createCredentials(new CredData(CredData.parseLogin("user"), CredData.parseDomain("user"), "pwd"), TestConcurrentUsers.this.rmHelper.getRMAuth().getPublicKey());
                ResourceManager rm2 = TestConcurrentUsers.this.rmHelper.getRMAuth().login(cred);
                rm2.releaseNode(ns.get(0)).getBooleanValue();
                Assert.assertTrue("Should not be able to release foreign node", false);
            } catch (Exception e) {
                log(e.getMessage());
            }
        }
    };
    t.start();
    t.join();
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    resourceManager.releaseNodes(ns);
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, node1URL);
    assertEquals(evt.getNodeState(), NodeState.FREE);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 2 - releasing node twice");
    resourceManager.releaseNodes(ns);
    // to make sure everything has been processed
    Thread.sleep(1000);
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 3 - client crash detection");
    JVMProcessImpl nodeProcess = new JVMProcessImpl(new org.objectweb.proactive.core.process.AbstractExternalProcess.StandardOutputMessageLogger());
    nodeProcess.setJvmOptions(Collections.singletonList(PAResourceManagerProperties.RM_HOME.getCmdLine() + PAResourceManagerProperties.RM_HOME.getValueAsString()));
    nodeProcess.setClassname(GetAllNodes.class.getName());
    nodeProcess.startProcess();
    // node busy event
    for (int i = 0; i < 1; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(evt.getNodeState(), NodeState.BUSY);
    }
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    // client does not exist anymore
    log("Client does not exist anymore. Waiting for client crash detection.");
    // waiting for node free event
    for (int i = 0; i < 1; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.FREE, evt.getNodeState());
    }
    assertEquals(1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(1, resourceManager.getState().getFreeNodesNumber());
    log("Test 4 - disconnecting");
    NodeSet ns2 = resourceManager.getAtMostNodes(1, null);
    RMNodeEvent event = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, 10000);
    Assert.assertTrue(event.getNodeState() == NodeState.BUSY);
    PAFuture.waitFor(ns2);
    log("Number of found nodes " + ns2.size());
    assertEquals(1, ns2.size());
    t = new Thread() {

        public void run() {
            try {
                RMAuthentication auth = rmHelper.getRMAuth();
                Credentials cred = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), auth.getPublicKey());
                ResourceManager rm = auth.login(cred);
                rm.disconnect().getBooleanValue();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    t.start();
    t.join();
    try {
        event = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED, 10000);
        fail("Unexpected event: " + event);
    } catch (ProActiveTimeoutException e) {
    }
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) DefaultInfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) CredData(org.ow2.proactive.authentication.crypto.CredData) JVMProcessImpl(org.objectweb.proactive.core.process.JVMProcessImpl) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) RMAuthentication(org.ow2.proactive.resourcemanager.authentication.RMAuthentication) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) Credentials(org.ow2.proactive.authentication.crypto.Credentials) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 37 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager in project scheduling by ow2-proactive.

the class TestNodeEncoding method testFileEncodingPropagationToRemoteJVM.

@Test
public void testFileEncodingPropagationToRemoteJVM() throws Exception {
    String javaProperty = "-D" + PAProperties.KEY_PA_FILE_ENCODING + "=" + FILE_ENCODING_NAME;
    ResourceManager resourceManager = rmHelper.getResourceManager(TestUsers.TEST, javaProperty);
    String nodeUrl = createNodeSourceWithOneLocalNode();
    List<ScriptResult<Object>> results = resourceManager.executeScript("import org.ow2.proactive.utils.PAProperties; print PAProperties.getFileEncoding()", "groovy", TargetType.NODE_URL.name(), ImmutableSet.of(nodeUrl));
    Assert.assertTrue(!results.isEmpty());
    Assert.assertEquals(FILE_ENCODING_NAME, results.get(0).getOutput());
}
Also used : ScriptResult(org.ow2.proactive.scripting.ScriptResult) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 38 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager in project scheduling by ow2-proactive.

the class TestNodesStates method testManyStatesChanges.

@Test
public void testManyStatesChanges() throws Exception {
    ResourceManager resourceManager = rmHelper.getResourceManager();
    int totalNodeNumber = 5;
    rmHelper.createNodeSource("TestNodesStates", totalNodeNumber);
    // ----------------------------------------------------------
    // Book all nodes deployed by descriptor (user action)
    // verify that there are no free nodes left,
    // and give back to RM
    log("Test 1");
    NodeSet nodes = resourceManager.getAtMostNodes(totalNodeNumber, null);
    PAFuture.waitFor(nodes);
    assertEquals(totalNodeNumber, nodes.size());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    for (int i = 0; i < totalNodeNumber; i++) {
        RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodes.get(i).getNodeInformation().getURL());
        assertEquals(NodeState.BUSY, evt.getNodeState());
        checkEvent(evt, nodes.get(i));
    }
    // for next test
    Node n = nodes.get(0);
    resourceManager.releaseNodes(nodes);
    for (int i = 0; i < totalNodeNumber; i++) {
        RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodes.get(i).getNodeInformation().getURL());
        assertEquals(NodeState.FREE, evt.getNodeState());
        checkEvent(evt, nodes.get(i));
    }
    // ----------------------------------------------------------
    // give back a node already given back (i.e; node already free)
    // this action causes nothing(nor increasing free nodes number, nor generation of any event)
    log("Test 2");
    resourceManager.releaseNode(n);
    boolean timeouted = false;
    try {
        rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL(), 4000);
    } catch (ProActiveTimeoutException e) {
        timeouted = true;
    }
    assertTrue(timeouted);
    assertEquals(totalNodeNumber, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // Book all nodes deployed by descriptor
    // Test admin action : Remove a node from the RM (non preemptively),
    // node is busy, so becomes in "toRelease" state
    // user give back to RM the "toRelease" node, node is now removed
    log("Test 3");
    nodes = resourceManager.getAtMostNodes(totalNodeNumber, null);
    PAFuture.waitFor(nodes);
    for (int i = 0; i < totalNodeNumber; i++) {
        RMNodeEvent evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.BUSY, evt.getNodeState());
    }
    n = nodes.remove(0);
    // put node in "To Release" state
    resourceManager.removeNode(n.getNodeInformation().getURL(), false);
    // check that node toRelease event has been thrown
    RMNodeEvent evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.TO_BE_REMOVED, evt.getNodeState());
    // node is in "ToRelease" state, so always handled by RM
    assertEquals(totalNodeNumber, resourceManager.getState().getTotalNodesNumber());
    // user give back the node, so node is now removed
    resourceManager.releaseNode(n);
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL());
    // ----------------------------------------------------------
    // nodes are always in busy state
    // kill JVM of a node (simulate a fallen JVM or broken connection, i.e down node)
    // node must detected down by RM
    log("Test 4");
    n = nodes.get(0);
    // for next test
    Node n2 = nodes.get(1);
    try {
        n.getProActiveRuntime().killNode(n.getNodeInformation().getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.DOWN, evt.getNodeState());
    checkEvent(evt, n);
    resourceManager.releaseNodes(nodes);
    for (int i = 0; i < totalNodeNumber - 2; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.FREE, evt.getNodeState());
    }
    // two nodes killed, but the detected down is in RM down nodes list
    // ( down nodes are in total nodes count)
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 2, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // nodes left are in free state
    // kill JVM of a free node
    // node must detected down by RM
    log("Test 5");
    try {
        n2.getProActiveRuntime().killNode(n2.getNodeInformation().getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n2.getNodeInformation().getURL());
    assertEquals(NodeState.DOWN, evt.getNodeState());
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 3, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // book nodes, put one node in "toRelease" state,
    // then kill its JVM,
    // node must detected down by RM
    log("Test 6");
    nodes = resourceManager.getAtMostNodes(totalNodeNumber - 3, null);
    PAFuture.waitFor(nodes);
    for (int i = 0; i < totalNodeNumber - 3; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.BUSY, evt.getNodeState());
    }
    n = nodes.get(0);
    // for next test
    n2 = nodes.get(1);
    // put node in "To Release" state
    resourceManager.removeNode(n.getNodeInformation().getURL(), false);
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.TO_BE_REMOVED, evt.getNodeState());
    log("Test 6 Bis");
    // kill the node
    try {
        n.getProActiveRuntime().killNode(n.getNodeInformation().getName());
    } catch (Exception e) {
        e.printStackTrace();
    }
    evt = rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, n.getNodeInformation().getURL());
    assertEquals(NodeState.DOWN, evt.getNodeState());
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(0, resourceManager.getState().getFreeNodesNumber());
    for (Node node : nodes) {
        log("Taken node: " + node.getNodeInformation().getURL());
    }
    // we have 2 nodes: 11 busy and one still down
    resourceManager.releaseNodes(nodes);
    for (int i = 0; i < 1; i++) {
        evt = rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
        assertEquals(NodeState.FREE, evt.getNodeState());
    }
    assertEquals(totalNodeNumber - 1, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 4, resourceManager.getState().getFreeNodesNumber());
    // admin removes again the node, ok he already asked this removal when node n was busy
    // choice here is advert admin that node has fallen (not hiding the down node event),
    // rather than automatically remove it
    resourceManager.removeNode(n.getNodeInformation().getURL(), false);
    // check that node removed event has been received
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n.getNodeInformation().getURL());
    assertEquals(totalNodeNumber - 2, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 4, resourceManager.getState().getFreeNodesNumber());
    // ----------------------------------------------------------
    // Remove a free node,
    // 
    log("Test 7");
    resourceManager.removeNode(n2.getNodeInformation().getURL(), false);
    // check that node removed event has been received
    rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, n2.getNodeInformation().getURL());
    assertEquals(totalNodeNumber - 3, resourceManager.getState().getTotalNodesNumber());
    assertEquals(totalNodeNumber - 5, resourceManager.getState().getFreeNodesNumber());
    log("End of test");
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) Node(org.objectweb.proactive.core.node.Node) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent) ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Example 39 with ResourceManager

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

Example 40 with ResourceManager

use of org.ow2.proactive.resourcemanager.frontend.ResourceManager in project scheduling by ow2-proactive.

the class TestNSAdminPermissions method action.

@Test
public void action() throws Exception {
    String nsName = "TestNSAdminPermissions";
    ResourceManager adminRMAccess = rmHelper.getResourceManager(TestUsers.ADMIN);
    RMTHelper.log("Test1 - node source removal");
    adminRMAccess.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), new Object[] { "ALL", "ME" }, NODES_NOT_RECOVERABLE);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
    // user does not have an access to change the node source
    ResourceManager userRMAccess = rmHelper.getResourceManager(TestUsers.RADMIN);
    try {
        userRMAccess.removeNodeSource(nsName, true).getBooleanValue();
        fail();
    } catch (Exception e) {
    }
    // admin and provider are in "nsadmins" group
    ResourceManager providerRMAccess = rmHelper.getResourceManager(TestUsers.NSADMIN);
    try {
        providerRMAccess.removeNodeSource(nsName, true).getBooleanValue();
        fail();
    } catch (Exception e) {
    }
    adminRMAccess = rmHelper.getResourceManager(TestUsers.ADMIN);
    adminRMAccess.removeNodeSource(nsName, true).getBooleanValue();
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nsName);
    RMTHelper.log("Test2 - ns admin can remove foreign nodes");
    userRMAccess = rmHelper.getResourceManager(TestUsers.RADMIN);
    userRMAccess.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), new Object[] { "PROVIDER", "ALL" }, NODES_NOT_RECOVERABLE);
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
    providerRMAccess = rmHelper.getResourceManager(TestUsers.NSADMIN);
    TestNode testNode1 = rmHelper.createNode("node1");
    testNodes.add(testNode1);
    Node node = testNode1.getNode();
    // adding the node as provider
    providerRMAccess.addNode(node.getNodeInformation().getURL(), nsName).getBooleanValue();
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    // node becomes free
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    userRMAccess = rmHelper.getResourceManager(TestUsers.RADMIN);
    // this is an administrator of the node source, so it can remove the foreign node
    userRMAccess.removeNode(node.getNodeInformation().getURL(), true).getBooleanValue();
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_REMOVED);
    RMTHelper.log("Test3 - ns admin cannot get the foreign node");
    providerRMAccess = rmHelper.getResourceManager(TestUsers.NSADMIN);
    TestNode testNode2 = rmHelper.createNode("node2");
    testNodes.add(testNode2);
    Node node2 = testNode2.getNode();
    // adding the node as provider
    providerRMAccess.addNode(node2.getNodeInformation().getURL(), nsName).getBooleanValue();
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_ADDED);
    // node becomes free
    rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
    userRMAccess = rmHelper.getResourceManager(TestUsers.RADMIN);
    // this is an administrator of the node source, so it can remove the foreign node
    NodeSet nodes = userRMAccess.getAtMostNodes(1, null);
    Assert.assertEquals("NS admin cannot get nodes as the get level is set to PROVIDER", 0, nodes.size());
    RMTHelper.log("Test4 - user with AllPermisssion can remove any node sources");
    adminRMAccess = rmHelper.getResourceManager(TestUsers.ADMIN);
    adminRMAccess.removeNodeSource(nsName, true).getBooleanValue();
    rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nsName);
    RMTHelper.log("Success");
}
Also used : NodeSet(org.ow2.proactive.utils.NodeSet) DefaultInfrastructureManager(org.ow2.proactive.resourcemanager.nodesource.infrastructure.DefaultInfrastructureManager) StaticPolicy(org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy) Node(org.objectweb.proactive.core.node.Node) TestNode(functionaltests.utils.TestNode) TestNode(functionaltests.utils.TestNode) ResourceManager(org.ow2.proactive.resourcemanager.frontend.ResourceManager) Test(org.junit.Test) RMFunctionalTest(functionaltests.utils.RMFunctionalTest)

Aggregations

ResourceManager (org.ow2.proactive.resourcemanager.frontend.ResourceManager)45 NodeSet (org.ow2.proactive.utils.NodeSet)26 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)25 Test (org.junit.Test)25 Node (org.objectweb.proactive.core.node.Node)16 File (java.io.File)14 Credentials (org.ow2.proactive.authentication.crypto.Credentials)14 Criteria (org.ow2.proactive.utils.Criteria)13 HashMap (java.util.HashMap)11 CredData (org.ow2.proactive.authentication.crypto.CredData)11 StaticPolicy (org.ow2.proactive.resourcemanager.nodesource.policy.StaticPolicy)11 RMAuthentication (org.ow2.proactive.resourcemanager.authentication.RMAuthentication)10 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)10 TestNode (functionaltests.utils.TestNode)9 SelectionScript (org.ow2.proactive.scripting.SelectionScript)9 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)5 PublicKey (java.security.PublicKey)4