Search in sources :

Example 31 with Builder

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());
}
Also used : Builder(org.apache.geode.distributed.LocatorLauncher.Builder) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 32 with Builder

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());
}
Also used : Builder(org.apache.geode.distributed.LocatorLauncher.Builder) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 33 with Builder

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());
}
Also used : Builder(org.apache.geode.distributed.LocatorLauncher.Builder) UnitTest(org.apache.geode.test.junit.categories.UnitTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 34 with Builder

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);
        }
    }
}
Also used : Builder(org.apache.geode.distributed.LocatorLauncher.Builder) LocatorState(org.apache.geode.distributed.LocatorLauncher.LocatorState) File(java.io.File) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 35 with Builder

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);
    }
}
Also used : Builder(org.apache.geode.distributed.LocatorLauncher.Builder) File(java.io.File) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Builder (org.apache.geode.distributed.LocatorLauncher.Builder)42 Test (org.junit.Test)40 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)26 File (java.io.File)21 LocatorState (org.apache.geode.distributed.LocatorLauncher.LocatorState)13 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)13 UnitTest (org.apache.geode.test.junit.categories.UnitTest)10 ArrayList (java.util.ArrayList)5 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 LocatorLauncher (org.apache.geode.distributed.LocatorLauncher)3 FileNotFoundException (java.io.FileNotFoundException)2 BindException (java.net.BindException)2 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Properties (java.util.Properties)2 Set (java.util.Set)2 DistributionManager (org.apache.geode.distributed.internal.DistributionManager)2 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)2