igorbernstein2 commented on code in PR #16939:
URL: https://github.com/apache/beam/pull/16939#discussion_r877199224
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableServiceImplTest.java:
##########
@@ -126,6 +157,426 @@ public void testRead() throws IOException {
verifyMetricWasSet("google.bigtable.v2.ReadRows", "ok", 1);
}
+ /**
+ * This test ensures that protobuf creation and interactions with {@link
BigtableDataClient} work
+ * as expected. This test checks that a single row is returned from the
future.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testReadSingleRangeBelowSegmentLimit() throws Exception {
+ RowSet.Builder ranges = RowSet.newBuilder();
+ ranges.addRowRanges(
+ generateRowRange(
+ generateByteString(DEFAULT_PREFIX, 0),
generateByteString(DEFAULT_PREFIX, 1)));
+
+ FlatRow expectedRow =
FlatRow.newBuilder().withRowKey(ByteString.copyFromUtf8("a")).build();
+
+ when(mockBigtableDataClient.readFlatRows(any(ReadRowsRequest.class),
any()))
+ .thenAnswer(mockReadRowsAnswer(Arrays.asList(expectedRow)));
+
+ BigtableService.Reader underTest =
+ new BigtableServiceImpl.BigtableSegmentReaderImpl(
+ mockSession,
+ TABLE_ID,
+ ranges.build(),
+ SEGMENT_SIZE,
+ DEFAULT_BYTE_SEGMENT_SIZE,
+ RowFilter.getDefaultInstance(),
+ mockCallMetric);
+
+ underTest.start();
+ Assert.assertEquals(FlatRowConverter.convert(expectedRow),
underTest.getCurrentRow());
+ Assert.assertFalse(underTest.advance());
+ underTest.close();
+
+ Mockito.verify(mockCallMetric, Mockito.times(2)).call("ok");
+ }
+
+ /**
+ * This test ensures that all the rows are properly added to the buffer and
read. This example
+ * uses a single range with SEGMENT_SIZE*2+1 rows. Range: [b00000, b00001,
... b00199, b00200)
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testReadSingleRangeAboveSegmentLimit() throws IOException {
+ RowSet.Builder ranges = RowSet.newBuilder();
+ ranges.addRowRanges(
+ generateRowRange(
+ generateByteString(DEFAULT_PREFIX, 0),
+ generateByteString(DEFAULT_PREFIX, SEGMENT_SIZE * 2)));
+
+ OngoingStubbing<?> stub =
+ when(mockBigtableDataClient.readFlatRows(any(ReadRowsRequest.class),
any()));
+ List<List<FlatRow>> expectedResults =
+ ImmutableList.of(
+ generateSegmentResult(DEFAULT_PREFIX, 0, SEGMENT_SIZE),
+ generateSegmentResult(DEFAULT_PREFIX, SEGMENT_SIZE, SEGMENT_SIZE),
+ ImmutableList.of());
+ expectRowResults(stub, expectedResults);
+
+ BigtableService.Reader underTest =
+ new BigtableServiceImpl.BigtableSegmentReaderImpl(
+ mockSession,
+ TABLE_ID,
+ ranges.build(),
+ SEGMENT_SIZE,
+ DEFAULT_BYTE_SEGMENT_SIZE,
+ RowFilter.getDefaultInstance(),
+ mockCallMetric);
+
+ List<Row> actualResults = new ArrayList<>();
+ Assert.assertTrue(underTest.start());
+ do {
+ actualResults.add(underTest.getCurrentRow());
+ } while (underTest.advance());
+
+ Assert.assertEquals(
+ expectedResults.stream()
+ .flatMap(Collection::stream)
+ .map(i -> FlatRowConverter.convert(i))
+ .collect(Collectors.toList()),
+ actualResults);
+ underTest.close();
+ Mockito.verify(mockCallMetric, Mockito.times(3)).call("ok");
+ }
+
+ /**
+ * This test ensures that all the rows are properly added to the buffer and
read. This example
+ * uses two ranges with SEGMENT_SIZE rows. The buffer should be refilled
twice and ReadRowsAsync
+ * should be called three times. The last rpc call should return zero rows.
The following test
+ * follows this example: FirstRange: [b00000,b00001,...,b00099,b00100)
SecondRange:
+ * [b00100,b00101,...,b00199,b00200)
+ *
+ * @throws IOException
Review Comment:
this is stale
##########
sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigtable/BigtableServiceImplTest.java:
##########
@@ -126,6 +157,426 @@ public void testRead() throws IOException {
verifyMetricWasSet("google.bigtable.v2.ReadRows", "ok", 1);
}
+ /**
+ * This test ensures that protobuf creation and interactions with {@link
BigtableDataClient} work
+ * as expected. This test checks that a single row is returned from the
future.
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testReadSingleRangeBelowSegmentLimit() throws Exception {
+ RowSet.Builder ranges = RowSet.newBuilder();
+ ranges.addRowRanges(
+ generateRowRange(
+ generateByteString(DEFAULT_PREFIX, 0),
generateByteString(DEFAULT_PREFIX, 1)));
+
+ FlatRow expectedRow =
FlatRow.newBuilder().withRowKey(ByteString.copyFromUtf8("a")).build();
+
+ when(mockBigtableDataClient.readFlatRows(any(ReadRowsRequest.class),
any()))
+ .thenAnswer(mockReadRowsAnswer(Arrays.asList(expectedRow)));
+
+ BigtableService.Reader underTest =
+ new BigtableServiceImpl.BigtableSegmentReaderImpl(
+ mockSession,
+ TABLE_ID,
+ ranges.build(),
+ SEGMENT_SIZE,
+ DEFAULT_BYTE_SEGMENT_SIZE,
+ RowFilter.getDefaultInstance(),
+ mockCallMetric);
+
+ underTest.start();
+ Assert.assertEquals(FlatRowConverter.convert(expectedRow),
underTest.getCurrentRow());
+ Assert.assertFalse(underTest.advance());
+ underTest.close();
+
+ Mockito.verify(mockCallMetric, Mockito.times(2)).call("ok");
+ }
+
+ /**
+ * This test ensures that all the rows are properly added to the buffer and
read. This example
+ * uses a single range with SEGMENT_SIZE*2+1 rows. Range: [b00000, b00001,
... b00199, b00200)
+ *
+ * @throws IOException
Review Comment:
this is stale
--
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]