kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: KAFKA-3195; Transient test failure in OffsetCheckpointTest.testReadWrite
Date Wed, 03 Feb 2016 02:29:38 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk fd10f6dff -> e8343e67e


KAFKA-3195; Transient test failure in OffsetCheckpointTest.testReadWrite

Author: Ismael Juma <ismael@juma.me.uk>

Reviewers: Ewen Cheslack-Postava <ewen@confluent.io>

Closes #855 from ijuma/kafka-3195-offset-checkpoint-test-transient-failure


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/e8343e67
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/e8343e67
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/e8343e67

Branch: refs/heads/trunk
Commit: e8343e67e1ca74c4c0ebd994b9811b9fed7aa386
Parents: fd10f6d
Author: Ismael Juma <ismael@juma.me.uk>
Authored: Tue Feb 2 18:29:29 2016 -0800
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Tue Feb 2 18:29:29 2016 -0800

----------------------------------------------------------------------
 .../src/test/java/org/apache/kafka/test/TestUtils.java   | 11 +++++++++++
 core/src/test/scala/unit/kafka/utils/TestUtils.scala     |  6 +-----
 .../streams/state/internals/OffsetCheckpointTest.java    |  7 +++----
 3 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/e8343e67/clients/src/test/java/org/apache/kafka/test/TestUtils.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/test/TestUtils.java b/clients/src/test/java/org/apache/kafka/test/TestUtils.java
index 0fb59e6..7b88f5e 100644
--- a/clients/src/test/java/org/apache/kafka/test/TestUtils.java
+++ b/clients/src/test/java/org/apache/kafka/test/TestUtils.java
@@ -19,6 +19,7 @@ package org.apache.kafka.test;
 import static java.util.Arrays.asList;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -82,4 +83,14 @@ public class TestUtils {
         return b.toString();
     }
 
+    /**
+     * Creates an empty file in the default temporary-file directory, using `kafka` as the
prefix and `tmp` as the
+     * suffix to generate its name.
+     */
+    public static File tempFile() throws IOException {
+        File file = File.createTempFile("kafka", ".tmp");
+        file.deleteOnExit();
+        return file;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/kafka/blob/e8343e67/core/src/test/scala/unit/kafka/utils/TestUtils.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/unit/kafka/utils/TestUtils.scala b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
index 93a181d..29e1082 100755
--- a/core/src/test/scala/unit/kafka/utils/TestUtils.scala
+++ b/core/src/test/scala/unit/kafka/utils/TestUtils.scala
@@ -122,11 +122,7 @@ object TestUtils extends Logging {
   /**
    * Create a temporary file
    */
-  def tempFile(): File = {
-    val f = File.createTempFile("kafka", ".tmp")
-    f.deleteOnExit()
-    f
-  }
+  def tempFile(): File = org.apache.kafka.test.TestUtils.tempFile()
 
   /**
    * Create a temporary file and return an open file channel for this file

http://git-wip-us.apache.org/repos/asf/kafka/blob/e8343e67/streams/src/test/java/org/apache/kafka/streams/state/internals/OffsetCheckpointTest.java
----------------------------------------------------------------------
diff --git a/streams/src/test/java/org/apache/kafka/streams/state/internals/OffsetCheckpointTest.java
b/streams/src/test/java/org/apache/kafka/streams/state/internals/OffsetCheckpointTest.java
index 352e330..0d80cd3 100644
--- a/streams/src/test/java/org/apache/kafka/streams/state/internals/OffsetCheckpointTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/state/internals/OffsetCheckpointTest.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.test.TestUtils;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -32,12 +33,10 @@ public class OffsetCheckpointTest {
 
     private final String topic = "topic";
 
-    private OffsetCheckpoint checkpoint = null;
-
     @Test
     public void testReadWrite() throws IOException {
-        File f = new File("/tmp/kafka-streams/offset_checkpoint.test");
-        checkpoint = new OffsetCheckpoint(f);
+        File f = TestUtils.tempFile();
+        OffsetCheckpoint checkpoint = new OffsetCheckpoint(f);
 
         try {
             Map<TopicPartition, Long> offsets = new HashMap<>();


Mime
View raw message