use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class SelectionManagerTest method testSelectNodesWith10Node.
@Test
public void testSelectNodesWith10Node() {
RMCore rmCore = newMockedRMCore(10);
SelectionManager selectionManager = createSelectionManager(rmCore);
Criteria crit = new Criteria(10);
crit.setTopology(TopologyDescriptor.ARBITRARY);
crit.setScripts(null);
crit.setBlackList(null);
crit.setBestEffort(true);
Client mockedClient = mock(Client.class);
NodeSet nodeSet = selectionManager.selectNodes(crit, mockedClient);
assertEquals(10, nodeSet.size());
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class SelectionManagerTest method selectWithDifferentPermissions.
@Test
public void selectWithDifferentPermissions() throws Exception {
PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER.updateProperty("10");
System.out.println("PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER=" + PAResourceManagerProperties.RM_SELECTION_MAX_THREAD_NUMBER);
System.setSecurityManager(securityManagerRejectingUser());
RMCore.topologyManager = mock(TopologyManager.class);
RMCore rmCore = mock(RMCore.class);
when(RMCore.topologyManager.getHandler(Matchers.<TopologyDescriptor>any())).thenReturn(selectAllTopology());
SelectionManager selectionManager = createSelectionManager(rmCore);
ArrayList<RMNode> freeNodes = new ArrayList<>();
freeNodes.add(createMockedNode("admin"));
freeNodes.add(createMockedNode("user"));
when(rmCore.getFreeNodes()).thenReturn(freeNodes);
Criteria criteria = new Criteria(2);
criteria.setTopology(TopologyDescriptor.ARBITRARY);
Subject subject = Subjects.create("admin");
NodeSet nodes = selectionManager.selectNodes(criteria, new Client(subject, false));
assertEquals(1, nodes.size());
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class SelectionManagerTest method testSelectNodesWith1Node.
@Test
public void testSelectNodesWith1Node() {
RMCore rmCore = newMockedRMCore(1);
SelectionManager selectionManager = createSelectionManager(rmCore);
Criteria crit = new Criteria(1);
crit.setTopology(TopologyDescriptor.ARBITRARY);
crit.setScripts(null);
crit.setBlackList(null);
crit.setBestEffort(true);
Client mockedClient = mock(Client.class);
NodeSet nodeSet = selectionManager.selectNodes(crit, mockedClient);
assertEquals(1, nodeSet.size());
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class TestAddRemoveAll method testCreateNodeSource.
@Test
public void testCreateNodeSource() throws Exception {
ResourceManager resourceManager = rmHelper.getResourceManager();
int pingFrequency = 6000;
log("Add/RemoveAll");
resourceManager.createNodeSource(nsName, DefaultInfrastructureManager.class.getName(), null, StaticPolicy.class.getName(), null, NODES_NOT_RECOVERABLE);
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, nsName);
resourceManager.setNodeSourcePingFrequency(pingFrequency, nsName);
testNode = rmHelper.createNode(nodeName);
Node nodeToAdd = testNode.getNode();
resourceManager.addNode(nodeToAdd.getNodeInformation().getURL(), nsName).getBooleanValue();
// at this time, nodes maybe fully added in the nodesource but not in the core
// the next removal may fail for some nodes that are not known by the core...
resourceManager.removeNodeSource(nsName, true);
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_REMOVED, nsName);
Thread.sleep(pingFrequency * 2);
if (resourceManager.getState().getTotalNodesNumber() != 0) {
log("The removeAll method in RMCore didn't removed all nodes");
fail();
} else {
log("The removeAll method in RMCore did its job well");
}
}
use of org.ow2.proactive.resourcemanager.core.RMCore in project scheduling by ow2-proactive.
the class NonBlockingCoreTest method action.
@Test
public void action() throws Exception {
String rmconf = new File(PAResourceManagerProperties.getAbsolutePath(getClass().getResource("/functionaltests/config/functionalTRMProperties-long-selection-script-timeout.ini").getFile())).getAbsolutePath();
rmHelper.startRM(rmconf);
ResourceManager resourceManager = rmHelper.getResourceManager();
int initialNodeNumber = 2;
rmHelper.createNodeSource("NonBlockingCoreTest1", initialNodeNumber);
long coreScriptExecutionTimeout = PAResourceManagerProperties.RM_SELECT_SCRIPT_TIMEOUT.getValueAsLong();
long scriptSleepingTime = coreScriptExecutionTimeout * 2;
log("Selecting node with timeout script");
// create the static selection script object
final SelectionScript sScript = new SelectionScript(new File(selectionScriptWithtimeOutPath.toURI()), new String[] { Long.toString(scriptSleepingTime) }, false);
// mandatory to use RMUser AO, otherwise, getAtMostNode we be send in
// RMAdmin request queue
final RMAuthentication auth = rmHelper.getRMAuth();
final Credentials cred = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), auth.getPublicKey());
// cannot connect twice from the same active object
// so creating another thread
Thread t = new Thread() {
public void run() {
ResourceManager rm2;
try {
rm2 = auth.login(cred);
nodes = rm2.getAtMostNodes(2, sScript);
} catch (LoginException e) {
}
}
};
t.start();
String nodeName = "node_non_blocking_test";
testNode = RMTHelper.createNode(nodeName);
String nodeUrl = testNode.getNode().getNodeInformation().getURL();
log("Adding node " + nodeUrl);
resourceManager.addNode(nodeUrl);
rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, nodeUrl);
// waiting for node to be in free state, it is in configuring state when
// added...
rmHelper.waitForAnyNodeEvent(RMEventType.NODE_STATE_CHANGED);
assertEquals(resourceManager.getState().getTotalNodesNumber(), initialNodeNumber + 1);
assertEquals(resourceManager.getState().getFreeNodesNumber(), initialNodeNumber + 1);
// preemptive removal is useless for this case, because node is free
log("Removing node " + nodeUrl);
resourceManager.removeNode(nodeUrl, false);
rmHelper.waitForNodeEvent(RMEventType.NODE_REMOVED, nodeUrl);
assertEquals(resourceManager.getState().getTotalNodesNumber(), initialNodeNumber);
assertEquals(resourceManager.getState().getFreeNodesNumber(), initialNodeNumber);
String nsName = "NonBlockingCoreTest";
log("Creating a node source " + nsName);
int nsNodesNumber = 1;
rmHelper.createNodeSource(nsName, nsNodesNumber);
assertEquals(resourceManager.getState().getTotalNodesNumber(), nsNodesNumber + initialNodeNumber);
assertEquals(resourceManager.getState().getFreeNodesNumber(), nsNodesNumber + initialNodeNumber);
log("Removing node source " + nsName);
resourceManager.removeNodeSource(nsName, true);
boolean selectionInProgress = PAFuture.isAwaited(nodes);
if (!selectionInProgress) {
// normally we are looking for 2 nodes with timeout script,
// so the selection procedure has to finish not earlier than
// coreScriptExecutionTimeout * nodesNumber
// it should be sufficient to perform all admin operations
// concurrently
//
// if the core is blocked admin operations will be performed after
// selection
fail("Blocked inside RMCore");
} else {
log("No blocking inside RMCore");
}
t.interrupt();
}
Aggregations