Github user jinmeiliao commented on a diff in the pull request:
https://github.com/apache/geode/pull/652#discussion_r129647221
--- Diff:
geode-assembly/src/test/java/org/apache/geode/management/internal/cli/shell/GfshExitCodeStatusCommandsDUnitTest.java
---
@@ -0,0 +1,396 @@
+/*
+ * 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.management.internal.cli.shell;
+
+import static java.util.concurrent.TimeUnit.MINUTES;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import org.apache.geode.internal.AvailablePort;
+import org.apache.geode.internal.ExitCode;
+import org.apache.geode.internal.process.PidFile;
+import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
+import org.apache.geode.management.internal.cli.util.ThreePhraseGenerator;
+import org.apache.geode.test.dunit.rules.gfsh.GfshExecution;
+import org.apache.geode.test.dunit.rules.gfsh.GfshRule;
+import org.apache.geode.test.dunit.rules.gfsh.GfshScript;
+import org.apache.geode.test.junit.categories.AcceptanceTest;
+
+// Originally created in response to GEODE-2971
+
+@Category(AcceptanceTest.class)
+@RunWith(JUnitParamsRunner.class)
+public class GfshExitCodeStatusCommandsDUnitTest {
+ private static File toolsJar;
+ private final static ThreePhraseGenerator nameGenerator = new
ThreePhraseGenerator();
+ private final static String memberControllerName = "member-controller";
+
+ @Rule
+ public GfshRule gfsh = new GfshRule();
+ private String locatorName;
+ private String serverName;
+
+ private int locatorPort;
+
+ // Some test configuration shorthands
+ private TestConfiguration LOCATOR_ONLINE_BUT_NOT_CONNECTED =
+ new TestConfiguration(true, false, false);
+ private TestConfiguration LOCATOR_ONLINE_AND_CONNECTED = new
TestConfiguration(true, false, true);
+ private TestConfiguration BOTH_ONLINE_BUT_NOT_CONNECTED =
+ new TestConfiguration(true, true, false);
+ private TestConfiguration BOTH_ONLINE_AND_CONNECTED = new
TestConfiguration(true, true, true);
+
+ @BeforeClass
+ public static void classSetup() {
+ File javaHome = new File(System.getProperty("java.home"));
+ String toolsPath =
+ javaHome.getName().equalsIgnoreCase("jre") ? "../lib/tools.jar" :
"lib/tools.jar";
+ toolsJar = new File(javaHome, toolsPath);
+ }
+
+ @Before
+ public void setup() {
+ locatorName = "locator-" + nameGenerator.generate('-');
+ serverName = "server-" + nameGenerator.generate('-');
+ locatorPort =
AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+ }
+
+ @Test
+ @Parameters(
+ value = {"status locator --port=-10", "status locator --pid=-1",
"status server --pid=-1"})
+ public void statusCommandWithInvalidOptionValueShouldFail(String cmd) {
+ GfshScript.of(cmd).withName("test-frame").awaitAtMost(1, MINUTES)
+ .expectExitCode(ExitCode.FATAL.getValue()).execute(gfsh);
+ }
+
+
+ @Test
+ @Parameters(value = {"status locator --host=somehostname", "status
locator --port=10334",
+ "status locator --dir=.", "status server --dir=.", "status locator
--name=some-locator-name",
+ "status server --name=some-server-name", "status locator --pid=-1",
"status server --pid=-1"})
+ public void
statusCommandWithValidOptionValueShouldFailWithNoMembers(String cmd) {
--- End diff --
this test failed for me when I run it locally:
[INFO 10:33:30.713 PDT] (test-frame): (1) Executing - status server --dir=.
[INFO 10:33:30.713 PDT] (test-frame):
[INFO 10:33:30.743 PDT] (test-frame): Server in
/private/var/folders/1r/mzzwlxp953ldf540k1cjpyvm0000gn/T/junit5151700688125605579/test-frame
on null is currently not responding.
[INFO 10:33:30.743 PDT] (test-frame):
org.junit.ComparisonFailure:
Expected :1
Actual :0
<Click to see difference>
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---