[ 
https://issues.apache.org/jira/browse/GEODE-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16122047#comment-16122047
 ] 

ASF GitHub Bot commented on GEODE-3413:
---------------------------------------

Github user kirklund commented on a diff in the pull request:

    https://github.com/apache/geode/pull/699#discussion_r132532641
  
    --- Diff: 
geode-core/src/test/java/org/apache/geode/internal/process/FileProcessControllerIntegrationTest.java
 ---
    @@ -0,0 +1,243 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
    + * agreements. See the NOTICE file distributed with this work for 
additional information regarding
    + * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance with the 
License. You may obtain a
    + * copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software 
distributed under the License
    + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
ANY KIND, either express
    + * or implied. See the License for the specific language governing 
permissions and limitations under
    + * the License.
    + */
    +package org.apache.geode.internal.process;
    +
    +import static com.googlecode.catchexception.CatchException.caughtException;
    +import static com.googlecode.catchexception.CatchException.verifyException;
    +import static java.util.concurrent.TimeUnit.MILLISECONDS;
    +import static java.util.concurrent.TimeUnit.MINUTES;
    +import static org.assertj.core.api.Assertions.assertThat;
    +import static org.assertj.core.api.Assertions.assertThatThrownBy;
    +import static org.mockito.Mockito.mock;
    +import static org.mockito.Mockito.when;
    +
    +import java.io.File;
    +import java.util.concurrent.ExecutorService;
    +import java.util.concurrent.Executors;
    +import java.util.concurrent.TimeoutException;
    +import java.util.concurrent.atomic.AtomicReference;
    +
    +import org.awaitility.Awaitility;
    +import org.awaitility.core.ConditionFactory;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.Ignore;
    +import org.junit.Rule;
    +import org.junit.Test;
    +import org.junit.experimental.categories.Category;
    +import org.junit.rules.ErrorCollector;
    +import org.junit.rules.TemporaryFolder;
    +import org.junit.rules.TestName;
    +
    +import org.apache.geode.distributed.AbstractLauncher.Status;
    +import org.apache.geode.distributed.LocatorLauncher;
    +import org.apache.geode.distributed.LocatorLauncher.Builder;
    +import org.apache.geode.distributed.LocatorLauncher.LocatorState;
    +import org.apache.geode.internal.process.io.EmptyFileWriter;
    +import org.apache.geode.internal.process.io.IntegerFileWriter;
    +import org.apache.geode.internal.process.io.StringFileWriter;
    +import org.apache.geode.test.junit.categories.IntegrationTest;
    +
    +/**
    + * Integration tests for {@link FileProcessController}.
    + */
    +@Category(IntegrationTest.class)
    +public class FileProcessControllerIntegrationTest {
    +
    +  private static final String STATUS_JSON = generateStatusJson();
    +
    +  private final AtomicReference<String> statusRef = new 
AtomicReference<>();
    +
    +  private File pidFile;
    +  private File statusFile;
    +  private File statusRequestFile;
    +  private File stopRequestFile;
    +  private int pid;
    +  private FileControllerParameters params;
    +  private ExecutorService executor;
    +
    +  @Rule
    +  public ErrorCollector errorCollector = new ErrorCollector();
    +
    +  @Rule
    +  public TemporaryFolder temporaryFolder = new TemporaryFolder();
    +
    +  @Rule
    +  public TestName testName = new TestName();
    +
    +  @Before
    +  public void setUp() throws Exception {
    +    ProcessType processType = ProcessType.LOCATOR;
    +    File directory = temporaryFolder.getRoot();
    +    pidFile = new File(directory, processType.getPidFileName());
    +    statusFile = new File(directory, processType.getStatusFileName());
    +    statusRequestFile = new File(directory, 
processType.getStatusRequestFileName());
    +    stopRequestFile = new File(directory, 
processType.getStopRequestFileName());
    +    pid = ProcessUtils.identifyPid();
    +
    +    params = mock(FileControllerParameters.class);
    +    when(params.getPidFile()).thenReturn(pidFile);
    +    when(params.getProcessId()).thenReturn(pid);
    +    when(params.getProcessType()).thenReturn(processType);
    +    when(params.getDirectory()).thenReturn(temporaryFolder.getRoot());
    +
    +    executor = Executors.newSingleThreadExecutor();
    +  }
    +
    +  @After
    +  public void tearDown() throws Exception {
    +    assertThat(executor.shutdownNow()).isEmpty();
    +  }
    +
    +  @Test
    +  public void statusShouldAwaitTimeoutWhileFileIsEmpty() throws Exception {
    +    // given: FileProcessController with empty pidFile
    +    FileProcessController controller = new FileProcessController(params, 
pid, 10, MILLISECONDS);
    +
    +    // when:
    +    verifyException(controller).status();
    +
    +    // then: we expect TimeoutException to be thrown
    +    assertThat((Exception) 
caughtException()).isInstanceOf(TimeoutException.class)
    +        .hasMessageContaining("Timed out waiting for process to 
create").hasNoCause();
    +  }
    +
    +  @Test
    +  public void statusShouldReturnJsonFromStatusFile() throws Exception {
    +    // given: FileProcessController with pidFile containing real pid
    +    new IntegerFileWriter(pidFile).writeToFile(pid);
    +    FileProcessController controller = new FileProcessController(params, 
pid, 2, MINUTES);
    +
    +    // when: status is called in one thread
    +    executor.execute(() -> {
    +      try {
    +        statusRef.set(controller.status());
    +      } catch (Exception e) {
    +        errorCollector.addError(e);
    +      }
    +    });
    +
    +    // and: json is written to the status file
    +    new StringFileWriter(statusFile).writeToFile(STATUS_JSON);
    +
    +    // then: returned status should be the json in the file
    +    await().until(() -> 
assertThat(statusRef.get()).isEqualTo(STATUS_JSON));
    +  }
    +
    +  @Ignore // GEODE-3278
    --- End diff --
    
    Done.


> Overhaul launcher tests and process tests
> -----------------------------------------
>
>                 Key: GEODE-3413
>                 URL: https://issues.apache.org/jira/browse/GEODE-3413
>             Project: Geode
>          Issue Type: Improvement
>          Components: gfsh
>            Reporter: Kirk Lund
>            Assignee: Kirk Lund
>              Labels: LauncherTest, ProcessTest
>
> The launcher and process tests are closely related and in need of overhauling 
> to improve debugging and remove flakiness.
> In addition, the org.apache.geode.internal.process package is need of 
> improving the test code coverage.
> Launcher tests:
> * 
> geode-assembly/src/test/java/org/apache/geode/distributed/LocatorLauncherAssemblyIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherServiceStatusTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/AbstractLauncherTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LauncherMemberMXBeanIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherLocalFileIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherLocalIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteFileIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherRemoteWithCustomLoggingIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/LocatorLauncherTest.java
> * geode-core/src/test/java/org/apache/geode/distributed/LocatorStateTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherLocalFileIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherLocalIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteFileIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteWithCustomLoggingIntegrationTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherTest.java
> * 
> geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherWithProviderIntegrationTest.java
> Process tests:
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/BlockingProcessStreamReaderJUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/FileProcessControllerIntegrationJUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/LocalProcessControllerJUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/LocalProcessLauncherDUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/LocalProcessLauncherJUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/NonBlockingProcessStreamReaderJUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/PidFileJUnitTest.java
> * 
> geode-core/src/test/java/org/apache/geode/internal/process/ProcessControllerFactoryJUnitTest.java



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to