Search in sources :

Example 16 with RMCore

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

the class NodesLockRestorationManagerTest method testLockNodeSucceeds.

@Test
public void testLockNodeSucceeds() {
    doReturn(new BooleanWrapper(true)).when(rmCore).lockNodes(anySetOf(String.class), eq(caller));
    verify(rmCore, never()).lockNodes(anySetOf(String.class), eq(caller));
    RMNode rmNode = RMNodeHelper.basicWithMockedInternals().getLeft();
    boolean lockResult = nodesLockRestorationManager.lockNode(rmNode, caller);
    assertThat(lockResult).isTrue();
    verify(rmCore).lockNodes(anySetOf(String.class), eq(caller));
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Test(org.junit.Test)

Example 17 with RMCore

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

the class NodesLockRestorationManagerTest method testHandleNoNodesToLock.

@Test
public void testHandleNoNodesToLock() {
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
    assertThat(rmNode.isLocked()).isFalse();
    Map<String, MutableInteger> table = Maps.newHashMap();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    nodesLockRestorationManager.initialize();
    assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
    verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(0);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(0);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 18 with RMCore

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

the class NodesLockRestorationManagerTest method testHandleMatchingNode.

@Test
public void testHandleMatchingNode() {
    doReturn(new BooleanWrapper(true)).when(rmCore).lockNodes(anySetOf(String.class), eq(caller));
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
    assertThat(rmNode.isLocked()).isFalse();
    Map<String, MutableInteger> table = Maps.newHashMap();
    MutableInteger putResult = table.put("ns1", new MutableInteger(1));
    assertThat(putResult).isNull();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class), eq(caller));
    nodesLockRestorationManager.initialize();
    assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
    verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(0);
    verify(rmCore).lockNodes(anySetOf(String.class), eq(caller));
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 19 with RMCore

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

the class NodesLockRestorationManagerTest method testHandleNonMatchingNode.

@Test
public void testHandleNonMatchingNode() {
    RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns2", "n1", "h1", "nurl1", "parurl1").getLeft();
    assertThat(rmNode.isLocked()).isFalse();
    Map<String, MutableInteger> table = Maps.newHashMap();
    MutableInteger putResult = table.put("ns1", new MutableInteger(1));
    assertThat(putResult).isNull();
    doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
    nodesLockRestorationManager.initialize();
    assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
    verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
    nodesLockRestorationManager.handle(rmNode, caller);
    assertThat(table).hasSize(1);
    verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 20 with RMCore

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

the class RMCoreTest method testSetNodesAvailableKnownNodeUrlDown.

@Test
public void testSetNodesAvailableKnownNodeUrlDown() throws ActiveObjectCreationException, NodeException {
    ImmutableMap<String, RMNode> allNodes = ImmutableMap.of(mockedRemovableNode.getNodeURL(), mockedRemovableNode);
    List<RMNode> freeNodes = Collections.emptyList();
    RMCore rmCore = spy(createRmCore(allNodes, freeNodes));
    configureNodeForStateChange(mockedRemovableNode, NodeState.BUSY);
    String unknownNodeUrl = mockedRemovableNode.getNodeURL();
    verify(rmCore, never()).restoreNodeState(mockedRemovableNode.getNodeURL(), mockedRemovableNode);
    Set<String> unknownNodeUrls = rmCore.setNodesAvailable(ImmutableSet.of(unknownNodeUrl));
    assertThat(unknownNodeUrls).isEmpty();
    verify(rmCore).restoreNodeState(mockedRemovableNode.getNodeURL(), mockedRemovableNode);
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

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