use of org.junit.experimental.categories.Category in project geode by apache.
the class QueryMonitorDUnitTest method testQueryExecutionLocally.
/**
* Tests query execution on local vm.
*/
// GEODE-577: eats exceptions
@Category(FlakyTest.class)
@Test
public void testQueryExecutionLocally() throws Exception {
setup(2);
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
final int numberOfEntries = 100;
// Start server
// All
server1.invoke("Create BridgeServer", () -> configServer(20, "testQueryExecutionLocally"));
// the
// queries
// taking
// more
// than
// 20ms
// should
// be
// canceled
// by
// Query
// monitor.
server1.invoke("createRegion", () -> createRegion());
// All
server2.invoke("Create BridgeServer", () -> configServer(20, "testQueryExecutionLocally"));
// the
// queries
// taking
// more
// than
// 20ms
// should
// be
// canceled
// by
// Query
// monitor.
server2.invoke("createRegion", () -> createRegion());
// Initialize server regions.
server1.invoke("Create Bridge Server", () -> populatePortfolioRegions(numberOfEntries));
// Initialize server regions.
server2.invoke("Create Bridge Server", () -> populatePortfolioRegions(numberOfEntries));
// Execute server queries
server1.invoke("execute queries on Server", () -> executeQueriesOnServer());
server2.invoke("execute queries on Server", () -> executeQueriesOnServer());
stopServer(server1);
stopServer(server2);
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class ClientCommandsDUnitTest method testListClient.
// GEODE-908: random ports, BindException, time sensitive, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testListClient() throws Exception {
setupSystemForListClient();
final VM manager = Host.getHost(0).getVM(0);
String commandString = CliStrings.LIST_CLIENTS;
getLogWriter().info("testListClient commandStr=" + commandString);
waitForListClientMbean();
final VM server1 = Host.getHost(0).getVM(1);
final DistributedMember serverMember = getMember(server1);
String[] clientIds = (String[]) manager.invoke("get client Ids", () -> {
final SystemManagementService service = (SystemManagementService) ManagementService.getManagementService(getCache());
final ObjectName cacheServerMBeanName = service.getCacheServerMBeanName(port0, serverMember);
CacheServerMXBean bean = service.getMBeanProxy(cacheServerMBeanName, CacheServerMXBean.class);
return bean.getClientIds();
});
String serverName = (String) server1.invoke("get distributed member Id", () -> getDistributedMemberId());
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testListClient commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testListClient resultAsString=" + resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("section1");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("TableForClientList");
assertNotNull(tableRsultData);
List<String> serverNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_SERVERS);
List<String> clientNames = tableRsultData.retrieveAllValues(CliStrings.LIST_CLIENT_COLUMN_Clients);
getLogWriter().info("testListClients serverNames : " + serverNames);
getLogWriter().info("testListClients clientNames : " + clientNames);
assertEquals(2, serverNames.size());
assertEquals(2, clientNames.size());
assertTrue(clientNames.contains(clientIds[0]));
assertTrue(clientNames.contains(clientIds[1]));
serverName = serverName.replace(":", "-");
getLogWriter().info("testListClients serverName : " + serverName);
for (String str : serverNames) {
assertTrue(str.contains(serverName));
}
closeNonDurableClient(Host.getHost(0).getVM(2));
closeCacheServer(Host.getHost(0).getVM(1));
closeCacheServer(Host.getHost(0).getVM(3));
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class ClientAuthzObjectModDUnitTest method testAllOpsObjectModWithFailover.
// GEODE-2071: failed with ForcedDisconnectException
@Category(FlakyTest.class)
@Test
public void testAllOpsObjectModWithFailover() throws Exception {
OperationWithAction[] allOps = allOps();
TestPostCredentialGenerator tgen = new TestPostCredentialGenerator();
CredentialGenerator credentialGenerator = new DummyCredentialGenerator();
credentialGenerator.init();
Properties extraProps = credentialGenerator.getSystemProperties();
Properties javaProps = credentialGenerator.getJavaProperties();
String authInit = credentialGenerator.getAuthInit();
String authenticator = credentialGenerator.getAuthenticator();
System.out.println("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
System.out.println("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
System.out.println("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
System.out.println("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
// Start servers with all required properties
Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
// Get ports for the servers
int[] portsList = AvailablePortHelper.getRandomAvailableTCPPorts(2);
// portsList[0];
int port1 = 0;
int port2 = portsList[1];
// Perform all the ops on the clients
List<OperationWithAction> opBlock = new ArrayList();
Random rnd = new Random();
for (int opNum = 0; opNum < allOps.length; ++opNum) {
// Start client with valid credentials as specified in OperationWithAction
OperationWithAction currentOp = allOps[opNum];
if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
port1 = server1.invoke("createCacheServer", () -> createCacheServer(getLocatorPort(), 0, serverProps, javaProps));
server2.invoke("closeCache", () -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
port2 = server2.invoke("createCacheServer", () -> createCacheServer(getLocatorPort(), 0, serverProps, javaProps));
server1.invoke("closeCache", () -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
}
opBlock.clear();
}
} else {
currentOp.setOpNum(opNum);
opBlock.add(currentOp);
}
}
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class ClientPostAuthorizationDUnitTest method testAllPostOps.
// GEODE-693: getRandomAvailablePort
@Category(FlakyTest.class)
@Test
public void testAllPostOps() throws Exception {
OperationWithAction[] allOps = allOpsForTestAllPostOps();
for (Iterator<AuthzCredentialGenerator> iter = getDummyGeneratorCombos().iterator(); iter.hasNext(); ) {
AuthzCredentialGenerator gen = iter.next();
CredentialGenerator cGen = gen.getCredentialGenerator();
Properties extraAuthProps = cGen.getSystemProperties();
Properties javaProps = cGen.getJavaProperties();
Properties extraAuthzProps = gen.getSystemProperties();
String authenticator = cGen.getAuthenticator();
String authInit = cGen.getAuthInit();
String accessor = gen.getAuthorizationCallback();
TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
getLogWriter().info("testAllPostOps: Using authinit: " + authInit);
getLogWriter().info("testAllPostOps: Using authenticator: " + authenticator);
getLogWriter().info("testAllPostOps: Using accessor: " + accessor);
// Start servers with all required properties
Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
// Get ports for the servers
int[] randomAvailableTCPPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
int port1 = randomAvailableTCPPorts[0];
int port2 = randomAvailableTCPPorts[1];
// Close down any running servers
server1.invoke(() -> closeCache());
server2.invoke(() -> closeCache());
// Perform all the ops on the clients
List opBlock = new ArrayList();
Random rnd = new Random();
for (int opNum = 0; opNum < allOps.length; ++opNum) {
// Start client with valid credentials as specified in OperationWithAction
OperationWithAction currentOp = allOps[opNum];
if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps));
server2.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps));
server1.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
}
opBlock.clear();
}
} else {
currentOp.setOpNum(opNum);
opBlock.add(currentOp);
}
}
}
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class ClientCommandsDUnitTest method testDescribeClientForNonSubscribedClient.
// GEODE-910: random ports, HeadlessGfsh
@Category(FlakyTest.class)
@Test
public void testDescribeClientForNonSubscribedClient() throws Exception {
setUpNonSubscribedClient();
getLogWriter().info("testDescribeClientForNonSubscribedClient clientId=" + clientId);
assertNotNull(clientId);
String commandString = CliStrings.DESCRIBE_CLIENT + " --" + CliStrings.DESCRIBE_CLIENT__ID + "=\"" + clientId + "\"";
getLogWriter().info("testDescribeClientForNonSubscribedClient commandStr=" + commandString);
CommandResult commandResult = executeCommand(commandString);
getLogWriter().info("testDescribeClientForNonSubscribedClient commandResult=" + commandResult);
String resultAsString = commandResultToString(commandResult);
getLogWriter().info("testDescribeClientForNonSubscribedClient resultAsString=" + resultAsString);
assertTrue(Status.OK.equals(commandResult.getStatus()));
CompositeResultData resultData = (CompositeResultData) commandResult.getResultData();
SectionResultData section = resultData.retrieveSection("InfoSection");
assertNotNull(section);
TabularResultData tableRsultData = section.retrieveTable("Pool Stats For Pool Name = DEFAULT");
assertNotNull(tableRsultData);
List<String> minConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MIN_CONN);
List<String> maxConn = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_MAX_CONN);
List<String> redudancy = tableRsultData.retrieveAllValues(CliStrings.DESCRIBE_CLIENT_REDUDANCY);
assertTrue(minConn.contains("1"));
assertTrue(maxConn.contains("-1"));
assertTrue(redudancy.contains("1"));
String puts = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PUTS);
assertTrue(puts.equals("2"));
String calls = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_LISTNER_CALLS);
assertTrue(calls.equals("1"));
String primServer = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PRIMARY_SERVERS);
assertTrue(primServer.equals("N.A."));
String durable = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_DURABLE);
assertTrue(durable.equals("No"));
String threads = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_THREADS);
assertTrue(Integer.parseInt(threads) > 0);
String cpu = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_CPU);
assertTrue(Integer.parseInt(cpu) > 0);
String upTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_UP_TIME);
assertTrue(Integer.parseInt(upTime) == 0);
String prcTime = section.retrieveString(CliStrings.DESCRIBE_CLIENT_COLUMN_PROCESS_CPU_TIME);
assertTrue(Long.parseLong(prcTime) > 0);
closeNonDurableClient(Host.getHost(0).getVM(2));
closeCacheServer(Host.getHost(0).getVM(1));
closeCacheServer(Host.getHost(0).getVM(3));
}
Aggregations