use of org.junit.experimental.categories.Category in project geode by apache.
the class DurableClientSimpleDUnitTest method testMultipleBridgeClientsInSingleDurableVM.
/**
* Test that a durable client VM with multiple BridgeClients correctly registers on the server.
*/
// GEODE-1618
@Category(FlakyTest.class)
@Test
public void testMultipleBridgeClientsInSingleDurableVM() {
// Start a server
int serverPort = ((Integer) this.server1VM.invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new Boolean(true)))).intValue();
// Start a durable client with 2 regions (and 2 BridgeClients) that is not
// kept alive on the server when it stops normally
final String durableClientId = getName() + "_client";
final String regionName1 = regionName + "1";
final String regionName2 = regionName + "2";
this.durableClientVM.invoke(() -> CacheServerTestUtil.createCacheClients(getClientPool(getServerHostName(durableClientVM.getHost()), serverPort, true), regionName1, regionName2, getClientDistributedSystemProperties(durableClientId)));
// Send clientReady message
this.durableClientVM.invoke(new CacheSerializableRunnable("Send clientReady") {
@Override
public void run2() throws CacheException {
assertEquals(2, PoolManager.getAll().size());
CacheServerTestUtil.getCache().readyForEvents();
}
});
// Verify durable clients on server
this.server1VM.invoke(new CacheSerializableRunnable("Verify durable client") {
@Override
public void run2() throws CacheException {
// Get the CacheClientNotifier
CacheClientNotifier notifier = getBridgeServer().getAcceptor().getCacheClientNotifier();
// Iterate the CacheClientProxies
checkNumberOfClientProxies(2);
String firstProxyRegionName = null;
for (Iterator i = notifier.getClientProxies().iterator(); i.hasNext(); ) {
CacheClientProxy proxy = (CacheClientProxy) i.next();
assertTrue(proxy.isDurable());
assertEquals(durableClientId, proxy.getDurableId());
assertEquals(DistributionConfig.DEFAULT_DURABLE_CLIENT_TIMEOUT, proxy.getDurableTimeout());
// Verify the two HA region names aren't the same
if (firstProxyRegionName == null) {
firstProxyRegionName = proxy.getHARegionName();
} else {
assertTrue(!firstProxyRegionName.equals(proxy.getHARegionName()));
}
}
}
});
// Stop the durable client
this.durableClientVM.invoke(() -> CacheServerTestUtil.closeCache());
// Verify the durable client is no longer on the server
this.server1VM.invoke(new CacheSerializableRunnable("Verify durable client") {
@Override
public void run2() throws CacheException {
// Find the proxy
checkNumberOfClientProxies(0);
}
});
// Stop the server
this.server1VM.invoke(() -> CacheServerTestUtil.closeCache());
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class WanAutoDiscoveryDUnitTest method test_NY_Recognises_TK_AND_HK_Simultaneously.
// GEODE-1920
@Category(FlakyTest.class)
@Test
public void test_NY_Recognises_TK_AND_HK_Simultaneously() {
Map<Integer, Set<InetSocketAddress>> dsVsPort = new HashMap<>();
Set<InetSocketAddress> locatorPortsln = new HashSet<>();
dsVsPort.put(1, locatorPortsln);
Integer lnLocPort1 = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
locatorPortsln.add(new InetSocketAddress("localhost", lnLocPort1));
Set<InetSocketAddress> locatorPortsny = new HashSet<>();
dsVsPort.put(2, locatorPortsny);
Integer nyLocPort1 = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnLocPort1));
locatorPortsny.add(new InetSocketAddress("localhost", nyLocPort1));
int AsyncInvocationArrSize = 4;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
Set<InetSocketAddress> locatorPortstk = new HashSet<>();
dsVsPort.put(3, locatorPortstk);
async[0] = vm2.invokeAsync(() -> WANTestBase.createFirstRemoteLocator(3, lnLocPort1));
Set<InetSocketAddress> locatorPortshk = new HashSet<>();
dsVsPort.put(4, locatorPortshk);
async[1] = vm3.invokeAsync(() -> WANTestBase.createFirstRemoteLocator(4, nyLocPort1));
ArrayList<Integer> locatorPortsln2 = new ArrayList<Integer>();
async[2] = vm4.invokeAsync(() -> WANTestBase.createSecondLocator(1, lnLocPort1));
ArrayList<Integer> locatorPortsny2 = new ArrayList<Integer>();
async[3] = vm5.invokeAsync(() -> WANTestBase.createSecondLocator(2, nyLocPort1));
try {
async[0].join();
async[1].join();
async[2].join();
async[3].join();
} catch (InterruptedException e) {
e.printStackTrace();
fail();
}
locatorPortstk.add(new InetSocketAddress("localhost", (Integer) async[0].getReturnValue()));
locatorPortshk.add(new InetSocketAddress("localhost", (Integer) async[1].getReturnValue()));
locatorPortsln.add(new InetSocketAddress("localhost", (Integer) async[2].getReturnValue()));
locatorPortsny.add(new InetSocketAddress("localhost", (Integer) async[3].getReturnValue()));
vm0.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
vm1.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
vm2.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
vm3.invoke(() -> WANTestBase.checkAllSiteMetaData(dsVsPort));
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class ClusterConfigurationDUnitTest method testDestroyExtensions.
/**
* Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator},
* {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and
* destroyed on region and cache.
*
* @since GemFire 8.1
*/
// GEODE-1333
@Category(FlakyTest.class)
@Test
public void testDestroyExtensions() throws Exception {
Object[] result = setup();
final int locatorPort = (Integer) result[0];
createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null);
createMockRegionExtension(REPLICATE_REGION, "value1");
destroyMockRegionExtension(REPLICATE_REGION);
createMockCacheExtension("value1");
destroyMockCacheExtension();
// Start a new member which receives the shared configuration
// Verify the config creation on this member
final String newMemberWorkingDir = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember;
VM newMember = getHost(0).getVM(2);
newMember.invoke(() -> {
Properties localProps = new Properties();
File workingDir = new File(newMemberWorkingDir);
workingDir.mkdirs();
localProps.setProperty(MCAST_PORT, "0");
localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember);
localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath());
getSystem(localProps);
InternalCache cache = getCache();
assertNotNull(cache);
Region<?, ?> region1 = cache.getRegion(REPLICATE_REGION);
assertNotNull(region1);
// MockRegionExtension verification
@SuppressWarnings("unchecked") final Extensible<Region<?, ?>> extensibleRegion = (Extensible<Region<?, ?>>) region1;
// Should not be any region extensions
assertTrue(!extensibleRegion.getExtensionPoint().getExtensions().iterator().hasNext());
// MockCacheExtension verification
@SuppressWarnings("unchecked") final Extensible<Cache> extensibleCache = (Extensible<Cache>) cache;
// Should not be any cache extensions
assertTrue(!extensibleCache.getExtensionPoint().getExtensions().iterator().hasNext());
return getAllNormalMembers(cache);
});
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class ClusterConfigurationDUnitTest method testCreateExtensions.
/**
* Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator},
* {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and
* altered on region and cache.
*
* @since GemFire 8.1
*/
// GEODE-1334
@Category(FlakyTest.class)
@Test
public void testCreateExtensions() throws Exception {
Object[] result = setup();
final int locatorPort = (Integer) result[0];
createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null);
createMockRegionExtension(REPLICATE_REGION, "value1");
alterMockRegionExtension(REPLICATE_REGION, "value2");
createMockCacheExtension("value1");
alterMockCacheExtension("value2");
// Start a new member which receives the shared configuration
// Verify the config creation on this member
final String newMemberWorkDir = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember;
VM newMember = getHost(0).getVM(2);
newMember.invoke(() -> {
Properties localProps = new Properties();
File workingDir = new File(newMemberWorkDir);
workingDir.mkdirs();
localProps.setProperty(MCAST_PORT, "0");
localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember);
localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath());
getSystem(localProps);
InternalCache cache = getCache();
assertNotNull(cache);
Region<?, ?> region1 = cache.getRegion(REPLICATE_REGION);
assertNotNull(region1);
// MockRegionExtension verification
@SuppressWarnings("unchecked") final MockRegionExtension // should only be one region extension
mockRegionExtension = (MockRegionExtension) ((Extensible<Region<?, ?>>) region1).getExtensionPoint().getExtensions().iterator().next();
assertNotNull(mockRegionExtension);
assertEquals(1, mockRegionExtension.beforeCreateCounter.get());
assertEquals(1, mockRegionExtension.onCreateCounter.get());
assertEquals("value2", mockRegionExtension.getValue());
// MockCacheExtension verification
@SuppressWarnings("unchecked") final MockCacheExtension // should only be one cache extension
mockCacheExtension = (MockCacheExtension) ((Extensible<Cache>) cache).getExtensionPoint().getExtensions().iterator().next();
assertNotNull(mockCacheExtension);
assertEquals(1, mockCacheExtension.beforeCreateCounter.get());
assertEquals(1, mockCacheExtension.onCreateCounter.get());
assertEquals("value2", mockCacheExtension.getValue());
return getAllNormalMembers(cache);
});
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class GemFireStatSamplerIntegrationTest method testArchiveRemoval.
/**
* Verifies that archive removal works correctly when archive-disk-space-limit is specified.
*/
// GEODE-2286: need to rewrite with Awaitility and longer timeouts
@Category(FlakyTest.class)
@Test
public void testArchiveRemoval() throws Exception {
// + File.separator + this.testName;
final String dirName = this.testDir.getAbsolutePath();
new File(dirName).mkdirs();
final String archiveFileName = dirName + File.separator + this.testName + ".gfs";
final File archiveFile = new File(archiveFileName);
final File archiveFile1 = new File(dirName + File.separator + this.testName + "-01-01.gfs");
final File archiveFile2 = new File(dirName + File.separator + this.testName + "-01-02.gfs");
final File archiveFile3 = new File(dirName + File.separator + this.testName + "-01-03.gfs");
final File archiveFile4 = new File(dirName + File.separator + this.testName + "-01-04.gfs");
final int sampleRate = 1000;
// set the system property to use KB instead of MB for file size
System.setProperty(HostStatSampler.TEST_FILE_SIZE_LIMIT_IN_KB_PROPERTY, "true");
Properties props = createGemFireProperties();
props.setProperty(STATISTIC_ARCHIVE_FILE, archiveFileName);
props.setProperty(ARCHIVE_FILE_SIZE_LIMIT, "1");
props.setProperty(ARCHIVE_DISK_SPACE_LIMIT, "12");
props.setProperty(STATISTIC_SAMPLE_RATE, String.valueOf(sampleRate));
connect(props);
assertTrue(getGemFireStatSampler().waitForInitialization(5000));
boolean exists1 = false;
boolean exists2 = false;
boolean exists3 = false;
boolean exists4 = false;
boolean exists = false;
boolean done = false;
try {
for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 10 * sampleRate; ) {
exists1 = exists1 || archiveFile1.exists();
exists2 = exists2 || archiveFile2.exists();
exists3 = exists3 || archiveFile3.exists();
exists4 = exists4 || archiveFile4.exists();
exists = exists || archiveFile.exists();
done = exists1 && exists2 && exists3 && exists4 && exists;
if (!done) {
Thread.sleep(10);
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
assertTrue("Waiting for archive files to exist:" + " exists1=" + exists1 + " exists2=" + exists2 + " exists3=" + exists3 + " exists4=" + exists4 + " exists=" + exists, done);
waitForFileToDelete(archiveFile1, 10 * sampleRate, 10);
}
Aggregations