You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/06/14 21:07:30 UTC

[GitHub] merlimat closed pull request #1968: Capture zookeeper journal when integration tests end

merlimat closed pull request #1968: Capture zookeeper journal when integration tests end
URL: https://github.com/apache/incubator-pulsar/pull/1968
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml
index 6a2e3e28bc..6b8eaa427d 100644
--- a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml
+++ b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-2-bookie-1-broker-unstarted-with-s3.yaml
@@ -35,6 +35,8 @@ zookeeper*:
   beforeStop:
     - customBeforeStopAction:
         strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
+    - customBeforeStopAction:
+        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
   networkMode: pulsarnet*
 
 configuration-store*:
@@ -51,6 +53,8 @@ configuration-store*:
   beforeStop:
     - customBeforeStopAction:
         strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
+    - customBeforeStopAction:
+        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
   networkMode: pulsarnet*
 
 init*:
diff --git a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker-unstarted.yaml b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker-unstarted.yaml
index 6fe4d980a4..7664091213 100644
--- a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker-unstarted.yaml
+++ b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker-unstarted.yaml
@@ -35,6 +35,8 @@ zookeeper*:
   beforeStop:
     - customBeforeStopAction:
         strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
+    - customBeforeStopAction:
+        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
   networkMode: pulsarnet*
 
 configuration-store*:
@@ -51,6 +53,8 @@ configuration-store*:
   beforeStop:
     - customBeforeStopAction:
         strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
+    - customBeforeStopAction:
+        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
   networkMode: pulsarnet*
 
 init*:
diff --git a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker.yaml b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker.yaml
index 268e6d7a6d..082a4d1585 100644
--- a/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker.yaml
+++ b/tests/integration-tests-topologies/src/main/resources/cube-definitions/single-cluster-3-bookie-2-broker.yaml
@@ -35,6 +35,8 @@ zookeeper*:
   beforeStop:
     - customBeforeStopAction:
         strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
+    - customBeforeStopAction:
+        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
   networkMode: pulsarnet*
 
 configuration-store*:
@@ -51,6 +53,8 @@ configuration-store*:
   beforeStop:
     - customBeforeStopAction:
         strategy: org.apache.pulsar.tests.PulsarLogsToTargetDirStopAction
+    - customBeforeStopAction:
+        strategy: org.apache.pulsar.tests.ZKJournalToTargetDirStopAction
   networkMode: pulsarnet*
 
 init*:
diff --git a/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/DockerUtils.java b/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/DockerUtils.java
index b815b51171..5bc3ab0c90 100644
--- a/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/DockerUtils.java
+++ b/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/DockerUtils.java
@@ -27,6 +27,7 @@
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.OutputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.util.Arrays;
@@ -37,6 +38,7 @@
 import java.util.concurrent.ExecutionException;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import java.util.zip.GZIPOutputStream;
 
 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
@@ -99,7 +101,27 @@ public void onComplete() {
         }
     }
 
-    public static void dumpContainerLogDirToTarget(DockerClient docker, String containerId, String path) {
+    public static void dumpContainerDirToTargetCompressed(DockerClient docker, String containerId,
+                                                          String path) {
+        final int READ_BLOCK_SIZE = 10000;
+
+        File output = new File(getTargetDirectory(containerId),
+                               (path.replace("/", "-") + ".tar.gz").replaceAll("^-", ""));
+        try (InputStream dockerStream = docker.copyArchiveFromContainerCmd(containerId, path).exec();
+             OutputStream os = new GZIPOutputStream(new FileOutputStream(output))) {
+            byte[] block = new byte[READ_BLOCK_SIZE];
+            int read = dockerStream.read(block, 0, READ_BLOCK_SIZE);
+            while (read > -1) {
+                os.write(block, 0, read);
+                read = dockerStream.read(block, 0, READ_BLOCK_SIZE);
+            }
+        } catch (RuntimeException|IOException e) {
+            LOG.error("Error reading dir from container {}", containerId, e);
+        }
+    }
+
+    public static void dumpContainerLogDirToTarget(DockerClient docker, String containerId,
+                                                   String path) {
         final int READ_BLOCK_SIZE = 10000;
 
         try (InputStream dockerStream = docker.copyArchiveFromContainerCmd(containerId, path).exec();
diff --git a/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/ZKJournalToTargetDirStopAction.java b/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/ZKJournalToTargetDirStopAction.java
new file mode 100644
index 0000000000..309c7a65ce
--- /dev/null
+++ b/tests/integration-tests-utils/src/main/java/org/apache/pulsar/tests/ZKJournalToTargetDirStopAction.java
@@ -0,0 +1,42 @@
+/**
+ * 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.pulsar.tests;
+
+import org.arquillian.cube.docker.impl.docker.DockerClientExecutor;
+import org.arquillian.cube.impl.model.CubeId;
+import org.arquillian.cube.spi.beforeStop.BeforeStopAction;
+
+public class ZKJournalToTargetDirStopAction implements BeforeStopAction {
+    private DockerClientExecutor dockerClientExecutor;
+    private CubeId containerID;
+
+    public void setDockerClientExecutor(DockerClientExecutor executor) {
+        this.dockerClientExecutor = executor;
+    }
+
+    public void setContainerID(CubeId containerID) {
+        this.containerID = containerID;
+    }
+
+    @Override
+    public void doBeforeStop() {
+        DockerUtils.dumpContainerDirToTargetCompressed(dockerClientExecutor.getDockerClient(),
+                                                       containerID.getId(), "/pulsar/data/zookeeper");
+    }
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services