github-actions[bot] commented on code in PR #41020:
URL: https://github.com/apache/beam/pull/41020#discussion_r4484449662
##########
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/state/StateFetchingIteratorsTest.java:
##########
@@ -529,4 +530,85 @@ private void testFetch(ByteString... expected) {
assertEquals(Arrays.asList(expected), results);
}
}
+
+ /** Tests for {@link StateFetchingIterators#readAllAndDecodeStartingFrom}
without caching. */
+ @RunWith(JUnit4.class)
+ public static class UncachedStateIterableTest {
+
+ @Test
+ public void testEmpty() throws Exception {
+ testFetch(4);
+ }
+
+ @Test
+ public void testNonEmpty() throws Exception {
+ testFetch(4, 0);
+ }
+
+ @Test
+ public void testMultipleElementsPerChunk() throws Exception {
+ testFetch(8, 0, 1, 2, 3, 4, 5);
+ }
+
+ @Test
+ public void testSingleElementPerChunk() throws Exception {
+ testFetch(4, 0, 1, 2, 3, 4, 5);
+ }
+
+ @Test
+ public void testChunkSmallerThanElementSize() throws Exception {
+ testFetch(3, 0, 1, 2, 3, 4, 5);
+ }
+
+ @Test
+ public void testChunkLargerThanElementSize() throws Exception {
+ testFetch(5, 0, 1, 2, 3, 4, 5);
+ }
+
+ @Test
+ public void testIsReadyAndPrefetch() throws Exception {
+ AtomicInteger callCount = new AtomicInteger();
+ BeamFnStateClient fakeStateClient =
+ fakeStateClient(callCount, ByteString.copyFromUtf8("BC"),
ByteString.copyFromUtf8("DEF"));
+ PrefetchableIterable<byte[]> iterable =
+ StateFetchingIterators.readAllAndDecodeStartingFrom(
+ fakeStateClient,
+ StateRequest.getDefaultInstance(),
+ org.apache.beam.sdk.coders.ByteArrayCoder.of());
+ // Not yet iterated or prefetched
+ PrefetchableIterator<byte[]> iterator = iterable.iterator();
+ assertFalse(iterator.isReady());
Review Comment:
**🟡 Medium**: `testIsReadyAndPrefetch` initializes `callCount` and multiple
chunks on `fakeStateClient`, but never calls `iterator.prefetch()` or verifies
`callCount` and `iterator.isReady()` after prefetching. Please complete the
test assertions to verify that `prefetch()` triggers the state request and
makes the iterator ready (and consider importing `ByteArrayCoder` rather than
using the fully qualified name on line 576).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]