geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [geode] branch develop updated: GEODE-3933: remove tests from the test suite and run them individually with parameters to avoid test contamination. (#996)
Date Wed, 01 Nov 2017 16:05:28 GMT
This is an automated email from the ASF dual-hosted git repository.

jinmeiliao pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new ba40a7f  GEODE-3933: remove tests from the test suite and run them individually with
parameters to avoid test contamination. (#996)
ba40a7f is described below

commit ba40a7fcdc8b7f329c9fb48e6780955bc7e636b7
Author: jinmeiliao <jiliao@pivotal.io>
AuthorDate: Wed Nov 1 09:05:26 2017 -0700

    GEODE-3933: remove tests from the test suite and run them individually with parameters
to avoid test contamination. (#996)
---
 .../commands/ChangeLogLevelCommandDUnitTest.java   | 79 +++++++++-------------
 .../internal/cli/commands/GcCommandDUnitTest.java  | 32 ++++++---
 .../cli/commands/ShowLogCommandDUnitTest.java      | 46 ++++++++-----
 .../cli/commands/ShutdownCommandDUnitTest.java     | 16 ++++-
 .../cli/commands/CommandOverHttpDUnitTest.java     | 11 +--
 5 files changed, 100 insertions(+), 84 deletions(-)

diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
index caed02c..d417995 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
@@ -16,20 +16,18 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.management.internal.cli.commands.CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.http;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.jmxManager;
-import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Properties;
 
-import org.junit.Before;
-import org.junit.Rule;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
 import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
 import org.apache.geode.test.dunit.rules.MemberVM;
 import org.apache.geode.test.junit.categories.DistributedTest;
@@ -37,8 +35,8 @@ import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
 
 
 @Category(DistributedTest.class)
+@RunWith(Parameterized.class)
 public class ChangeLogLevelCommandDUnitTest {
-  private static final boolean CONNECT_OVER_HTTP = Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
   private static final String MANAGER_NAME = "Manager";
   private static final String SERVER1_NAME = "Server1";
   private static final String SERVER2_NAME = "Server2";
@@ -46,14 +44,23 @@ public class ChangeLogLevelCommandDUnitTest {
   private static final String GROUP1 = "Group1";
   private static final String GROUP2 = "Group2";
 
-  @Rule
-  public LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
+  @ClassRule
+  public static LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
 
-  @Rule
-  public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+  @ClassRule
+  public static GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
 
-  @Before
-  public void setup() throws Exception {
+
+  @Parameterized.Parameter
+  public static boolean useHttp;
+
+  @Parameterized.Parameters
+  public static Object[] data() {
+    return new Object[] {true, false};
+  }
+
+  @BeforeClass
+  public static void setup() throws Exception {
     Properties managerProps = new Properties();
     managerProps.setProperty(NAME, MANAGER_NAME);
     managerProps.setProperty(GROUPS, GROUP0);
@@ -69,7 +76,7 @@ public class ChangeLogLevelCommandDUnitTest {
     server2Props.setProperty(GROUPS, GROUP2);
     locatorServerStartupRule.startServerVM(2, server2Props, manager.getPort());
 
-    if (CONNECT_OVER_HTTP) {
+    if (useHttp) {
       gfsh.connectAndVerify(manager.getHttpPort(), http);
     } else {
       gfsh.connectAndVerify(manager.getJmxPort(), jmxManager);
@@ -81,26 +88,16 @@ public class ChangeLogLevelCommandDUnitTest {
   public void testChangeLogLevelForGroups() {
     String commandString = "change loglevel --loglevel=finer --groups=" + GROUP1 + "," +
GROUP2;
 
-    gfsh.executeAndAssertThat(commandString).statusIsSuccess();
-
-    String output = gfsh.getGfshOutput();
-
-    assertThat(output).contains(SERVER1_NAME);
-    assertThat(output).contains(SERVER2_NAME);
-    assertThat(output).doesNotContain(MANAGER_NAME);
+    gfsh.executeAndAssertThat(commandString).statusIsSuccess()
+        .containsOutput(SERVER1_NAME, SERVER2_NAME).doesNotContainOutput(MANAGER_NAME);
   }
 
   @Test
   public void testChangeLogLevelForGroup() {
     String commandString = "change loglevel --loglevel=finer --groups=" + GROUP1;
 
-    gfsh.executeAndAssertThat(commandString).statusIsSuccess();
-
-    String output = gfsh.getGfshOutput();
-
-    assertThat(output).contains(SERVER1_NAME);
-    assertThat(output).doesNotContain(SERVER2_NAME);
-    assertThat(output).doesNotContain(MANAGER_NAME);
+    gfsh.executeAndAssertThat(commandString).statusIsSuccess().containsOutput(SERVER1_NAME)
+        .doesNotContainOutput(SERVER2_NAME, MANAGER_NAME);
   }
 
   @Test
@@ -108,37 +105,23 @@ public class ChangeLogLevelCommandDUnitTest {
     String commandString =
         "change loglevel --loglevel=finer --members=" + SERVER1_NAME + "," + SERVER2_NAME;
 
-    gfsh.executeAndAssertThat(commandString).statusIsSuccess();
-
-    String output = gfsh.getGfshOutput();
-
-    assertThat(output).contains(SERVER1_NAME);
-    assertThat(output).contains(SERVER2_NAME);
-    assertThat(output).doesNotContain(MANAGER_NAME);
+    gfsh.executeAndAssertThat(commandString).statusIsSuccess()
+        .containsOutput(SERVER1_NAME, SERVER2_NAME).doesNotContainOutput(MANAGER_NAME);
   }
 
   @Test
   public void testChangeLogLevelForMember() {
     String commandString = "change loglevel --loglevel=finer --members=" + SERVER1_NAME;
 
-    gfsh.executeAndAssertThat(commandString).statusIsSuccess();
-
-    String output = gfsh.getGfshOutput();
-
-    assertThat(output).contains(SERVER1_NAME);
-    assertThat(output).doesNotContain(SERVER2_NAME);
-    assertThat(output).doesNotContain(MANAGER_NAME);
+    gfsh.executeAndAssertThat(commandString).statusIsSuccess().containsOutput(SERVER1_NAME)
+        .doesNotContainOutput(SERVER2_NAME, MANAGER_NAME);
   }
 
   @Test
   public void testChangeLogLevelForInvalidMember() {
     String commandString = "change loglevel --loglevel=finer --members=NotAValidMember";
 
-    CommandResult result = gfsh.executeCommand(commandString);
-
-    assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    String output = gfsh.getGfshOutput();
-
-    assertThat(output).contains("No members were found matching the given member IDs or groups.");
+    gfsh.executeAndAssertThat(commandString).statusIsError()
+        .containsOutput("No members were found matching the given member IDs or groups.");
   }
 }
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
index 2cf5772..a3e2937 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
@@ -17,17 +17,18 @@ package org.apache.geode.management.internal.cli.commands;
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.management.internal.cli.commands.CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.http;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.jmxManager;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.util.Properties;
 
-import org.junit.Before;
-import org.junit.Rule;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
 import org.apache.geode.management.cli.Result;
 import org.apache.geode.management.internal.cli.result.CommandResult;
@@ -38,8 +39,8 @@ import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
 
 
 @Category(DistributedTest.class)
+@RunWith(Parameterized.class)
 public class GcCommandDUnitTest {
-  private static final boolean CONNECT_OVER_HTTP = Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
   private static final String MANAGER_NAME = "Manager";
   private static final String SERVER1_NAME = "Server1";
   private static final String SERVER2_NAME = "Server2";
@@ -47,14 +48,23 @@ public class GcCommandDUnitTest {
   private static final String GROUP1 = "Group1";
   private static final String GROUP2 = "Group2";
 
-  @Rule
-  public LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
+  @Parameterized.Parameter
+  public static boolean useHttp;
 
-  @Rule
-  public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+  @Parameterized.Parameters
+  public static Object[] data() {
+    return new Object[] {true, false};
+  }
+
+
+  @ClassRule
+  public static LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
+
+  @ClassRule
+  public static GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
 
-  @Before
-  public void setup() throws Exception {
+  @BeforeClass
+  public static void setup() throws Exception {
     Properties managerProps = new Properties();
     managerProps.setProperty(NAME, MANAGER_NAME);
     managerProps.setProperty(GROUPS, GROUP0);
@@ -72,7 +82,7 @@ public class GcCommandDUnitTest {
     server2Props.setProperty(GROUPS, GROUP2);
     locatorServerStartupRule.startServerVM(2, server2Props, manager.getPort());
 
-    if (CONNECT_OVER_HTTP) {
+    if (useHttp) {
       gfsh.connectAndVerify(manager.getHttpPort(), http);
     } else {
       gfsh.connectAndVerify(manager.getJmxPort(), jmxManager);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
index cf1cd52..6f9dd88 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
@@ -16,8 +16,8 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.management.internal.cli.commands.CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.http;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.jmxManager;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -27,10 +27,12 @@ import java.util.Properties;
 import java.util.concurrent.TimeUnit;
 
 import org.awaitility.Awaitility;
-import org.junit.Before;
-import org.junit.Rule;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
 import org.apache.geode.cache.CacheFactory;
 import org.apache.geode.distributed.DistributedMember;
@@ -45,9 +47,8 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
 
 @Category(DistributedTest.class)
+@RunWith(Parameterized.class)
 public class ShowLogCommandDUnitTest implements Serializable {
-  private static final boolean CONNECT_OVER_HTTP = Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
-
   private static final String MANAGER_NAME = "Manager";
   private static final String SERVER1_NAME = "Server1";
   private static final String SERVER2_NAME = "Server2";
@@ -57,22 +58,30 @@ public class ShowLogCommandDUnitTest implements Serializable {
   private static final String MESSAGE_ON_MANAGER = "someLogMessageOnManager";
   private static final String MESSAGE_ON_SERVER1 = "someLogMessageOnServer1";
   private static final String MESSAGE_ON_SERVER2 = "someLogMessageOnServer2";
-  private MemberVM manager;
-  private MemberVM server1;
-  private MemberVM server2;
-  @Rule
-  public LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
+  private static MemberVM manager;
+  private static MemberVM server1;
+  private static MemberVM server2;
+  @ClassRule
+  public static LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
+
+  @ClassRule
+  public static GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
 
-  @Rule
-  public GfshShellConnectionRule gfsh = new GfshShellConnectionRule();
+  @Parameterized.Parameter
+  public static boolean useHttp;
 
+  @Parameterized.Parameters
+  public static Object[] data() {
+    return new Object[] {true, false};
+  }
 
-  @Before
-  public void setup() throws Exception {
+  @BeforeClass
+  public static void setup() throws Exception {
     Properties managerProps = new Properties();
     managerProps.setProperty(NAME, MANAGER_NAME);
     managerProps.setProperty(GROUPS, GROUP0);
     managerProps.setProperty(LOG_FILE, MANAGER_NAME + ".log");
+    managerProps.setProperty(LOG_LEVEL, "info");
 
     manager = locatorServerStartupRule.startLocatorVM(0, managerProps);
 
@@ -80,6 +89,7 @@ public class ShowLogCommandDUnitTest implements Serializable {
     server1Props.setProperty(NAME, SERVER1_NAME);
     server1Props.setProperty(GROUPS, GROUP1);
     server1Props.setProperty(LOG_FILE, SERVER1_NAME + ".log");
+    managerProps.setProperty(LOG_LEVEL, "info");
 
     server1 = locatorServerStartupRule.startServerVM(1, server1Props, manager.getPort());
 
@@ -87,16 +97,18 @@ public class ShowLogCommandDUnitTest implements Serializable {
     server2Props.setProperty(NAME, SERVER2_NAME);
     server2Props.setProperty(GROUPS, GROUP2);
     server2Props.setProperty(LOG_FILE, SERVER2_NAME + ".log");
+    managerProps.setProperty(LOG_LEVEL, "info");
 
     server2 = locatorServerStartupRule.startServerVM(2, server2Props, manager.getPort());
 
-    if (CONNECT_OVER_HTTP) {
+    if (useHttp) {
       gfsh.connectAndVerify(manager.getHttpPort(), http);
     } else {
       gfsh.connectAndVerify(manager.getJmxPort(), jmxManager);
     }
 
-    Awaitility.await().atMost(2, TimeUnit.MINUTES).until(this::allMembersAreConnected);
+    Awaitility.await().atMost(2, TimeUnit.MINUTES)
+        .until(ShowLogCommandDUnitTest::allMembersAreConnected);
   }
 
   private void writeLogMessages() {
@@ -147,7 +159,7 @@ public class ShowLogCommandDUnitTest implements Serializable {
 
   }
 
-  private boolean allMembersAreConnected() {
+  private static boolean allMembersAreConnected() {
     return manager.getVM().invoke(() -> {
       InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
       DistributedMember server1 = CliUtil.getDistributedMemberByNameOrId(SERVER1_NAME);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
index e60262c..84e2803 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
@@ -17,7 +17,6 @@ package org.apache.geode.management.internal.cli.commands;
 import static org.apache.geode.distributed.ConfigurationProperties.GROUPS;
 import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE;
 import static org.apache.geode.distributed.ConfigurationProperties.NAME;
-import static org.apache.geode.management.internal.cli.commands.CliCommandTestBase.USE_HTTP_SYSTEM_PROPERTY;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.http;
 import static org.apache.geode.test.junit.rules.GfshShellConnectionRule.PortType.jmxManager;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -31,6 +30,8 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
 
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheClosedException;
@@ -43,8 +44,8 @@ import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
 
 
 @Category(DistributedTest.class)
+@RunWith(Parameterized.class)
 public class ShutdownCommandDUnitTest {
-  private static final boolean CONNECT_OVER_HTTP = Boolean.getBoolean(USE_HTTP_SYSTEM_PROPERTY);
   private static final String MANAGER_NAME = "Manager";
   private static final String SERVER1_NAME = "Server1";
   private static final String SERVER2_NAME = "Server2";
@@ -56,6 +57,15 @@ public class ShutdownCommandDUnitTest {
   private MemberVM server1;
   private MemberVM server2;
 
+
+  @Parameterized.Parameter
+  public static boolean useHttp;
+
+  @Parameterized.Parameters
+  public static Object[] data() {
+    return new Object[] {true, false};
+  }
+
   @Rule
   public LocatorServerStartupRule locatorServerStartupRule = new LocatorServerStartupRule();
 
@@ -82,7 +92,7 @@ public class ShutdownCommandDUnitTest {
     server2Props.setProperty(GROUPS, GROUP2);
     server2 = locatorServerStartupRule.startServerVM(2, server2Props, manager.getPort());
 
-    if (CONNECT_OVER_HTTP) {
+    if (useHttp) {
       gfsh.connectAndVerify(manager.getHttpPort(), http);
     } else {
       gfsh.connectAndVerify(manager.getJmxPort(), jmxManager);
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
index 97a5112..5334e10 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpDUnitTest.java
@@ -24,13 +24,14 @@ import org.apache.geode.test.junit.categories.DistributedTest;
 import org.apache.geode.test.junit.categories.SecurityTest;
 import org.apache.geode.test.junit.runners.SuiteRunner;
 
+/**
+ * Only commands that extends CliCommandTestBase needs to be in this test suite
+ */
 @Category({DistributedTest.class, SecurityTest.class})
 @RunWith(SuiteRunner.class)
-@Suite.SuiteClasses({ChangeLogLevelCommandDUnitTest.class, DeployWithGroupsDUnitTest.class,
-    DiskStoreCommandsDUnitTest.class, GcCommandDUnitTest.class, GemfireDataCommandsDUnitTest.class,
-    ListAndDescribeDiskStoreCommandsDUnitTest.class, ShutdownCommandDUnitTest.class,
-    QueueCommandsDUnitTest.class, ShellCommandsDUnitTest.class, ShowDeadlockDUnitTest.class,
-    ShowLogCommandDUnitTest.class, ShowMetricsDUnitTest.class, ShowStackTraceDUnitTest.class})
+@Suite.SuiteClasses({DiskStoreCommandsDUnitTest.class, GemfireDataCommandsDUnitTest.class,
+    ListAndDescribeDiskStoreCommandsDUnitTest.class, QueueCommandsDUnitTest.class,
+    ShellCommandsDUnitTest.class, ShowStackTraceDUnitTest.class})
 public class CommandOverHttpDUnitTest {
   @ClassRule
   public static ProvideSystemProperty provideSystemProperty =

-- 
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <commits@geode.apache.org>'].

Mime
View raw message