Search in sources :

Example 11 with NodesLockRestorationManager

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

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

Aggregations

Test (org.junit.Test)11 MutableInteger (org.objectweb.proactive.core.util.MutableInteger)10 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)10 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 NodesLockRestorationManager (org.ow2.proactive.resourcemanager.core.recovery.NodesLockRestorationManager)2 NodesRecoveryManager (org.ow2.proactive.resourcemanager.core.recovery.NodesRecoveryManager)2 Maps (com.google.common.collect.Maps)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Permission (java.security.Permission)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Function (java.util.function.Function)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Mock (org.mockito.Mock)1 Mockito.doReturn (org.mockito.Mockito.doReturn)1 Mockito.never (org.mockito.Mockito.never)1 Mockito.spy (org.mockito.Mockito.spy)1 Mockito.verify (org.mockito.Mockito.verify)1 MockitoAnnotations (org.mockito.MockitoAnnotations)1