use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherTest method testSetAndGetMemberName.
@Test
public void testSetAndGetMemberName() {
Builder builder = new Builder();
assertNull(builder.getMemberName());
assertSame(builder, builder.setMemberName("locatorOne"));
assertEquals("locatorOne", builder.getMemberName());
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherTest method testSetAndGetHostnameForClients.
@Test
public void testSetAndGetHostnameForClients() {
final Builder builder = new Builder();
assertNull(builder.getHostnameForClients());
assertSame(builder, builder.setHostnameForClients("Pegasus"));
assertEquals("Pegasus", builder.getHostnameForClients());
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherTest method testSetAndGetPort.
@SuppressWarnings("deprecation")
@Test
public void testSetAndGetPort() {
Builder builder = new Builder();
assertEquals(LocatorLauncher.DEFAULT_LOCATOR_PORT, builder.getPort());
assertSame(builder, builder.setPort(65535));
assertEquals(65535, builder.getPort().intValue());
assertSame(builder, builder.setPort(1024));
assertEquals(1024, builder.getPort().intValue());
assertSame(builder, builder.setPort(80));
assertEquals(80, builder.getPort().intValue());
assertSame(builder, builder.setPort(1));
assertEquals(1, builder.getPort().intValue());
assertSame(builder, builder.setPort(0));
assertEquals(0, builder.getPort().intValue());
assertSame(builder, builder.setPort(null));
assertEquals(LocatorLauncher.DEFAULT_LOCATOR_PORT, builder.getPort());
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherLocalIntegrationTest method testStatusUsingWorkingDirectory.
@Test
public void testStatusUsingWorkingDirectory() throws Throwable {
final Builder builder = new Builder().setMemberName(getUniqueName()).setPort(this.locatorPort).setRedirectOutput(true).setWorkingDirectory(this.workingDirectory).set(CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory).set(LOG_LEVEL, "config");
assertFalse(builder.getForce());
this.launcher = builder.build();
assertFalse(this.launcher.isForcing());
LocatorLauncher dirLauncher = null;
try {
this.launcher.start();
waitForLocatorToStart(this.launcher);
this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
assertTrue("Pid file " + this.pidFile.getCanonicalPath().toString() + " should exist", this.pidFile.exists());
final int pid = readPid(this.pidFile);
assertTrue(pid > 0);
assertEquals(ProcessUtils.identifyPid(), pid);
dirLauncher = new Builder().setWorkingDirectory(this.workingDirectory).build();
assertNotNull(dirLauncher);
assertFalse(dirLauncher.isRunning());
final LocatorState actualStatus = dirLauncher.status();
assertNotNull(actualStatus);
assertEquals(Status.ONLINE, actualStatus.getStatus());
assertEquals(pid, actualStatus.getPid().intValue());
assertTrue(actualStatus.getUptime() > 0);
// getWorkingDirectory returns user.dir instead of rootFolder because test is starting Locator
// in this process (to move logFile and pidFile into temp dir)
assertEquals(ManagementFactory.getRuntimeMXBean().getClassPath(), actualStatus.getClasspath());
assertEquals(GemFireVersion.getGemFireVersion(), actualStatus.getGemFireVersion());
assertEquals(System.getProperty("java.version"), actualStatus.getJavaVersion());
assertEquals(this.workingDirectory + File.separator + getUniqueName() + ".log", actualStatus.getLogFile());
assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), actualStatus.getHost());
assertEquals(getUniqueName(), actualStatus.getMemberName());
} catch (Throwable e) {
this.errorCollector.addError(e);
}
if (dirLauncher == null) {
try {
assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
waitForFileToDelete(this.pidFile);
} catch (Throwable e) {
this.errorCollector.addError(e);
}
} else {
try {
assertEquals(Status.STOPPED, dirLauncher.stop().getStatus());
waitForFileToDelete(this.pidFile);
} catch (Throwable e) {
this.errorCollector.addError(e);
}
}
}
use of org.apache.geode.distributed.LocatorLauncher.Builder in project geode by apache.
the class LocatorLauncherLocalIntegrationTest method testStartCreatesPidFile.
@Test
public void testStartCreatesPidFile() throws Throwable {
this.launcher = new Builder().setMemberName(getUniqueName()).setPort(this.locatorPort).setRedirectOutput(true).setWorkingDirectory(this.workingDirectory).set(CLUSTER_CONFIGURATION_DIR, this.clusterConfigDirectory).set(LOG_LEVEL, "config").build();
try {
this.launcher.start();
waitForLocatorToStart(this.launcher);
assertEquals(Status.ONLINE, this.launcher.status().getStatus());
// validate the pid file and its contents
this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
assertTrue(this.pidFile.exists());
final int pid = readPid(this.pidFile);
assertTrue(pid > 0);
assertTrue(ProcessUtils.isProcessAlive(pid));
assertEquals(getPid(), pid);
assertEquals(Status.ONLINE, this.launcher.status().getStatus());
} catch (Throwable e) {
this.errorCollector.addError(e);
}
try {
assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
waitForFileToDelete(this.pidFile);
} catch (Throwable e) {
this.errorCollector.addError(e);
}
}
Aggregations