use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method testManagerShutdownWithComponentDestruction.
public void testManagerShutdownWithComponentDestruction() {
try {
boolean activateOnActivation = true;
TestContainer container = new TestContainer("Container");
Map supportedComponents = new HashMap();
TestContainer container2 = new TestContainer("Container2");
Map supportedComponents2 = new HashMap();
TestComponent mount1COB = new TestComponent("MOUNT1");
TestHierarchicalComponent mount2HierCOB = new TestHierarchicalComponent("HierarchicalCOB2", manager, new String[] { "MOUNT3" }, true, activateOnActivation);
TestHierarchicalComponent mount3HierCOB = new TestHierarchicalComponent("HierarchicalCOB3", manager, new String[] { "MOUNT5", "PBEND_B_01" }, true, activateOnActivation);
TestComponent mount5COB = new TestComponent("MOUNT5");
TestHierarchicalComponent mount4HierCOB = new TestHierarchicalComponent("HierarchicalCOB4", manager, new String[] { "MOUNT2" }, true, activateOnActivation);
TestHierarchicalComponent psHierCOB = new TestHierarchicalComponent("HierarchicalPSCOB", manager, new String[] { "MOUNT5" }, true, activateOnActivation);
supportedComponents.put("MOUNT1", mount1COB);
supportedComponents.put("MOUNT2", mount2HierCOB);
supportedComponents.put("MOUNT3", mount3HierCOB);
supportedComponents2.put("MOUNT5", mount5COB);
supportedComponents.put("MOUNT4", mount4HierCOB);
supportedComponents.put("PBEND_B_01", psHierCOB);
container.setSupportedComponents(supportedComponents);
container2.setSupportedComponents(supportedComponents2);
ClientInfo containerInfo = manager.login(container);
ClientInfo containerInfo2 = manager.login(container2);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// activate hier. components
URI mount2URI;
try {
mount2URI = new URI("MOUNT2");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
assertEquals(mount2HierCOB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
// activate orphan component
URI mount1URI;
try {
mount1URI = new URI("MOUNT1");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount1URI, true, status);
assertEquals(mount1COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
// activate mount4
URI mount4URI;
try {
mount4URI = new URI("MOUNT4");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount4URI, true, status);
assertEquals(mount4HierCOB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// test activated Components
// there should be all three Components activated
ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
assertEquals(6, infos.length);
// check container shutdown order
int[] containerSolution = new int[] { mount4HierCOB.getHandle(), mount2HierCOB.getHandle(), mount3HierCOB.getHandle(), psHierCOB.getHandle(), mount1COB.getHandle() };
int[] containerOrder = container.get_component_shutdown_order();
assertNotNull(containerOrder);
assertEquals(containerSolution.length, containerOrder.length);
for (int i = 0; i < containerSolution.length; i++) assertEquals(containerSolution[i], containerOrder[i]);
int[] container2Order = container2.get_component_shutdown_order();
/*
int[] container2Solution = new int[] {mount5COB.getHandle()};
assertNotNull(container2Order);
assertEquals(container2Solution.length, container2Order.length);
for (int i = 0; i < container2Solution.length; i++)
assertEquals(container2Solution[i], container2Order[i]);
*/
// optimization, no notification if sequence size is not less than 1
assertNull(container2Order);
// check shutdown
try {
manager.shutdown(manager.getHandle(), 1);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
assertEquals(0, container.getActivatedComponents().size());
assertEquals(0, container2.getActivatedComponents().size());
} finally {
// tearDown should not shutdown
manager = null;
}
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method testManagerToContainerStateTransferComponents.
public void testManagerToContainerStateTransferComponents() {
TestComponent mount1COB = new TestComponent("MOUNT1");
TestComponent mount2COB = new TestComponent("MOUNT2");
Map supportedComponents = new HashMap();
supportedComponents.put("MOUNT1", mount1COB);
supportedComponents.put("MOUNT2", mount2COB);
TestContainer container = new TestContainer("Container");
container.setSupportedComponents(supportedComponents);
// recovery mode
TestContainer container2 = new TestContainer("Container", ClientType.CONTAINER, true);
container2.setSupportedComponents(supportedComponents);
try {
// container login
ClientInfo containerInfo = manager.login(container);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
// activate MOUNT2
//
URI mount1URI;
URI mount2URI;
try {
mount1URI = new URI("MOUNT1");
mount2URI = new URI("MOUNT2");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount1URI, true, status);
assertEquals(mount1COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
assertEquals(mount2COB, ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
} catch (Exception ex) {
fail();
}
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
manager.logout(containerInfo.getHandle());
// now do the trick, make container2 to login
// this will assime container is down
ClientInfo containerInfo2 = manager.login(container2);
try {
Thread.sleep(STARTUP_COBS_SLEEP_TIME_MS);
} catch (InterruptedException ie) {
}
// there should be 2 Components activated
ComponentInfo[] infos = manager.getComponentInfo(info.getHandle(), new int[0], "*", "*", true);
Arrays.sort(infos);
assertEquals(2, infos.length);
assertEquals("MOUNT1", infos[0].getName());
assertEquals("MOUNT2", infos[1].getName());
// container2 took over
assertEquals(containerInfo2.getHandle(), infos[0].getContainer());
assertEquals(containerInfo2.getHandle(), infos[1].getContainer());
// manager and client
assertEquals(2, infos[0].getClients().size());
assertTrue(infos[0].getClients().contains(info.getHandle()));
assertTrue(infos[0].getClients().contains(HandleConstants.MANAGER_MASK));
// client only
assertEquals(1, infos[1].getClients().size());
assertTrue(infos[1].getClients().contains(info.getHandle()));
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method testOnDemandContainer.
public void testOnDemandContainer() throws Throwable {
TestDaemon daemon = new TestDaemon(manager, false);
transport.registerDeamon("test", daemon);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
assertTrue(info.getHandle() != 0);
URI curl = null;
// test on-demand activation
curl = new URI("DEMANDER");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), curl, true, status);
assertNotNull(ref);
assertEquals(ComponentStatus.COMPONENT_ACTIVATED, status.getStatus());
// check if container is logged in
ContainerInfo[] infos = manager.getContainerInfo(info.getHandle(), new int[0], "OnDemandContainer");
assertNotNull(infos);
assertEquals(1, infos.length);
// release component
manager.releaseComponent(info.getHandle(), curl);
Thread.sleep(SLEEP_TIME_MS);
// there should be no container
infos = manager.getContainerInfo(info.getHandle(), new int[0], "OnDemandContainer");
assertNotNull(infos);
assertEquals(0, infos.length);
// now fail to start container
daemon = new TestDaemon(manager, true);
transport.registerDeamon("test", daemon);
try {
status = new StatusHolder();
ref = manager.getComponent(info.getHandle(), curl, true, status);
fail();
} catch (AcsJCannotGetComponentEx e) {
System.out.println("This is OK: " + e.toString());
}
// no daemon case
transport.registerDeamon("test", null);
try {
status = new StatusHolder();
ref = manager.getComponent(info.getHandle(), curl, true, status);
fail("Expected AcsJCannotGetComponentEx");
} catch (AcsJCannotGetComponentEx e) {
System.out.println("This is OK: " + e.toString());
} catch (AcsJNoPermissionEx e) {
fail();
}
}
use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method testClientInfo.
public void testClientInfo() {
try {
//test invalid
try {
manager.getClientInfo(0, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getClientInfo(Integer.MAX_VALUE, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getClientInfo(dummyHandle, null, null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getClientInfo(dummyHandle, new int[0], null);
fail();
} catch (BadParametersException bpe) {
System.out.println("This is OK: " + bpe.getMessage());
}
//test invalid
try {
manager.getClientInfo(dummyHandle, new int[0], "non-null");
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
/*
//test invalid regular expression
try {
manager.getClientInfo(dummyHandle, new int[0], ")");
fail();
}
catch (BadParametersException bpe)
{
System.out.println("This is OK: "+bpe.getMessage());
}
*/
//test valid
ClientInfo info = manager.login(new TestClient(clientName));
int[] handles = { info.getHandle() };
ClientInfo[] infos = manager.getClientInfo(info.getHandle(), handles, null);
assertNotNull(infos);
assertEquals(infos.length, 1);
assertEquals(infos[0], info);
manager.logout(info.getHandle());
//test inaccessible
info = manager.login(new TestClient(clientName));
handles[0] = info.getHandle();
ClientInfo anotherInfo = manager.login(new TestClient(anotherName));
try {
manager.getClientInfo(anotherInfo.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
try {
manager.getClientInfo(anotherInfo.getHandle(), new int[0], clientName);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
manager.logout(anotherInfo.getHandle());
//test valid and invalid client info
info = manager.login(new TestClient(clientName));
handles = new int[2];
handles[0] = info.getHandle();
handles[1] = dummyHandle;
try {
infos = manager.getClientInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
//test invalid and inaccessible client info
info = manager.login(new TestClient(clientName));
anotherInfo = manager.login(new TestClient(anotherName));
handles = new int[2];
handles[0] = anotherInfo.getHandle();
handles[1] = dummyHandle;
try {
infos = manager.getClientInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
manager.logout(anotherInfo.getHandle());
//test valid and inaccessible client info
info = manager.login(new TestClient(clientName));
anotherInfo = manager.login(new TestClient(anotherName));
handles = new int[2];
handles[0] = info.getHandle();
handles[1] = anotherInfo.getHandle();
try {
infos = manager.getClientInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
manager.logout(anotherInfo.getHandle());
//test valid, invalid and inaccessible client info
info = manager.login(new TestClient(clientName));
anotherInfo = manager.login(new TestClient(anotherName));
handles = new int[3];
handles[0] = info.getHandle();
handles[1] = anotherInfo.getHandle();
handles[2] = dummyHandle;
try {
infos = manager.getClientInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
manager.logout(anotherInfo.getHandle());
//test duplicating infos
info = manager.login(new TestClient(clientName));
handles = new int[2];
handles[0] = info.getHandle();
handles[1] = info.getHandle();
try {
infos = manager.getClientInfo(info.getHandle(), handles, null);
fail();
} catch (AcsJNoPermissionEx npe) {
System.out.println("This is OK: " + npe.toString());
}
manager.logout(info.getHandle());
//test with INTROSPECTION_MANAGER rights
info = manager.login(new TestClient(clientName));
ClientInfo adminInfo = manager.login(new TestAdministrator(administratorName));
handles = new int[3];
handles[0] = adminInfo.getHandle();
handles[1] = info.getHandle();
handles[2] = dummyHandle;
infos = manager.getClientInfo(adminInfo.getHandle(), handles, null);
assertNotNull(infos);
assertEquals(infos[0].getHandle(), adminInfo.getHandle());
assertEquals(infos[1].getHandle(), info.getHandle());
//assertEquals(infos[2].getHandle(),0);
assertNull(infos[2]);
manager.logout(info.getHandle());
manager.logout(adminInfo.getHandle());
// test wildcard search
info = manager.login(new TestClient("client1"));
assertNotNull(info);
ClientInfo info2 = manager.login(new TestClient("client2a"));
assertNotNull(info2);
ClientInfo info3 = manager.login(new TestClient("client3aa"));
assertNotNull(info3);
ClientInfo info4 = manager.login(new TestClient("other4"));
assertNotNull(info4);
adminInfo = manager.login(new TestAdministrator("client55"));
assertNotNull(adminInfo);
//infos = manager.getClientInfo(adminInfo.getHandle(), new int[0], "client.*");
infos = manager.getClientInfo(adminInfo.getHandle(), new int[0], "client*");
assertNotNull(infos);
assertEquals(4, infos.length);
assertEquals(info.getHandle(), infos[0].getHandle());
assertEquals(info2.getHandle(), infos[1].getHandle());
assertEquals(info3.getHandle(), infos[2].getHandle());
assertEquals(adminInfo.getHandle(), infos[3].getHandle());
manager.logout(info.getHandle());
manager.logout(info2.getHandle());
manager.logout(info3.getHandle());
manager.logout(info4.getHandle());
manager.logout(adminInfo.getHandle());
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
use of alma.maciErrType.wrappers.AcsJNoPermissionEx in project ACS by ACS-Community.
the class ManagerImplTest method testGetCyclicHierachicalComponent.
/*
This test was disabled, since construct() is not yet implemented as it should be,
now it activation (named) lock is aquired also when construct() method is called!
public void testGetCyclicHierachicalComponentConstructCase()
{
// activation of subcomponents is requested in construct() method
testGetCyclicHierachicalComponent(false);
}
*/
private void testGetCyclicHierachicalComponent(boolean constructCase) {
try {
TestContainer container = new TestContainer("Container");
Map supportedComponents = new HashMap();
// MOUNT2 -> MOUNT2 cycle
TestHierarchicalComponent mount2HierCOB = new TestHierarchicalComponent("CyclicHierarchical", manager, new String[] { "MOUNT2" }, true, constructCase);
supportedComponents.put("MOUNT2", mount2HierCOB);
// MOUNT3 -> MOUNT5 -> PBEND_B_01 -> MOUNT3 cycle
TestHierarchicalComponent mount3HierCOB = new TestHierarchicalComponent("MOUNT3", manager, new String[] { "MOUNT4" }, true, constructCase);
supportedComponents.put("MOUNT3", mount3HierCOB);
TestHierarchicalComponent mount4HierCOB = new TestHierarchicalComponent("MOUNT4", manager, new String[] { "PBEND_B_01" }, true, constructCase);
supportedComponents.put("MOUNT4", mount4HierCOB);
TestHierarchicalComponent pbendHierCOB = new TestHierarchicalComponent("PBEND_B_01", manager, new String[] { "MOUNT3" }, true, constructCase);
supportedComponents.put("PBEND_B_01", pbendHierCOB);
container.setSupportedComponents(supportedComponents);
TestAdministrator client = new TestAdministrator(administratorName);
ClientInfo info = manager.login(client);
// test case when container is unable to activate startup Component - MOUNT1
ClientInfo containerInfo = manager.login(container);
long startTime = System.currentTimeMillis();
// this will cause cyclic depedency...
try {
StatusHolder status;
Component ref;
URI mount2URI = new URI("MOUNT2");
status = new StatusHolder();
ref = manager.getComponent(info.getHandle(), mount2URI, true, status);
fail();
} catch (AcsJCannotGetComponentEx e) {
System.out.println("This is OK: cyclic dependency " + e.toString());
} catch (Exception ex) {
fail();
}
long stopTime = System.currentTimeMillis();
// cyclic dependency should be detected, not deadlock detected
if (stopTime - startTime > 30000)
fail("Cyclic dependency detection is too slow.");
startTime = System.currentTimeMillis();
// this will cause cyclic depedency...
try {
URI mount3URI = new URI("MOUNT3");
StatusHolder status = new StatusHolder();
Component ref = manager.getComponent(info.getHandle(), mount3URI, true, status);
fail();
} catch (AcsJCannotGetComponentEx e) {
System.out.println("This is OK: cyclic dependency " + e.toString());
} catch (Exception ex) {
fail();
}
stopTime = System.currentTimeMillis();
// cyclic dependency should be detected, not deadlock detected
if (stopTime - startTime > 30000)
fail("Cyclic dependency detection is too slow.");
} catch (AcsJNoPermissionEx e) {
fail("No permission");
}
}
Aggregations