use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class NodesLockRestorationManagerTest method testHandleNotInitialized.
@Test
public void testHandleNotInitialized() {
// creates a node that matches an entry in the table specifying the nodes to lock
RMNodeImpl rmNode = RMNodeHelper.basicWithMockedInternals("ns1", "n1", "h1", "nurl1", "parurl1").getLeft();
assertThat(rmNode.isLocked()).isFalse();
Map<String, MutableInteger> table = Maps.newHashMap();
MutableInteger putResult = table.put("ns", new MutableInteger(1));
assertThat(putResult).isNull();
doReturn(table).when(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.RMCore 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.RMCore in project scheduling by ow2-proactive.
the class NodesLockRestorationManagerTest method testLockNodeFails.
@Test
public void testLockNodeFails() {
doReturn(new BooleanWrapper(false)).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).isFalse();
verify(rmCore).lockNodes(anySetOf(String.class), eq(caller));
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class RMCoreTest method populateRMCore.
/**
* 6 nodes (same nodesource).
*/
private void populateRMCore() {
when(mockedCaller.checkPermission(any(Permission.class), any(String.class))).thenReturn(true);
when(mockedSelectionManager.selectNodes(any(Criteria.class), any(Client.class))).thenReturn(new NodeSet());
nodeSources = new HashMap<String, NodeSource>(1);
configureNodeSource(mockedNodeSource, "NODESOURCE-test");
nodeSources.put(mockedNodeSource.getName(), mockedNodeSource);
// MockedRMNodeParameters(String url, boolean isFree, boolean isDown, boolean isLocked, NodeSource nodeSource, RMNode rmNode)
configureRMNode(new MockedRMNodeParameters("mockedRemovableNode", true, true, false, mockedNodeSource, "NODESOURCE-test", mockedRemovableNode));
configureRMNode(new MockedRMNodeParameters("mockedUnremovableNode", false, true, false, mockedNodeSource, "NODESOURCE-test", mockedUnremovableNode));
configureRMNode(new MockedRMNodeParameters(RMDeployingNode.PROTOCOL_ID + "://removableNode", true, true, false, mockedNodeSource, "NODESOURCE-test", mockedRemovableNodeInDeploy));
configureRMNode(new MockedRMNodeParameters(RMDeployingNode.PROTOCOL_ID + "://unRemovableNode", false, false, false, mockedNodeSource, "NODESOURCE-test", mockedUnremovableNodeInDeploy));
configureRMNode(new MockedRMNodeParameters("mockedBusyNode", false, false, true, mockedNodeSource, "NODESOURCE-test", mockedBusyNode));
configureRMNode(new MockedRMNodeParameters("mockedFreeButLockedNode", true, false, true, mockedNodeSource, "NODESOURCE-test", mockedFreeButLockedNode));
HashMap<String, RMNode> nodes = new HashMap<>(6);
nodes.put(mockedRemovableNodeInDeploy.getNodeName(), mockedRemovableNodeInDeploy);
nodes.put(mockedUnremovableNodeInDeploy.getNodeName(), mockedUnremovableNodeInDeploy);
nodes.put(mockedRemovableNode.getNodeName(), mockedRemovableNode);
nodes.put(mockedUnremovableNode.getNodeName(), mockedUnremovableNode);
nodes.put(mockedBusyNode.getNodeName(), mockedBusyNode);
nodes.put(mockedFreeButLockedNode.getNodeName(), mockedFreeButLockedNode);
ArrayList<RMNode> freeNodes = new ArrayList<>(3);
freeNodes.add(mockedRemovableNodeInDeploy);
freeNodes.add(mockedRemovableNode);
freeNodes.add(mockedFreeButLockedNode);
rmCore = new RMCore(nodeSources, nodes, mockedCaller, mockedMonitoring, mockedSelectionManager, freeNodes, dbManager);
rmCore.signalRMCoreIsInitialized();
rmCore = spy(rmCore);
nodesLockRestorationManager = new NodesLockRestorationManager(rmCore);
nodesLockRestorationManager = spy(nodesLockRestorationManager);
doReturn(new Function<RMCore, NodesRecoveryManager>() {
@Override
public NodesRecoveryManager apply(RMCore rmCore) {
nodesRecoveryManager = new NodesRecoveryManager(rmCore);
nodesRecoveryManager = spy(nodesRecoveryManager);
return nodesRecoveryManager;
}
}).when(rmCore).getNodesRecoveryManagerBuilder();
rmCore.initiateRecoveryIfRequired();
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class RMCoreTest method testSetNodesAvailableUnknownNodeUrl.
@Test
public void testSetNodesAvailableUnknownNodeUrl() throws ActiveObjectCreationException, NodeException {
ImmutableMap<String, RMNode> allNodes = ImmutableMap.of(mockedBusyNode.getNodeURL(), mockedBusyNode);
List<RMNode> freeNodes = Collections.emptyList();
RMCore rmCore = createRmCore(allNodes, freeNodes);
String unknownNodeUrl = mockedRemovableNode.getNodeURL();
Set<String> unknownNodeUrls = rmCore.setNodesAvailable(ImmutableSet.of(unknownNodeUrl));
assertThat(unknownNodeUrls).hasSize(1);
assertThat(unknownNodeUrls).contains(unknownNodeUrl);
}
Aggregations