use of org.junit.experimental.categories.Category in project geode by apache.
the class LocatorLauncherRemoteIntegrationTest method testStartUsingForceOverwritesExistingPidFile.
// GEODE-764: BindException
@Category(FlakyTest.class)
@Test
public void testStartUsingForceOverwritesExistingPidFile() throws Throwable {
// create existing pid file
this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
final int otherPid = getPid();
assertTrue("Pid " + otherPid + " should be alive", ProcessUtils.isProcessAlive(otherPid));
writePid(this.pidFile, otherPid);
// build and start the locator
final List<String> jvmArguments = getJvmArguments();
final List<String> command = new ArrayList<String>();
command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
for (String jvmArgument : jvmArguments) {
command.add(jvmArgument);
}
command.add("-cp");
command.add(System.getProperty("java.class.path"));
command.add(LocatorLauncher.class.getName());
command.add(LocatorLauncher.Command.START.getName());
command.add(getUniqueName());
command.add("--port=" + this.locatorPort);
command.add("--redirect-output");
command.add("--force");
this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
// wait for locator to start
int pid = 0;
this.launcher = new LocatorLauncher.Builder().setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()).build();
try {
waitForLocatorToStart(this.launcher);
// validate the pid file and its contents
assertTrue(this.pidFile.exists());
pid = readPid(this.pidFile);
assertTrue(pid > 0);
assertTrue(ProcessUtils.isProcessAlive(pid));
assertTrue(pid != otherPid);
// validate log file was created
final String logFileName = getUniqueName() + ".log";
assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
} catch (Throwable e) {
this.errorCollector.addError(e);
}
// stop the locator
try {
assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
waitForPidToStop(pid);
} catch (Throwable e) {
this.errorCollector.addError(e);
}
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class LocatorLauncherRemoteIntegrationTest method testStartDeletesStaleControlFiles.
// GEODE-530: BindException, random ports
@Category(FlakyTest.class)
@Test
public void testStartDeletesStaleControlFiles() throws Throwable {
// create existing control files
this.stopRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStopRequestFileName());
this.stopRequestFile.createNewFile();
assertTrue(this.stopRequestFile.exists());
this.statusRequestFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusRequestFileName());
this.statusRequestFile.createNewFile();
assertTrue(this.statusRequestFile.exists());
this.statusFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getStatusFileName());
this.statusFile.createNewFile();
assertTrue(this.statusFile.exists());
// build and start the locator
final List<String> jvmArguments = getJvmArguments();
final List<String> command = new ArrayList<String>();
command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
for (String jvmArgument : jvmArguments) {
command.add(jvmArgument);
}
command.add("-cp");
command.add(System.getProperty("java.class.path"));
command.add(LocatorLauncher.class.getName());
command.add(LocatorLauncher.Command.START.getName());
command.add(getUniqueName());
command.add("--port=" + this.locatorPort);
command.add("--redirect-output");
this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
// wait for locator to start
int pid = 0;
this.launcher = new LocatorLauncher.Builder().setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()).build();
try {
waitForLocatorToStart(this.launcher);
// validate the pid file and its contents
this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
assertTrue(this.pidFile.exists());
pid = readPid(this.pidFile);
assertTrue(pid > 0);
assertTrue(ProcessUtils.isProcessAlive(pid));
// validate stale control files were deleted
waitForFileToDelete(this.stopRequestFile);
waitForFileToDelete(this.statusRequestFile);
waitForFileToDelete(this.statusFile);
// validate log file was created
final String logFileName = getUniqueName() + ".log";
assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
} catch (Throwable e) {
this.errorCollector.addError(e);
}
// stop the locator
try {
assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
waitForPidToStop(pid);
} catch (Throwable e) {
this.errorCollector.addError(e);
}
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class LocatorLauncherRemoteIntegrationTest method testStartOverwritesStalePidFile.
// GEODE-1229: BindException
@Category(FlakyTest.class)
@Test
public void testStartOverwritesStalePidFile() throws Throwable {
// create existing pid file
this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
writePid(this.pidFile, Integer.MAX_VALUE);
// build and start the locator
final List<String> jvmArguments = getJvmArguments();
final List<String> command = new ArrayList<String>();
command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
for (String jvmArgument : jvmArguments) {
command.add(jvmArgument);
}
command.add("-cp");
command.add(System.getProperty("java.class.path"));
command.add(LocatorLauncher.class.getName());
command.add(LocatorLauncher.Command.START.getName());
command.add(getUniqueName());
command.add("--port=" + this.locatorPort);
command.add("--redirect-output");
this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).build().start();
this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).build().start();
int pid = 0;
this.launcher = new LocatorLauncher.Builder().setWorkingDirectory(this.temporaryFolder.getRoot().getCanonicalPath()).build();
try {
waitForLocatorToStart(this.launcher);
// validate the pid file and its contents
assertTrue(this.pidFile.exists());
pid = readPid(this.pidFile);
assertTrue(pid > 0);
assertTrue(ProcessUtils.isProcessAlive(pid));
assertFalse(pid == Integer.MAX_VALUE);
final String logFileName = getUniqueName() + ".log";
assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
} catch (Throwable e) {
this.errorCollector.addError(e);
}
// stop the locator
try {
assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
waitForPidToStop(pid);
} catch (Throwable e) {
this.errorCollector.addError(e);
}
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class GIIDeltaDUnitTest method testClearAfterChunkEntries.
/**
* P and R are peers, each holds a DR. Each does a few operations to make RVV=P6,R6, RVVGC=P0,R0
* for both members. R off line, then run P7. Restart R. It will trigger deltaGII to chunk entry
* P7(key1). After that, do clear(). Make sure R should not contain key1 after GII.
*/
// GEODE-1068: time sensitive, SLOW_DISTRIBUTION_MS, waitForCriterion,
@Category(FlakyTest.class)
// possible thread unsafe test hooks, async actions, depends on stats
@Test
public void testClearAfterChunkEntries() throws Throwable {
prepareForEachTest();
final DiskStoreID memberP = getMemberID(P);
final DiskStoreID memberR = getMemberID(R);
final long[] exceptionlist = { 4, 5 };
assertEquals(0, DistributedCacheOperation.SLOW_DISTRIBUTION_MS);
prepareCommonTestData(6);
// let r4,r5,r6 to succeed
doOnePut(R, 4, "key4");
doOneDestroy(R, 5, "key5");
doOnePut(R, 6, "key1");
// P's rvv=p6, gc=0
waitForToVerifyRVV(P, memberP, 6, null, 0);
// P's rvv=r6, gc=0
waitForToVerifyRVV(P, memberR, 6, null, 0);
// R's rvv=P6, gc=0
waitForToVerifyRVV(R, memberP, 6, null, 0);
// R's rvv=r6, gc=0
waitForToVerifyRVV(R, memberR, 6, null, 0);
// set tesk hook
R.invoke(new SerializableRunnable() {
public void run() {
Mycallback myAfterReceivedImageReply = new Mycallback(GIITestHookType.AfterReceivedImageReply, REGION_NAME);
InitialImageOperation.setGIITestHook(myAfterReceivedImageReply);
}
});
// shutdown R
byte[] R_rvv_bytes = getRVVByteArray(R, REGION_NAME);
closeCache(R);
// key1 will be the delta
doOnePut(P, 7, "key1");
// retart R
checkIfFullGII(P, REGION_NAME, R_rvv_bytes, false);
AsyncInvocation async3 = createDistributedRegionAsync(R);
// when chunk arrived, do clear()
waitForCallbackStarted(R, GIITestHookType.AfterReceivedImageReply);
doOneClear(P, 8);
R.invoke(() -> InitialImageOperation.resetGIITestHook(GIITestHookType.AfterReceivedImageReply, true));
async3.getResult(MAX_WAIT);
// clear() increased P's version with 1 to P8
// after clear, P and R's RVVGC == RVV
// P's rvv=r8, gc=8
waitForToVerifyRVV(P, memberP, 8, null, 8);
// P's rvv=r6, gc=6
waitForToVerifyRVV(P, memberR, 6, null, 6);
// retart R again to do fullGII
closeCache(R);
createDistributedRegion(R);
RegionVersionVector p_rvv = getRVV(P);
RegionVersionVector r_rvv = getRVV(R);
// after gii, rvv should be the same
assertSameRVV(p_rvv, r_rvv);
// R's rvv=r8, gc=8
waitForToVerifyRVV(R, memberP, 8, null, 8);
// R's rvv=r6, gc=6
waitForToVerifyRVV(R, memberR, 6, null, 6);
waitToVerifyKey(P, "key1", null);
waitToVerifyKey(R, "key1", null);
verifyDeltaSizeFromStats(R, 0, 1);
}
use of org.junit.experimental.categories.Category in project geode by apache.
the class PartitionedRegionCreationDUnitTest method testPartitionRegionInitialization.
/**
* This test creates partition region with scope = DISTRIBUTED_ACK and tests whether all the
* attributes of partiotion region are properlt initialized
*
* @throws Exception
*/
// GEODE-1104: time sensitive, async actions
@Category(FlakyTest.class)
@Test
public void testPartitionRegionInitialization() throws Throwable {
final String name = getUniqueName();
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
VM vm3 = host.getVM(3);
LogWriterUtils.getLogWriter().info("*****INITIALIZATION TEST STARTED*****");
int AsyncInvocationArrSize = 8;
AsyncInvocation[] async = new AsyncInvocation[AsyncInvocationArrSize];
async[0] = vm0.invokeAsync(getCacheSerializableRunnableForPRCreate(name, MAX_REGIONS, 0, "NONE"));
async[1] = vm1.invokeAsync(getCacheSerializableRunnableForPRCreate(name, MAX_REGIONS, 0, "NONE"));
async[2] = vm2.invokeAsync(getCacheSerializableRunnableForPRCreate(name, MAX_REGIONS, 0, "NONE"));
async[3] = vm3.invokeAsync(getCacheSerializableRunnableForPRCreate(name, MAX_REGIONS, 0, "NONE"));
/** main thread is waiting for the other threads to complete */
for (int count = 0; count < 4; count++) {
ThreadUtils.join(async[count], 30 * 1000);
}
for (int count = 0; count < 4; count++) {
if (async[count].exceptionOccurred()) {
Assert.fail("exception during " + count, async[count].getException());
}
}
async[4] = vm0.invokeAsync(getCacheSerializableRunnableForPRInitialize());
async[5] = vm1.invokeAsync(getCacheSerializableRunnableForPRInitialize());
async[6] = vm2.invokeAsync(getCacheSerializableRunnableForPRInitialize());
async[7] = vm3.invokeAsync(getCacheSerializableRunnableForPRInitialize());
/** main thread is waiting for the other threads to complete */
for (int count = 4; count < AsyncInvocationArrSize; count++) {
ThreadUtils.join(async[count], 30 * 1000);
}
for (int count = 4; count < AsyncInvocationArrSize; count++) {
if (async[count].exceptionOccurred()) {
Assert.fail("exception during " + count, async[count].getException());
}
}
LogWriterUtils.getLogWriter().info("*****INITIALIZATION TEST ENDED*****");
}
Aggregations