You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/07/17 16:21:29 UTC

[activemq-artemis] branch master updated: NO-JIRA Making sudo a requirement for NetworkFailureFailoverTest

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 9d7bbf4  NO-JIRA Making sudo a requirement for NetworkFailureFailoverTest
     new 55e0e4e  This closes #2758
9d7bbf4 is described below

commit 9d7bbf4ea3ba61d2d805dd638f11b94f1a49857f
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Wed Jul 17 09:47:38 2019 -0400

    NO-JIRA Making sudo a requirement for NetworkFailureFailoverTest
    
    When setting up a new Jenkins CI, it's required to add sudoer to have this test working
    otherwise it will silently pass.
---
 .../cluster/failover/NetworkFailureFailoverTest.java     | 13 ++++++++-----
 .../activemq/artemis/tests/util/network/NetUtil.java     | 16 ++++++++++------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java
index 2844162..8f9f6dc 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NetworkFailureFailoverTest.java
@@ -51,6 +51,12 @@ import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
 
+/**
+ * This test will simulate a failure where the network card is gone.
+ * On that case the server should fail (as in stop) and not hung.
+ * If you don't have sudoer access to ifutil, this test will fail.
+ * You should add sudoer on your environment. otherwise you will have to ignore failures here.
+ */
 public class NetworkFailureFailoverTest extends FailoverTestBase {
 
    @Rule
@@ -58,18 +64,16 @@ public class NetworkFailureFailoverTest extends FailoverTestBase {
 
    @BeforeClass
    public static void start() {
-      NetUtil.assumeSudo();
+      NetUtil.failIfNotSudo();
    }
 
-   // 192.0.2.0 is reserved for documentation, so I'm pretty sure this won't exist on any system. (It shouldn't at least)
+   // 192.0.2.0 is reserved for documentation (and testing on this case).
    private static final String LIVE_IP = "192.0.2.0";
 
    private int beforeTime;
 
    @Override
    public void setUp() throws Exception {
-      //      beforeTime = NettyConnection.getLockTimeout();
-      //      NettyConnection.setLockTimeout(1000);
       NetUtil.netUp(LIVE_IP);
       super.setUp();
    }
@@ -77,7 +81,6 @@ public class NetworkFailureFailoverTest extends FailoverTestBase {
    @Override
    public void tearDown() throws Exception {
       super.tearDown();
-      //      NettyConnection.setLockTimeout(beforeTime);
    }
 
    @Override
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/network/NetUtil.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/network/NetUtil.java
index 1d29b38..124face 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/network/NetUtil.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/network/NetUtil.java
@@ -21,6 +21,8 @@ import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.net.InetAddress;
 import java.util.Iterator;
 import java.util.Map;
@@ -77,14 +79,16 @@ public class NetUtil {
       osUsed = osTmp;
    }
 
-   public static void assumeSudo() {
+   public static void failIfNotSudo() {
       Assume.assumeTrue("non supported OS", osUsed != OS.NON_SUPORTED);
       if (!canSudo()) {
-         System.out.println("Add the following at the end of your /etc/sudoers (use the visudo command)");
-         System.out.println("# ------------------------------------------------------- ");
-         System.out.println(user + " ALL = NOPASSWD: /sbin/ifconfig");
-         System.out.println("# ------------------------------------------------------- ");
-         Assume.assumeFalse(true);
+         StringWriter writer = new StringWriter();
+         PrintWriter out = new PrintWriter(writer);
+         out.println("Add the following at the end of your /etc/sudoers (use the visudo command)");
+         out.println("# ------------------------------------------------------- ");
+         out.println(user + " ALL = NOPASSWD: /sbin/ifconfig");
+         out.println("# ------------------------------------------------------- ");
+         Assert.fail(writer.toString());
       }
    }