You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by gu...@apache.org on 2021/05/10 19:35:47 UTC

[kafka] branch trunk updated: KAFKA-12747: Fix flakiness in shouldReturnUUIDsWithStringPrefix (#10643)

This is an automated email from the ASF dual-hosted git repository.

guozhang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 25f4ee8  KAFKA-12747: Fix flakiness in shouldReturnUUIDsWithStringPrefix (#10643)
25f4ee8 is described below

commit 25f4ee879cf9e13f586d4d45f9451cf0090e084d
Author: Guozhang Wang <wa...@gmail.com>
AuthorDate: Mon May 10 12:32:51 2021 -0700

    KAFKA-12747: Fix flakiness in shouldReturnUUIDsWithStringPrefix (#10643)
    
    Consecutive UUID generation could result in same prefix.
    
    Reviewers: Josep Prat <jo...@aiven.io>, Anna Sophie Blee-Goldman <ab...@apache.org>
---
 .../kafka/streams/state/internals/RocksDBStoreTest.java       | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBStoreTest.java b/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBStoreTest.java
index 93e65f0..c9e9a8d 100644
--- a/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBStoreTest.java
+++ b/streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBStoreTest.java
@@ -74,6 +74,7 @@ import static org.easymock.EasyMock.isNull;
 import static org.easymock.EasyMock.mock;
 import static org.easymock.EasyMock.notNull;
 import static org.easymock.EasyMock.reset;
+import static org.hamcrest.CoreMatchers.either;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.notNullValue;
@@ -439,6 +440,8 @@ public class RocksDBStoreTest {
         final UUID uuid1 = UUID.randomUUID();
         final UUID uuid2 = UUID.randomUUID();
         final String prefix = uuid1.toString().substring(0, 4);
+        final int numMatches = uuid2.toString().substring(0, 4).equals(prefix) ? 2 : 1;
+
         entries.add(new KeyValue<>(
             new Bytes(uuidSerializer.serialize(null, uuid1)),
             stringSerializer.serialize(null, "a")));
@@ -460,8 +463,12 @@ public class RocksDBStoreTest {
             numberOfKeysReturned++;
         }
 
-        assertThat(numberOfKeysReturned, is(1));
-        assertThat(valuesWithPrefix.get(0), is("a"));
+        assertThat(numberOfKeysReturned, is(numMatches));
+        if (numMatches == 2) {
+            assertThat(valuesWithPrefix.get(0), either(is("a")).or(is("b")));
+        } else {
+            assertThat(valuesWithPrefix.get(0), is("a"));
+        }
     }
 
     @Test