use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper 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));
}
use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper 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.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.
the class RMCoreTest method testLockNodeState.
private void testLockNodeState(NodeState nodeState) {
RMNodeImpl rmNode = spy(RMNodeHelper.basicWithMockedInternals().getLeft());
rmNode.setState(nodeState);
HashMap<String, RMNode> allNodes = new HashMap<>();
allNodes.put(rmNode.getNodeURL(), rmNode);
ArrayList<RMNode> freeNodes = Lists.newArrayList((RMNode) rmNode);
RMCore rmCore = new RMCore(new HashMap<String, NodeSource>(), allNodes, Mockito.mock(Client.class), Mockito.mock(RMMonitoringImpl.class), Mockito.mock(SelectionManager.class), freeNodes, Mockito.mock(RMDBManager.class));
rmCore.signalRMCoreIsInitialized();
BooleanWrapper lockResult = rmCore.lockNodes(ImmutableSet.of(rmNode.getNodeURL()));
assertThat(lockResult.getBooleanValue()).isTrue();
assertThat(rmNode.getState()).isEqualTo(nodeState);
assertThat(rmNode.isLocked()).isTrue();
assertThat(freeNodes).isEmpty();
}
use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.
the class RMRestTest method testAddNodeOverloading.
// PORTAL-326
@Test
public void testAddNodeOverloading() throws Exception {
RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
when(rm.addNode(anyString())).thenReturn(new BooleanWrapper(true));
List<NameValuePair> firstCall = Collections.<NameValuePair>singletonList(new BasicNameValuePair("nodeurl", "url"));
callHttpPostMethod("node", sessionId, firstCall);
verify(rm).addNode("url");
reset(rm);
when(rm.addNode(anyString(), anyString())).thenReturn(new BooleanWrapper(true));
List<NameValuePair> secondCall = new ArrayList<>();
secondCall.add(new BasicNameValuePair("nodeurl", "urlwithnsname"));
secondCall.add(new BasicNameValuePair("nodesource", "ns"));
callHttpPostMethod("node", sessionId, secondCall);
verify(rm).addNode("urlwithnsname", "ns");
}
use of org.objectweb.proactive.core.util.wrapper.BooleanWrapper in project scheduling by ow2-proactive.
the class RMRestTest method testShutdown_NoPreemptParameter.
@Test
public void testShutdown_NoPreemptParameter() throws Exception {
RMProxyUserInterface rm = mock(RMProxyUserInterface.class);
when(rm.shutdown(false)).thenReturn(new BooleanWrapper(true));
String sessionId = SharedSessionStoreTestUtils.createValidSession(rm);
HttpResponse response = callHttpGetMethod("shutdown", sessionId);
assertEquals(HttpURLConnection.HTTP_OK, response.getStatusLine().getStatusCode());
verify(rm).shutdown(false);
}
Aggregations