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 20:10:47 UTC
[kafka] branch 2.8 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 2.8
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.8 by this push:
new 0fc30b5 KAFKA-12747: Fix flakiness in shouldReturnUUIDsWithStringPrefix (#10643)
0fc30b5 is described below
commit 0fc30b5e4320c1cac0024ac2095b8c26aa88a815
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 0568df2..070e978 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