Skip to content

Commit 25f4ee8

Browse files
authored
KAFKA-12747: Fix flakiness in shouldReturnUUIDsWithStringPrefix (#10643)
Consecutive UUID generation could result in same prefix. Reviewers: Josep Prat <[email protected]>, Anna Sophie Blee-Goldman <[email protected]>
1 parent 8a574ad commit 25f4ee8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

streams/src/test/java/org/apache/kafka/streams/state/internals/RocksDBStoreTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import static org.easymock.EasyMock.mock;
7575
import static org.easymock.EasyMock.notNull;
7676
import static org.easymock.EasyMock.reset;
77+
import static org.hamcrest.CoreMatchers.either;
7778
import static org.hamcrest.CoreMatchers.equalTo;
7879
import static org.hamcrest.CoreMatchers.is;
7980
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -439,6 +440,8 @@ public void shouldReturnUUIDsWithStringPrefix() {
439440
final UUID uuid1 = UUID.randomUUID();
440441
final UUID uuid2 = UUID.randomUUID();
441442
final String prefix = uuid1.toString().substring(0, 4);
443+
final int numMatches = uuid2.toString().substring(0, 4).equals(prefix) ? 2 : 1;
444+
442445
entries.add(new KeyValue<>(
443446
new Bytes(uuidSerializer.serialize(null, uuid1)),
444447
stringSerializer.serialize(null, "a")));
@@ -460,8 +463,12 @@ public void shouldReturnUUIDsWithStringPrefix() {
460463
numberOfKeysReturned++;
461464
}
462465

463-
assertThat(numberOfKeysReturned, is(1));
464-
assertThat(valuesWithPrefix.get(0), is("a"));
466+
assertThat(numberOfKeysReturned, is(numMatches));
467+
if (numMatches == 2) {
468+
assertThat(valuesWithPrefix.get(0), either(is("a")).or(is("b")));
469+
} else {
470+
assertThat(valuesWithPrefix.get(0), is("a"));
471+
}
465472
}
466473

467474
@Test

0 commit comments

Comments
 (0)