You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2018/05/17 17:43:37 UTC

[incubator-pulsar] branch master updated: Utilities to update configuration for integration tests (#1802)

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

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 63a6b83  Utilities to update configuration for integration tests (#1802)
63a6b83 is described below

commit 63a6b835bb3f21b63923eb128c285b9f827491d0
Author: Ivan Kelly <iv...@apache.org>
AuthorDate: Thu May 17 19:43:35 2018 +0200

    Utilities to update configuration for integration tests (#1802)
    
    This patch provides two utility methods. One of them allows the update
    of a key value properties type configuration, such as broker.conf.
    
    The other allows the update of a log4j2.yaml, to add loggers at a certain
    level. This is useful for debugging integration tests.
---
 .../apache/pulsar/tests/PulsarClusterUtils.java    | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/PulsarClusterUtils.java b/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/PulsarClusterUtils.java
index 984dadc..ca8e33b 100644
--- a/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/PulsarClusterUtils.java
+++ b/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/PulsarClusterUtils.java
@@ -169,7 +169,7 @@ public class PulsarClusterUtils {
                     return true;
                 } catch (Exception e) {
                     // couldn't connect, try again after sleep
-                    LOG.info("Failed to connect {} @ {}", ip, BROKER_PORT, e);
+                    LOG.debug("Failed to connect {} @ {}", ip, BROKER_PORT, e);
                 }
                 try {
                     Thread.sleep(pollMillis);
@@ -295,4 +295,27 @@ public class PulsarClusterUtils {
         return DockerUtils.cubeIdsWithLabels(docker, ImmutableMap.of("service", "zookeeper",
                                                                      "cluster", cluster));
     }
+
+    public static void updateConf(DockerClient docker, String containerId,
+                                  String confFile, String key, String value) throws Exception {
+        String sedProgram = String.format(
+                "/[[:blank:]]*%s[[:blank:]]*=/ { h; s^=.*^=%s^; }; ${x;/^$/ { s^^%s=%s^;H; }; x}",
+                key, value, key, value);
+        DockerUtils.runCommand(docker, containerId, "sed", "-i", "-e", sedProgram, confFile);
+    }
+
+    public static void setLogLevel(DockerClient docker, String containerId,
+                                   String loggerName, String level) throws Exception {
+        String sedProgram = String.format(
+                "/  Logger:/ a\\\n"
+                +"      - name: %s\\n"
+                +"        level: %s\\n"
+                +"        additivity: false\\n"
+                +"        AppenderRef:\\n"
+                +"          - ref: Console\\n"
+                +"          - level: debug\\n",
+                loggerName, level);
+        String logConf = "/pulsar/conf/log4j2.yaml";
+        DockerUtils.runCommand(docker, containerId, "sed", "-i", "-e", sedProgram, logConf);
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
mmerli@apache.org.