Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 80AF420049E for ; Thu, 10 Aug 2017 21:11:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7F15516BF28; Thu, 10 Aug 2017 19:11:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 77BCD16BF22 for ; Thu, 10 Aug 2017 21:11:05 +0200 (CEST) Received: (qmail 42571 invoked by uid 500); 10 Aug 2017 19:11:04 -0000 Mailing-List: contact issues-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list issues@geode.apache.org Received: (qmail 42433 invoked by uid 99); 10 Aug 2017 19:11:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Aug 2017 19:11:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 054A1C0455 for ; Thu, 10 Aug 2017 19:11:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id oN0GotYRWpwZ for ; Thu, 10 Aug 2017 19:11:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 57C195FC4D for ; Thu, 10 Aug 2017 19:11:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B4DBEE0E0F for ; Thu, 10 Aug 2017 19:11:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 152DA24175 for ; Thu, 10 Aug 2017 19:11:01 +0000 (UTC) Date: Thu, 10 Aug 2017 19:11:01 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@geode.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GEODE-3413) Overhaul launcher tests and process tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 10 Aug 2017 19:11:06 -0000 [ https://issues.apache.org/jira/browse/GEODE-3413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16122131#comment-16122131 ] 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_r132542146 --- Diff: geode-core/src/test/java/org/apache/geode/distributed/LauncherIntegrationTestCase.java --- @@ -0,0 +1,505 @@ +/* + * 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.MCAST_PORT; +import static org.apache.geode.internal.AvailablePort.SOCKET; +import static org.apache.geode.internal.AvailablePort.isPortAvailable; +import static org.apache.geode.internal.process.ProcessUtils.identifyPid; +import static org.apache.geode.internal.process.ProcessUtils.isProcessAlive; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.lang.management.ManagementFactory; +import java.net.ServerSocket; +import java.nio.file.Files; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.Logger; +import org.awaitility.Awaitility; +import org.awaitility.core.ConditionFactory; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.contrib.java.lang.system.RestoreSystemProperties; +import org.junit.rules.TemporaryFolder; +import org.junit.rules.TestName; + +import org.apache.geode.distributed.internal.DistributionConfig; +import org.apache.geode.distributed.internal.InternalDistributedSystem; +import org.apache.geode.internal.logging.LogService; +import org.apache.geode.internal.net.SocketCreatorFactory; +import org.apache.geode.internal.process.PidUnavailableException; +import org.apache.geode.internal.process.ProcessStreamReader.InputListener; +import org.apache.geode.internal.process.ProcessType; +import org.apache.geode.internal.process.ProcessUtils; +import org.apache.geode.internal.process.lang.AvailablePid; +import org.apache.geode.internal.util.StopWatch; +import org.apache.geode.test.dunit.IgnoredException; + +/** + * Abstract base class for integration tests of both {@link LocatorLauncher} and + * {@link ServerLauncher}. + * + * @since GemFire 8.0 + */ +public abstract class LauncherIntegrationTestCase { + protected static final Logger logger = LogService.getLogger(); + + protected static final int WAIT_FOR_PROCESS_TO_DIE_TIMEOUT = 5 * 60 * 1000; // 5 minutes + protected static final int TIMEOUT_MILLISECONDS = WAIT_FOR_PROCESS_TO_DIE_TIMEOUT; + protected static final int WAIT_FOR_FILE_CREATION_TIMEOUT = 10 * 1000; // 10s + protected static final int WAIT_FOR_FILE_DELETION_TIMEOUT = 10 * 1000; // 10s + protected static final int WAIT_FOR_MBEAN_TIMEOUT = 10 * 1000; // 10s + protected static final int INTERVAL_MILLISECONDS = 100; + + protected static final int PREFERRED_FAKE_PID = 42; + + private static final String EXPECTED_EXCEPTION_ADD = + "{}"; + private static final String EXPECTED_EXCEPTION_REMOVE = + "{}"; + private static final String EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED = + "MBean Not Registered In GemFire Domain"; + + private IgnoredException ignoredException; + + protected int localPid; + protected int fakePid; + + protected volatile ServerSocket socket; + + protected volatile File pidFile; + protected volatile File stopRequestFile; + protected volatile File statusRequestFile; + protected volatile File statusFile; + + @Rule + public TestName testName = new TestName(); + + @Rule + public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); + + @Rule + public TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @Before + public void setUpAbstractLauncherIntegrationTestCase() throws Exception { + System.setProperty(DistributionConfig.GEMFIRE_PREFIX + MCAST_PORT, Integer.toString(0)); + ignoredException = + IgnoredException.addIgnoredException(EXPECTED_EXCEPTION_MBEAN_NOT_REGISTERED); + localPid = identifyPid(); + fakePid = new AvailablePid().findAvailablePid(PREFERRED_FAKE_PID); + } + + @After + public void tearDownAbstractLauncherIntegrationTestCase() throws Exception { + ignoredException.remove(); + if (this.socket != null) { + this.socket.close(); + this.socket = null; + } + delete(this.pidFile); + delete(this.stopRequestFile); + delete(this.statusRequestFile); + delete(this.statusFile); + } + + protected abstract ProcessType getProcessType(); + + protected String getStopRequestFileName() { + return getProcessType().getStopRequestFileName(); + } + + protected String getStatusRequestFileName() { + return getProcessType().getStatusRequestFileName(); + } + + protected String getStatusFileName() { + return getProcessType().getStatusFileName(); + } + + protected void givenEmptyWorkingDirectory() { + assertThat(getWorkingDirectory().listFiles()).hasSize(0); + } + + protected List getJvmArguments() { + return ManagementFactory.getRuntimeMXBean().getInputArguments(); + } + + protected ConditionFactory await() { + return Awaitility.await().atMost(2, MINUTES); + } + + public String getClassPath() { + // alternative: ManagementFactory.getRuntimeMXBean().getClassPath() + return System.getProperty("java.class.path"); + } + + public String getJavaPath() { + try { + return new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + protected File getPidFile() { + return new File(getWorkingDirectory(), getProcessType().getPidFileName()); + } + + protected File getLogFile() { + return new File(getWorkingDirectory(), getUniqueName() + ".log"); + } + + protected String getLogFilePath() { + try { + return getLogFile().getCanonicalPath(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + protected File getWorkingDirectory() { + return this.temporaryFolder.getRoot(); + } + + protected String getWorkingDirectoryPath() { + try { + return getWorkingDirectory().getCanonicalPath(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + protected void createPidFile(final Object content) { --- End diff -- All unused methods deleted. > 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)