Search in sources :

Example 6 with RMNodeImpl

use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.

the class NodeSourceTest method testSetNodeAvailableUnknownNode.

@Test
public void testSetNodeAvailableUnknownNode() throws RMException {
    Node node = createNode(PROACTIVE_PROGRAMMING_NODE_URL);
    RMNode rmNode = new RMNodeImpl(node, nodeSource, client, mock(Permission.class));
    nodeSource.internalAddNode(node);
    assertThat(nodeSource.getDownNodes()).hasSize(0);
    boolean result = nodeSource.setNodeAvailable(rmNode);
    assertThat(result).isFalse();
    assertThat(nodeSource.getDownNodes()).hasSize(0);
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) Node(org.objectweb.proactive.core.node.Node) Permission(java.security.Permission) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 7 with RMNodeImpl

use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl in project scheduling by ow2-proactive.

the class RMNodeHelper method basicWithMockedInternals.

public static Pair<RMNodeImpl, Node> basicWithMockedInternals(String nodeSourceName, Node node) {
    NodeSource nodeSource = Mockito.mock(NodeSource.class);
    Set<Principal> principals = new HashSet<>();
    principals.add(new UserNamePrincipal("provider"));
    Client provider = new Client(new Subject(false, principals, emptySet(), emptySet()), false);
    Permission permission = Mockito.mock(Permission.class);
    when(nodeSource.getName()).thenReturn(nodeSourceName);
    return new ImmutablePair<>(new RMNodeImpl(node, nodeSource, provider, permission), node);
}
Also used : UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) NodeSource(org.ow2.proactive.resourcemanager.nodesource.NodeSource) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Permission(java.security.Permission) Client(org.ow2.proactive.resourcemanager.authentication.Client) UserNamePrincipal(org.ow2.proactive.authentication.principals.UserNamePrincipal) Principal(java.security.Principal) Subject(javax.security.auth.Subject) HashSet(java.util.HashSet)

Example 8 with RMNodeImpl

use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl 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));
}
Also used : MutableInteger(org.objectweb.proactive.core.util.MutableInteger) RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl) Test(org.junit.Test)

Example 9 with RMNodeImpl

use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl 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 10 with RMNodeImpl

use of org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl 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)

Aggregations

RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)10 Test (org.junit.Test)7 MutableInteger (org.objectweb.proactive.core.util.MutableInteger)5 Permission (java.security.Permission)3 Client (org.ow2.proactive.resourcemanager.authentication.Client)3 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)3 Node (org.objectweb.proactive.core.node.Node)2 BooleanWrapper (org.objectweb.proactive.core.util.wrapper.BooleanWrapper)2 NodeSource (org.ow2.proactive.resourcemanager.nodesource.NodeSource)2 Principal (java.security.Principal)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Subject (javax.security.auth.Subject)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Matchers.anyString (org.mockito.Matchers.anyString)1 IdentityPrincipal (org.ow2.proactive.authentication.principals.IdentityPrincipal)1 TokenPrincipal (org.ow2.proactive.authentication.principals.TokenPrincipal)1 UserNamePrincipal (org.ow2.proactive.authentication.principals.UserNamePrincipal)1 PrincipalPermission (org.ow2.proactive.permissions.PrincipalPermission)1