[
https://issues.apache.org/jira/browse/GEODE-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16120736#comment-16120736
]
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_r132321751
--- Diff:
geode-core/src/test/java/org/apache/geode/distributed/ServerLauncherRemoteIntegrationTestCase.java
---
@@ -0,0 +1,270 @@
+/*
+ * 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.distributed;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+import static
org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static
org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static
org.apache.geode.distributed.internal.DistributionConfig.GEMFIRE_PREFIX;
+import static
org.apache.geode.internal.cache.AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY;
+import static
org.apache.geode.internal.process.ProcessUtils.isProcessAlive;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.net.BindException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.junit.After;
+import org.junit.Before;
+
+import org.apache.geode.distributed.AbstractLauncher.Status;
+import org.apache.geode.internal.process.ProcessStreamReader;
+import org.apache.geode.internal.process.ProcessStreamReader.InputListener;
+
+/**
+ * Abstract base class for integration tests of {@link ServerLauncher} as
an application main in a
+ * forked JVM.
+ *
+ * @since GemFire 8.0
+ */
+public abstract class ServerLauncherRemoteIntegrationTestCase
+ extends ServerLauncherIntegrationTestCase implements UsesServerCommand
{
+
+ private final AtomicBoolean threwBindException = new AtomicBoolean();
+
+ protected volatile Process process;
+ protected volatile ProcessStreamReader processOutReader;
+ protected volatile ProcessStreamReader processErrReader;
+
+ private ServerCommand serverCommand;
+
+ @Before
+ public void setUp() throws Exception {
+ serverCommand = new ServerCommand(this);
+ }
+
+ @After
+ public void tearDownAbstractServerLauncherRemoteIntegrationTestCase()
throws Exception {
+ if (this.process != null) {
+ this.process.destroy();
+ this.process = null;
+ }
+ if (this.processOutReader != null &&
this.processOutReader.isRunning()) {
+ this.processOutReader.stop();
+ }
+ if (this.processErrReader != null &&
this.processErrReader.isRunning()) {
+ this.processErrReader.stop();
+ }
+ }
+
+ @Override
+ public List<String> getJvmArguments() {
+ List<String> jvmArguments = new ArrayList<>();
+ jvmArguments.add("-D" + GEMFIRE_PREFIX + LOG_LEVEL + "=config");
+ jvmArguments.add("-D" + GEMFIRE_PREFIX + MCAST_PORT + "=0");
+ jvmArguments
+ .add("-D" + TEST_OVERRIDE_DEFAULT_PORT_PROPERTY + "=" +
String.valueOf(defaultServerPort));
+ return jvmArguments;
+ }
+
+ @Override
+ public String getName() {
+ return getUniqueName();
+ }
+
+ @Override
+ public boolean getDisableDefaultServer() {
+ return false;
+ }
+
+ protected void assertThatServerThrewBindException() {
+ assertThat(threwBindException.get()).isTrue();
+ }
+
+ protected void assertThatServerThrew(final Class<? extends Throwable>
throwableClass) {
+ assertThat(threwBindException.get()).isTrue();
+ }
+
+ protected ServerLauncher startServer(final ServerCommand command) {
+ return awaitStart(command);
+ }
+
+ protected ServerLauncher awaitStart(final ServerCommand command,
+ final ProcessStreamReader.InputListener outListener,
+ final ProcessStreamReader.InputListener errListener) throws
Exception {
+ executeCommandWithReaders(command.create(), outListener, errListener);
+ ServerLauncher launcher = awaitStart(getWorkingDirectory());
+ assertThat(process.isAlive()).isTrue();
+ return launcher;
+ }
+
+ protected ServerLauncher awaitStart(final ServerCommand command) {
+ try {
+ executeCommandWithReaders(command);
+ ServerLauncher launcher = awaitStart(getWorkingDirectory());
+ assertThat(process.isAlive()).isTrue();
+ return launcher;
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ protected ServerLauncher awaitStart(final File workingDirectory) {
+ try {
+ this.launcher = new ServerLauncher.Builder()
+
.setWorkingDirectory(workingDirectory.getCanonicalPath()).build();
+ ServerLauncher launcher = awaitStart(this.launcher);
+ assertThat(process.isAlive()).isTrue();
+ return launcher;
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ @Override
+ protected ServerLauncher awaitStart(final ServerLauncher launcher) {
+ await().until(() ->
assertThat(launcher.status().getStatus()).isEqualTo(Status.ONLINE));
+ assertThat(process.isAlive()).isTrue();
+ return launcher;
+ }
+
+ protected ServerLauncher awaitStart() {
+ return awaitStart(this.launcher);
+ }
+
+ protected void awaitStop() {
--- End diff --
Delete unused method.
> 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)