acrites commented on code in PR #41020:
URL: https://github.com/apache/beam/pull/41020#discussion_r4484609295
##########
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:
Addressed in the next commit.
--
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]