use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class PersistentRecoveryOrderDUnitTest method testRevokeAHostBeforeInitialization.
/**
* Tests to make sure that we can revoke a member before initialization, and that member will stay
* revoked
*
* @throws Exception
*/
@Test
public void testRevokeAHostBeforeInitialization() throws Exception {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
LogWriterUtils.getLogWriter().info("Creating region in VM0");
createPersistentRegion(vm0);
LogWriterUtils.getLogWriter().info("Creating region in VM1");
createPersistentRegion(vm1);
putAnEntry(vm0);
vm0.invoke(new SerializableRunnable("Check for waiting regions") {
public void run() {
GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
PersistentMemberManager mm = cache.getPersistentMemberManager();
Map<String, Set<PersistentMemberID>> waitingRegions = mm.getWaitingRegions();
assertEquals(0, waitingRegions.size());
}
});
LogWriterUtils.getLogWriter().info("closing region in vm0");
closeRegion(vm0);
updateTheEntry(vm1);
LogWriterUtils.getLogWriter().info("closing region in vm1");
closeRegion(vm1);
final File dirToRevoke = getDiskDirForVM(vm1);
vm2.invoke(new SerializableRunnable("Revoke the member") {
public void run() {
GemFireCacheImpl cache = (GemFireCacheImpl) getCache();
DistributedSystemConfig config;
AdminDistributedSystem adminDS = null;
try {
config = AdminDistributedSystemFactory.defineDistributedSystem(getSystem(), "");
adminDS = AdminDistributedSystemFactory.getDistributedSystem(config);
adminDS.connect();
adminDS.revokePersistentMember(InetAddress.getLocalHost(), dirToRevoke.getCanonicalPath());
} catch (Exception e) {
Assert.fail("Unexpected exception", e);
} finally {
if (adminDS != null) {
adminDS.disconnect();
}
}
}
});
// This shouldn't wait, because we revoked the member
LogWriterUtils.getLogWriter().info("Creating region in VM0");
createPersistentRegion(vm0);
checkForRecoveryStat(vm0, true);
// Check to make sure we recovered the old
// value of the entry.
SerializableRunnable checkForEntry = new SerializableRunnable("check for the entry") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion(REGION_NAME);
assertEquals("B", region.get("A"));
}
};
vm0.invoke(checkForEntry);
// Now, we should not be able to create a region
// in vm1, because the this member was revoked
LogWriterUtils.getLogWriter().info("Creating region in VM1");
IgnoredException e = IgnoredException.addIgnoredException(RevokedPersistentDataException.class.getSimpleName(), vm1);
try {
createPersistentRegion(vm1);
fail("We should have received a split distributed system exception");
} catch (RuntimeException expected) {
if (!(expected.getCause() instanceof RevokedPersistentDataException)) {
throw expected;
}
// Do nothing
} finally {
e.remove();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class CacheServerSSLConnectionDUnitTest method testSSLClientWithNonSSLServer.
@Test
public void testSSLClientWithNonSSLServer() throws Exception {
final Host host = Host.getHost(0);
VM serverVM = host.getVM(1);
VM clientVM = host.getVM(2);
boolean cacheServerSslenabled = false;
boolean cacheClientSslenabled = true;
boolean cacheClientSslRequireAuth = true;
serverVM.invoke(() -> setUpServerVMTask(cacheServerSslenabled, true));
serverVM.invoke(() -> createServerTask());
Object[] array = (Object[]) serverVM.invoke(() -> getCacheServerEndPointTask());
String hostName = (String) array[0];
int port = (Integer) array[1];
IgnoredException expect = IgnoredException.addIgnoredException("javax.net.ssl.SSLHandshakeException", serverVM);
try {
clientVM.invoke(() -> setUpClientVMTask(hostName, port, cacheClientSslenabled, cacheClientSslRequireAuth, TRUSTED_STORE, TRUSTED_STORE));
clientVM.invoke(() -> doClientRegionTestTask());
serverVM.invoke(() -> doServerRegionTestTask());
fail("Test should fail as ssl client with ssl enabled is trying to connect to server with ssl disabled");
} catch (Exception rmiException) {
// ignore
} finally {
expect.remove();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class PRQueryDUnitTest method testDataLossDuringQueryProcessor.
/**
* Test data loss (bucket 0) while the PRQueryEvaluator is processing the query loop
*
* @throws Exception
*/
@Test
public void testDataLossDuringQueryProcessor() throws Exception {
final String rName = getUniqueName();
Host host = Host.getHost(0);
final VM datastore1 = host.getVM(2);
final VM datastore2 = host.getVM(3);
final int totalBuckets = 11;
final int redCop = 0;
CacheSerializableRunnable createPR = new CacheSerializableRunnable("Create PR") {
@Override
public void run2() throws CacheException {
AttributesFactory attr = new AttributesFactory();
attr.setValueConstraint(String.class);
PartitionAttributes prAttr = new PartitionAttributesFactory().setRedundantCopies(redCop).setTotalNumBuckets(totalBuckets).create();
attr.setPartitionAttributes(prAttr);
getCache().createRegion(rName, attr.create());
}
};
datastore1.invoke(createPR);
datastore2.invoke(createPR);
AttributesFactory attr = new AttributesFactory();
attr.setValueConstraint(String.class);
PartitionAttributes prAttr = new PartitionAttributesFactory().setRedundantCopies(redCop).setTotalNumBuckets(totalBuckets).setLocalMaxMemory(0).create();
attr.setPartitionAttributes(prAttr);
PartitionedRegion pr = (PartitionedRegion) getCache().createRegion(rName, attr.create());
// Create bucket zero, one and two
pr.put(new Integer(0), "zero");
pr.put(new Integer(1), "one");
pr.put(new Integer(2), "two");
class MyTestHook implements PartitionedRegionQueryEvaluator.TestHook {
public boolean done = false;
public void hook(int spot) throws RuntimeException {
if (spot == 4) {
synchronized (this) {
if (done) {
return;
}
this.done = true;
}
datastore1.invoke(disconnectVM());
datastore2.invoke(disconnectVM());
}
}
}
;
final MyTestHook th = new MyTestHook();
// add expected exception strings
final IgnoredException ex = IgnoredException.addIgnoredException("Data loss detected");
try {
Object[] params = new Object[0];
final DefaultQuery query = (DefaultQuery) getCache().getQueryService().newQuery("select distinct * from " + pr.getFullPath());
final SelectResults results = query.getSimpleSelect().getEmptyResultSet(params, getCache(), query);
// TODO assert this is the correct set of bucket Ids,
final HashSet<Integer> buckets = new HashSet<Integer>();
for (int i = 0; i < 3; i++) {
buckets.add(new Integer(i));
}
PartitionedRegionQueryEvaluator qe = new PartitionedRegionQueryEvaluator(pr.getSystem(), pr, query, params, results, buckets);
qe.queryBuckets(th);
assertTrue(th.done);
assertTrue(false);
} catch (QueryException expected) {
assertTrue(th.done);
} finally {
ex.remove();
getCache().close();
}
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class CacheXml66DUnitTest method testResourceManagerThresholds.
/**
* Test the ResourceManager element's critical-heap-percentage and eviction-heap-percentage
* attributes
*/
@Test
public void testResourceManagerThresholds() throws Exception {
CacheCreation cache = new CacheCreation();
final float low = 90.0f;
final float high = 95.0f;
Cache c;
ResourceManagerCreation rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(low);
rmc.setCriticalHeapPercentage(high);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(low, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(high, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
rmc = new ResourceManagerCreation();
// Set them to similar values
rmc.setEvictionHeapPercentage(low);
rmc.setCriticalHeapPercentage(low + 1);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(low, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(low + 1, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(high);
rmc.setCriticalHeapPercentage(low);
cache.setResourceManagerCreation(rmc);
IgnoredException expectedException = IgnoredException.addIgnoredException(LocalizedStrings.MemoryMonitor_EVICTION_PERCENTAGE_LTE_CRITICAL_PERCENTAGE.toLocalizedString());
try {
testXml(cache);
assertTrue(false);
} catch (IllegalArgumentException expected) {
} finally {
expectedException.remove();
closeCache();
}
// Disable eviction
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(0);
rmc.setCriticalHeapPercentage(low);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(0f, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(low, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
// Disable refusing ops in "red zone"
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(low);
rmc.setCriticalHeapPercentage(0);
cache.setResourceManagerCreation(rmc);
testXml(cache);
{
c = getCache();
assertEquals(low, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(0f, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
closeCache();
// Disable both
rmc = new ResourceManagerCreation();
rmc.setEvictionHeapPercentage(0);
rmc.setCriticalHeapPercentage(0);
cache.setResourceManagerCreation(rmc);
testXml(cache);
c = getCache();
assertEquals(0f, c.getResourceManager().getEvictionHeapPercentage(), 0);
assertEquals(0f, c.getResourceManager().getCriticalHeapPercentage(), 0);
}
use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.
the class CacheXml66DUnitTest method testBadKeyConstraintClass.
/**
* Tests parsing an XML file with a non-existent key constraint class.
*/
@Test
public void testBadKeyConstraintClass() throws Exception {
setXmlFile(findFile("badKeyConstraintClass.xml"));
IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
try {
getCache();
fail("Should have thrown a CacheXmlException");
} catch (CacheXmlException ex) {
assertTrue(ex.getCause() instanceof ClassNotFoundException);
} finally {
expectedException.remove();
}
}
Aggregations