Skip to content

Commit

Permalink
For integration tests, copy function logs out of container on shutdow…
Browse files Browse the repository at this point in the history
…n for debugging purposes (apache#3529)
  • Loading branch information
jerrypeng authored and merlimat committed Feb 7, 2019
1 parent 3b1dd8c commit 2bc5c5b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.apache.pulsar.tests.integration.containers;

import org.apache.pulsar.tests.integration.utils.DockerUtils;

/**
* A pulsar container that runs functions worker.
*/
Expand All @@ -35,4 +37,16 @@ public WorkerContainer(String clusterName, String hostname) {
BROKER_HTTP_PORT,
"/admin/v2/worker/cluster");
}

@Override
protected void beforeStop() {
super.beforeStop();
if (null != containerId) {
DockerUtils.dumpContainerDirToTargetCompressed(
getDockerClient(),
containerId,
"/pulsar/logs/functions"
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.InspectContainerResponse;
import com.github.dockerjava.api.command.InspectExecResponse;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.ContainerNetwork;
import com.github.dockerjava.api.model.Frame;
import com.github.dockerjava.api.model.StreamType;
Expand Down Expand Up @@ -140,7 +141,9 @@ public static void dumpContainerDirToTargetCompressed(DockerClient dockerClient,
read = dockerStream.read(block, 0, READ_BLOCK_SIZE);
}
} catch (RuntimeException|IOException e) {
LOG.error("Error reading dir from container {}", containerName, e);
if (!(e instanceof NotFoundException)) {
LOG.error("Error reading dir from container {}", containerName, e);
}
}
}

Expand Down

0 comments on commit 2bc5c5b

Please sign in to comment.