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 44349cc Capture zookeeper journal when integration tests end (#1968)
44349cc is described below
commit 44349cc12fecbce85ed729ab2579c2f1038dcee3
Author: Ivan Kelly <[email protected]>
AuthorDate: Thu Jun 14 23:07:28 2018 +0200
Capture zookeeper journal when integration tests end (#1968)
Some issues with integration are hard to debug from the logs
alone. For example, #1916 looks like bookies are registering with
zookeeper, but the broker never sees them. It's hard to narrow the
issue to the client or the server.
This patch adds a stop action for arquillian, which pulls the
zookeeper data directory at the end of the run, so we can at least
verify the state of the cluster from the zookeeper point of view.
---
...luster-2-bookie-1-broker-unstarted-with-s3.yaml | 4 +++
...single-cluster-3-bookie-2-broker-unstarted.yaml | 4 +++
.../single-cluster-3-bookie-2-broker.yaml | 4 +++
.../java/org/apache/pulsar/tests/DockerUtils.java | 24 ++++++++++++-
.../tests/ZKJournalToTargetDirStopAction.java | 42 ++++++++++++++++++++++
5 files changed, 77 insertions(+), 1 deletion(-)
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 6a2e3e2..6b8eaa4 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 6fe4d98..7664091 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 268e6d7..082a4d1 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 b815b51..5bc3ab0 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 com.github.dockerjava.api.model.ContainerNetwork;
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.CompletableFuture;
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 class DockerUtils {
}
}
- 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 0000000..309c7a6
--- /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");
+ }
+}
--
To stop receiving notification emails like this one, please contact
[email protected].