use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class NodeSourcesTest method testAddNodeSourceWithEmptyInfrastructureVariables.
@Test
public void testAddNodeSourceWithEmptyInfrastructureVariables() {
NodeSourceData nodeSourceData = createNodeSource();
nodeSourceData.setInfrastructureVariables(new HashMap<String, Serializable>());
dbManager.addNodeSource(nodeSourceData);
Collection<NodeSourceData> nodeSources = dbManager.getNodeSources();
assertThat(nodeSources).hasSize(1);
NodeSourceData nodeSource = nodeSources.iterator().next();
assertThat(nodeSource.getInfrastructureVariables()).hasSize(0);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class NodeSourcesTest method testAddNodeSourceWithVariousObjectsInInfrastructureVariables.
@Test
public void testAddNodeSourceWithVariousObjectsInInfrastructureVariables() {
NodeSourceData nodeSourceData = createNodeSource();
Map<String, Serializable> infrastructureVariables = new HashMap<>();
Integer integer = new Integer(42);
AtomicBoolean atomicBoolean = new AtomicBoolean(true);
char c = 'z';
infrastructureVariables.put("anInteger", integer);
infrastructureVariables.put("aBoolean", atomicBoolean);
infrastructureVariables.put("aChar", c);
nodeSourceData.setInfrastructureVariables(infrastructureVariables);
dbManager.addNodeSource(nodeSourceData);
Collection<NodeSourceData> nodeSources = dbManager.getNodeSources();
assertThat(nodeSources).hasSize(1);
NodeSourceData nodeSource = nodeSources.iterator().next();
Map<String, Serializable> retrievedInfravariables = nodeSource.getInfrastructureVariables();
assertThat(retrievedInfravariables).hasSize(3);
assertThat(retrievedInfravariables.get("anInteger")).isEqualTo(integer);
// works with autoboxing
assertThat(retrievedInfravariables.get("anInteger")).isEqualTo(42);
assertThat(((AtomicBoolean) retrievedInfravariables.get("aBoolean")).get()).isEqualTo(atomicBoolean.get());
assertThat(retrievedInfravariables.get("aChar")).isEqualTo(c);
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class TestExecRemote method scriptOnNodeSource.
private void scriptOnNodeSource(String nsName, HashSet<String> nodesUrls) throws Exception {
RMTHelper.log("Test 6 - Execute script on a specified nodesource name");
SimpleScript script = new SimpleScript(TestExecRemote.simpleScriptContent, "javascript");
HashSet<String> targets = new HashSet<>(1);
targets.add(nsName);
List<ScriptResult<Object>> results = rmHelper.getResourceManager().executeScript(script, TargetType.NODESOURCE_NAME.toString(), targets);
assertEquals("The size of result list must equal to size of nodesource", nodesUrls.size(), results.size());
for (ScriptResult<Object> res : results) {
Throwable exception = res.getException();
if (exception != null) {
RMTHelper.log("An exception occured while executing the script remotely:");
exception.printStackTrace(System.out);
}
assertNull("No exception must occur", exception);
}
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMCoreTest method configureNodeSource.
private void configureNodeSource(NodeSource nodeSource, String nodeSourceName) {
when(nodeSource.getName()).thenReturn(nodeSourceName);
when(nodeSource.acquireNode(any(String.class), any(Client.class))).thenReturn(new BooleanWrapper(true));
when(nodeSource.acquireNode(any(String.class), any(Client.class))).thenReturn(new BooleanWrapper(true));
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource 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();
}
Aggregations