sijie closed pull request #3080: Don't overwrite integration tests longs if 
container restarted
URL: https://github.com/apache/pulsar/pull/3080
 
 
   

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/src/test/java/org/apache/pulsar/tests/integration/utils/DockerUtils.java
 
b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/utils/DockerUtils.java
index 5148a36912..8fdd968f1e 100644
--- 
a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/utils/DockerUtils.java
+++ 
b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/utils/DockerUtils.java
@@ -71,6 +71,11 @@ public static void dumpContainerLogToTarget(DockerClient 
dockerClient, String co
         // this removes it to be consistent with what docker ps shows.
         final String containerName = 
inspectContainerResponse.getName().replace("/","");
         File output = new File(getTargetDirectory(containerName), 
"docker.log");
+        int i = 0;
+        while (output.exists()) {
+            LOG.info("{} exists, incrementing", output);
+            output = new File(getTargetDirectory(containerName), "docker." + 
i++ + ".log");
+        }
         try (FileOutputStream os = new FileOutputStream(output)) {
             CompletableFuture<Boolean> future = new CompletableFuture<>();
             dockerClient.logContainerCmd(containerName).withStdOut(true)
@@ -116,8 +121,13 @@ public static void 
dumpContainerDirToTargetCompressed(DockerClient dockerClient,
         // docker api returns names prefixed with "/", it's part of it's 
legacy design,
         // this removes it to be consistent with what docker ps shows.
         final String containerName = 
inspectContainerResponse.getName().replace("/","");
-        File output = new File(getTargetDirectory(containerName),
-                               (path.replace("/", "-") + 
".tar.gz").replaceAll("^-", ""));
+        String baseName = path.replace("/", "-").replaceAll("^-", "");
+        File output = new File(getTargetDirectory(containerName), baseName + 
".tar.gz");
+        int i = 0;
+        while (output.exists()) {
+            LOG.info("{} exists, incrementing", output);
+            output = new File(getTargetDirectory(containerName), baseName + 
"_" + i++ + ".tar.gz");
+        }
         try (InputStream dockerStream = 
dockerClient.copyArchiveFromContainerCmd(containerId, path).exec();
              OutputStream os = new GZIPOutputStream(new 
FileOutputStream(output))) {
             byte[] block = new byte[READ_BLOCK_SIZE];


 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to