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));
}
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));
}
use of org.ow2.proactive.resourcemanager.core.recovery.NodesLockRestorationManager in project scheduling by ow2-proactive.
the class NodesRecoveryManagerTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
nodesLockRestorationManager = null;
nodesRecoveryManager = new NodesRecoveryManager(rmCore);
nodesRecoveryManager = spy(nodesRecoveryManager);
nodesLockRestorationManager = null;
doReturn((Function<RMCore, NodesLockRestorationManager>) rmCore -> {
nodesLockRestorationManager = new NodesLockRestorationManager(rmCore);
nodesLockRestorationManager = spy(nodesLockRestorationManager);
doReturn(Maps.newHashMap()).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
return nodesLockRestorationManager;
}).when(nodesRecoveryManager).getNodesLockRestorationManagerBuilder();
initialize();
}
use of org.ow2.proactive.resourcemanager.core.recovery.NodesLockRestorationManager in project scheduling by ow2-proactive.
the class NodesLockRestorationManagerTest method testHandleNodeAlreadyLocked.
@Test
public void testHandleNodeAlreadyLocked() {
RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
rmNode.lock(null);
assertThat(rmNode.isLocked()).isTrue();
Map<String, MutableInteger> table = Maps.newHashMap();
MutableInteger putResult = table.put("ns", new MutableInteger(1));
assertThat(putResult).isNull();
doReturn(table).when(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
nodesLockRestorationManager.initialize();
assertThat(nodesLockRestorationManager.isInitialized()).isTrue();
verify(nodesLockRestorationManager).findNodesLockedOnPreviousRun();
assertThat(table).hasSize(1);
verify(rmCore, never()).lockNodes(anySetOf(String.class));
nodesLockRestorationManager.handle(rmNode, caller);
assertThat(table).hasSize(1);
verify(rmCore, never()).lockNodes(anySetOf(String.class));
}
use of org.ow2.proactive.resourcemanager.core.recovery.NodesLockRestorationManager 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));
}
Aggregations