[
https://issues.apache.org/jira/browse/BEAM-8511?focusedWorklogId=344431&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-344431
]
ASF GitHub Bot logged work on BEAM-8511:
----------------------------------------
Author: ASF GitHub Bot
Created on: 15/Nov/19 17:26
Start Date: 15/Nov/19 17:26
Worklog Time Spent: 10m
Work Description: aromanenko-dev commented on pull request #9899:
[BEAM-8511] [WIP] KinesisIO.Read enhanced fanout
URL: https://github.com/apache/beam/pull/9899#discussion_r346926798
##########
File path:
sdks/java/io/kinesis2/src/test/java/org/apache/beam/sdk/io/kinesis2/KinesisIOIT.java
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.io.kinesis2;
+
+import com.amazonaws.regions.Regions;
+import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
+import java.util.Random;
+import org.apache.beam.sdk.io.GenerateSequence;
+import org.apache.beam.sdk.io.common.HashingFn;
+import org.apache.beam.sdk.io.common.TestRow;
+import org.apache.beam.sdk.io.kinesis.KinesisPartitioner;
+import org.apache.beam.sdk.options.PipelineOptionsFactory;
+import org.apache.beam.sdk.testing.PAssert;
+import org.apache.beam.sdk.testing.TestPipeline;
+import org.apache.beam.sdk.transforms.Combine;
+import org.apache.beam.sdk.transforms.Count;
+import org.apache.beam.sdk.transforms.DoFn;
+import org.apache.beam.sdk.transforms.ParDo;
+import org.apache.beam.sdk.values.PCollection;
+import org.joda.time.Duration;
+import org.joda.time.Instant;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.kinesis.common.InitialPositionInStream;
+
+/**
+ * Integration test, that writes and reads data to and from real Kinesis. You
need to provide {@link
+ * KinesisTestOptions} in order to run this.
+ */
+@RunWith(JUnit4.class)
+public class KinesisIOIT implements Serializable {
+ private static int numberOfShards;
+ private static int numberOfRows;
+
+ @Rule public TestPipeline pipelineWrite = TestPipeline.create();
+ @Rule public TestPipeline pipelineRead = TestPipeline.create();
+
+ private static KinesisTestOptions options;
+ private static final Instant now = Instant.now();
+
+ @BeforeClass
+ public static void setup() {
+ PipelineOptionsFactory.register(KinesisTestOptions.class);
+ options =
TestPipeline.testingPipelineOptions().as(KinesisTestOptions.class);
+ numberOfShards = options.getNumberOfShards();
+ numberOfRows = options.getNumberOfRecords();
+ }
+
+ /** Test which write and then read data for a Kinesis stream. */
+ @Test
+ public void testWriteThenRead() {
+ runWrite();
+ runRead();
+ }
+
+ /** Write test dataset into Kinesis stream. */
+ private void runWrite() {
+ pipelineWrite
+ .apply("Generate Sequence", GenerateSequence.from(0).to((long)
numberOfRows))
+ .apply("Prepare TestRows", ParDo.of(new
TestRow.DeterministicallyConstructTestRowFn()))
+ .apply("Prepare Kinesis input records", ParDo.of(new ConvertToBytes()))
+ .apply(
+ "Write to Kinesis",
+ org.apache.beam.sdk.io.kinesis.KinesisIO.write()
+ .withStreamName(options.getAwsKinesisStream())
+ .withPartitioner(new RandomPartitioner())
+ .withAWSClientsProvider(
+ options.getAwsAccessKey(),
+ options.getAwsSecretKey(),
+ Regions.fromName(options.getAwsKinesisRegion())));
+
+ pipelineWrite.run().waitUntilFinish();
+ }
+
+ /** Read test dataset from Kinesis stream. */
+ private void runRead() {
Review comment:
Since we can read messaged using two different modes - pull and subscribe -
then I think we need to have two different Read tests for that.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 344431)
Time Spent: 2h 20m (was: 2h 10m)
> Support for enhanced fan-out in KinesisIO.Read
> ----------------------------------------------
>
> Key: BEAM-8511
> URL: https://issues.apache.org/jira/browse/BEAM-8511
> Project: Beam
> Issue Type: New Feature
> Components: io-java-kinesis
> Reporter: Jonothan Farr
> Assignee: Jonothan Farr
> Priority: Major
> Time Spent: 2h 20m
> Remaining Estimate: 0h
>
> Add support for reading from an enhanced fan-out consumer using KinesisIO.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)