use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class TestRMProxy method testRMProxies.
private void testRMProxies(boolean singleUserConnection) throws Exception {
ResourceManager rm = rmHelper.getResourceManager();
assertEquals(NODES_NUMBER, rm.getState().getFreeNodesNumber());
URI rmUri = new URI(RMTHelper.getLocalUrl());
Credentials schedulerProxyCredentials = Credentials.getCredentials(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.RESOURCE_MANAGER_CREDS.getValueAsString()));
if (singleUserConnection) {
proxiesManager = new SingleConnectionRMProxiesManager(rmUri, schedulerProxyCredentials);
} else {
proxiesManager = new PerUserConnectionRMProxiesManager(rmUri, schedulerProxyCredentials);
}
RMProxy user1RMProxy = proxiesManager.getUserRMProxy("admin", user1Credentials);
assertSame("Proxy manager should return cached proxy instance", user1RMProxy, proxiesManager.getUserRMProxy("admin", user1Credentials));
RMProxy user2RMProxy = proxiesManager.getUserRMProxy("demo", user2Credentials);
assertSame("Proxy manager should return cached proxy instance", user2RMProxy, proxiesManager.getUserRMProxy("demo", user2Credentials));
requestReleaseOneNode(user1RMProxy, rm);
testSplitNodeSet(user1RMProxy, rm);
checkSchedulerProxy(proxiesManager);
requestWithExtraNodes(user1RMProxy, rm);
requestTooManyNodes(user1RMProxy, rm);
requestReleaseAllNodes(user1RMProxy, rm);
checkSchedulerProxy(proxiesManager);
requestReleaseOneNode(user2RMProxy, rm);
requestReleaseAllNodes(user2RMProxy, rm);
requestWithTwoUsers(user1RMProxy, user2RMProxy, rm);
checkSchedulerProxy(proxiesManager);
log("Terminate user proxy1");
proxiesManager.terminateRMProxy("admin");
user1RMProxy = proxiesManager.getUserRMProxy("admin", user1Credentials);
requestReleaseAllNodes(user1RMProxy, rm);
log("Terminate user proxy2");
proxiesManager.terminateRMProxy("demo");
user2RMProxy = proxiesManager.getUserRMProxy("demo", user2Credentials);
requestReleaseAllNodes(user2RMProxy, rm);
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class TestRMProxyRebind method testRebind.
private void testRebind(URI rmUri1, URI rmUri2, ResourceManager rm1, ResourceManager rm2, RMMonitorsHandler monitorsHandler1, RMMonitorsHandler monitorsHandler2, boolean singleConnection) throws Exception {
RMProxiesManager proxiesManager;
if (singleConnection) {
proxiesManager = new SingleConnectionRMProxiesManager(rmUri1, schedulerProxyCredentials);
} else {
proxiesManager = new PerUserConnectionRMProxiesManager(rmUri1, schedulerProxyCredentials);
}
Credentials user1Credentials = Credentials.createCredentials(new CredData("admin", "admin"), helper1.getAuth().getPublicKey());
RMProxy proxy1 = proxiesManager.getUserRMProxy("admin", user1Credentials);
log("Get one node with RM1");
NodeSet rm1NodeSet1 = proxy1.getNodes(new Criteria(1));
waitWhenNodeSetAcquired(rm1NodeSet1, 1, monitorsHandler1);
checkFreeNodes(rm1, NODES_NUMBER - 1);
checkFreeNodes(rm2, NODES_NUMBER);
assertEquals(NODES_NUMBER - 1, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
log("Get one node with RM1");
NodeSet rm1NodeSet2 = proxy1.getNodes(new Criteria(1));
waitWhenNodeSetAcquired(rm1NodeSet2, 1, monitorsHandler1);
checkFreeNodes(rm1, NODES_NUMBER - 2);
checkFreeNodes(rm2, NODES_NUMBER);
assertEquals(NODES_NUMBER - 2, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
log("Rebinding to " + rmUri2);
proxiesManager.rebindRMProxiesManager(rmUri2);
assertEquals(NODES_NUMBER, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
waitWhenNodeSetReleased(2, monitorsHandler1);
log("Get one node with RM2");
NodeSet rm2NodeSet1 = proxy1.getNodes(new Criteria(1));
waitWhenNodeSetAcquired(rm2NodeSet1, 1, monitorsHandler2);
checkFreeNodes(rm1, NODES_NUMBER);
checkFreeNodes(rm2, NODES_NUMBER - 1);
assertEquals(NODES_NUMBER - 1, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
log("Get two nodes with RM2");
NodeSet rm2NodeSet2 = proxy1.getNodes(new Criteria(2));
waitWhenNodeSetAcquired(rm2NodeSet2, 2, monitorsHandler2);
checkFreeNodes(rm1, NODES_NUMBER);
checkFreeNodes(rm2, NODES_NUMBER - 3);
assertEquals(NODES_NUMBER - 3, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
log("Release one node with RM2");
proxy1.releaseNodes(rm2NodeSet1);
waitWhenNodeSetReleased(1, monitorsHandler2);
checkFreeNodes(rm1, NODES_NUMBER);
checkFreeNodes(rm2, NODES_NUMBER - 2);
assertEquals(NODES_NUMBER - 2, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
log("Kill RM1");
PAFuture.waitFor(rm1.shutdown(true));
helper1.kill();
rm1 = null;
assertEquals(NODES_NUMBER - 2, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
log("Release two nodes with RM2");
proxy1.releaseNodes(rm2NodeSet2);
waitWhenNodeSetReleased(2, monitorsHandler2);
checkFreeNodes(rm2, NODES_NUMBER);
assertEquals(NODES_NUMBER, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
log("Try to release node with terminated RM1");
proxy1.releaseNodes(rm1NodeSet2);
log("Try to release node with terminated RM1 one more time");
proxy1.releaseNodes(rm1NodeSet2);
assertEquals(NODES_NUMBER, proxiesManager.getRmProxy().getState().getFreeNodesNumber());
assertTrue(proxiesManager.getRmProxy().isActive().getBooleanValue());
log("Terminate all proxies");
proxiesManager.terminateAllProxies();
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class RMProxyUserInterfaceTest method createRMCachingProxyUserInterface.
private RMListenerProxy createRMCachingProxyUserInterface() throws Exception {
RMListenerProxy proxyUserInterface = PAActiveObject.newActive(RMListenerProxy.class, new Object[] {});
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), pubKey);
proxyUserInterface.init(RMTHelper.getLocalUrl(), adminCreds);
return proxyUserInterface;
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class AddGetDownRemoveTest method action.
@Test
public void action() throws Exception {
// The username and thr password must be the same a used to connect to the RM
final ResourceManager rm = rmHelper.getResourceManager();
// All accounting values are checked through JMX
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), pubKey);
final JMXServiceURL jmxRmiServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI));
final HashMap<String, Object> env = new HashMap<>(1);
env.put(JMXConnector.CREDENTIALS, new Object[] { TestUsers.TEST.username, adminCreds });
// Connect to the JMX RMI Connector Server
final ObjectName myAccountMBeanName = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
final ObjectName managementMBeanName = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
final JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxRmiServiceURL, env);
final MBeanServerConnection conn = jmxConnector.getMBeanServerConnection();
long usedNodeTime = (Long) conn.getAttribute(myAccountMBeanName, "UsedNodeTime");
// ADD, GET, DOWN, REMOVE
// 1) ADD
final String name = "AddGetDownRemoveTest";
testNode = rmHelper.createNode(name);
Node node = testNode.getNode();
final String nodeURL = node.getNodeInformation().getURL();
rm.addNode(nodeURL).getBooleanValue();
rmHelper.waitForNodeSourceEvent(RMEventType.NODESOURCE_CREATED, RMConstants.DEFAULT_STATIC_SOURCE_NAME);
rm.setNodeSourcePingFrequency(5000, RMConstants.DEFAULT_STATIC_SOURCE_NAME);
// wait for node from configuring to free
rmHelper.waitForNodeEvent(RMEventType.NODE_ADDED, nodeURL);
rmHelper.waitForNodeEvent(RMEventType.NODE_STATE_CHANGED, nodeURL);
// 2) GET the same node
final long beforeGetTime = System.currentTimeMillis();
node = rm.getNodes(new Criteria(1)).get(0);
// Sleep a certain amount of time that will be the minimum amount of the GET->RELEASE duration
Thread.sleep(GR_DURATION);
// 3) Kill the node to ensure that the RM considers it as being DOWN
try {
node.getProActiveRuntime().killNode(node.getNodeInformation().getName());
} catch (Exception e) {
}
while (rm.nodeIsAvailable(nodeURL).getBooleanValue()) {
RMTHelper.log("Node is available " + nodeURL);
Thread.sleep(100);
}
final long getDownMaxDuration = System.currentTimeMillis() - beforeGetTime;
// 4) REMOVE
rm.removeNode(nodeURL, true).getBooleanValue();
// Refresh the account manager
conn.invoke(managementMBeanName, "clearAccoutingCache", null, null);
// Check account values validity
usedNodeTime = (Long) conn.getAttribute(myAccountMBeanName, "UsedNodeTime") - usedNodeTime;
Assert.assertTrue("Invalid value of the usedNodeTime attribute : " + usedNodeTime + " while expected is " + GR_DURATION, (usedNodeTime >= GR_DURATION) && (usedNodeTime <= getDownMaxDuration));
}
use of org.ow2.proactive.authentication.crypto.Credentials in project scheduling by ow2-proactive.
the class ResourceManagerJMXTest method action.
@Test
public void action() throws Exception {
final RMAuthentication auth = rmHelper.getRMAuth();
final PublicKey pubKey = auth.getPublicKey();
final Credentials adminCreds = Credentials.createCredentials(new CredData(TestUsers.TEST.username, TestUsers.TEST.password), pubKey);
final JMXServiceURL jmxRmiServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RMI));
final JMXServiceURL jmxRoServiceURL = new JMXServiceURL(auth.getJMXConnectorURL(JMXTransportProtocol.RO));
final ObjectName allAccountsMBeanName = new ObjectName(RMJMXBeans.ALLACCOUNTS_MBEAN_NAME);
final ObjectName myAccountMBeanName = new ObjectName(RMJMXBeans.MYACCOUNT_MBEAN_NAME);
final ObjectName runtimeDataMBeanName = new ObjectName(RMJMXBeans.RUNTIMEDATA_MBEAN_NAME);
final ObjectName managementMBeanName = new ObjectName(RMJMXBeans.MANAGEMENT_MBEAN_NAME);
final String suffix = "/" + PAResourceManagerProperties.RM_JMX_CONNECTOR_NAME.getValueAsString();
jmxURLsAreWellFormed(jmxRmiServiceURL, jmxRoServiceURL, suffix);
jmxAuthInvalidCreds(jmxRmiServiceURL);
jmxAuthNullLoginPassword(jmxRmiServiceURL);
jmxAuthInvalidLoginPassword(jmxRmiServiceURL);
jmxRMIAsUser(jmxRmiServiceURL, allAccountsMBeanName, myAccountMBeanName, runtimeDataMBeanName);
jmxRemoteObjectAsAdmin(adminCreds, jmxRoServiceURL, allAccountsMBeanName, managementMBeanName);
simultaneousRMIAndROConnections(adminCreds, jmxRmiServiceURL, jmxRoServiceURL);
jmxClientHelper(auth, adminCreds);
}
Aggregations