Search in sources :

Example 21 with BooleanWrapper

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));
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Test(org.junit.Test)

Example 22 with BooleanWrapper

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));
}
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 23 with BooleanWrapper

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();
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) SelectionManager(org.ow2.proactive.resourcemanager.selection.SelectionManager) HashMap(java.util.HashMap) RMMonitoringImpl(org.ow2.proactive.resourcemanager.frontend.RMMonitoringImpl) Matchers.anyString(org.mockito.Matchers.anyString) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Client(org.ow2.proactive.resourcemanager.authentication.Client)

Example 24 with BooleanWrapper

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");
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 25 with BooleanWrapper

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);
}
Also used : BooleanWrapper(org.objectweb.proactive.core.util.wrapper.BooleanWrapper) RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) HttpResponse(org.apache.http.HttpResponse) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)36 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)10 Test (org.junit.Test)9 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)7 Matchers.anyString (org.mockito.Matchers.anyString)5 Node (org.objectweb.proactive.core.node.Node)5 HashSet (java.util.HashSet)4 Client (org.ow2.proactive.resourcemanager.authentication.Client)4 RMNodeSourceEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeSourceEvent)4 RMDeployingNode (org.ow2.proactive.resourcemanager.rmnode.RMDeployingNode)4 NodeSet (org.ow2.proactive.utils.NodeSet)4 RMMonitorEventReceiver (functionaltests.monitor.RMMonitorEventReceiver)3 RMFunctionalTest (functionaltests.utils.RMFunctionalTest)3 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)3 RMTHelper (functionaltests.utils.RMTHelper)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 HttpResponse (org.apache.http.HttpResponse)2 ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)2 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)2