You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/07/08 08:20:52 UTC
[GitHub] [flink] dannycranmer opened a new pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
dannycranmer opened a new pull request #12850:
URL: https://github.com/apache/flink/pull/12850
## What is the purpose of the change
Improved test coverage for existing `FlinkKinesisConsumer` polling consumption implementation (`ShardConsumer`).
## Brief change log
- Add tests for consumption of aggregated records
- Add tests for resuming consumption from an aggregated sub-sequence number
- Add assertions on `ShardIteratorType` for existing `ShardConsumerTest` methods
- Existing code in `ShardConsumerTest` had high duplication, this has been extracted to a method
Note: Source code has not be modified, only test code.
## Verifying this change
This change added tests and can be verified as follows:
- Running unit tests for `flink/flink-connectors/flink-connector-kinesis`, specifically:
-- `ShardConsumerTest`
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): yes
-- I have added a **test scoped** dependency on [amazon-kinesis-aggregator](https://github.com/awslabs/kinesis-aggregation) to perform record aggregation
-- License: [Apache 2.0](https://github.com/awslabs/kinesis-aggregation/blob/master/LICENSE.txt)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): no
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4823",
"triggerID" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811) Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329)
* fb8632b7371a8130ce4a7e9d0e60e5eb068bef43 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4823)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] xiaolong-sn commented on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
xiaolong-sn commented on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-656025637
> Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
> to review your pull request. We will use this comment to track the progress of the review.
>
> ## Automated Checks
> Last check on commit [d2297eb](https://github.com/apache/flink/commit/d2297eb49d52eb26e753feb4d61331d26dc2ed62) (Wed Jul 08 08:26:59 UTC 2020)
>
> **Warnings:**
>
> * **1 pom.xml files were touched**: Check for build and licensing issues.
> * No documentation files were touched! Remember to keep the Flink docs up to date!
>
> Mention the bot in a comment to re-run the automated checks.
>
> ## Review Progress
> * ❓ 1. The [description] looks good.
> * ❓ 2. There is [consensus] that the contribution should go into to Flink.
> * ❓ 3. Needs [attention] from.
> * ❓ 4. The change fits into the overall [architecture].
> * ❓ 5. Overall code [quality] is good.
>
> Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.
>
> Bot commands
@flinkbot approve description
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] xiaolong-sn removed a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
xiaolong-sn removed a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-656016232
@flinkbot approve description
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4823",
"triggerID" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* fb8632b7371a8130ce4a7e9d0e60e5eb068bef43 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4823)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] tzulitai commented on a change in pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
tzulitai commented on a change in pull request #12850:
URL: https://github.com/apache/flink/pull/12850#discussion_r458507237
##########
File path: flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/internals/ShardConsumerTest.java
##########
@@ -51,148 +61,123 @@
@Test
public void testMetricsReporting() {
- StreamShardHandle fakeToBeConsumedShard = getMockStreamShard("fakeStream", 0);
-
- LinkedList<KinesisStreamShardState> subscribedShardsStateUnderTest = new LinkedList<>();
- subscribedShardsStateUnderTest.add(
- new KinesisStreamShardState(
- KinesisDataFetcher.convertToStreamShardMetadata(fakeToBeConsumedShard),
- fakeToBeConsumedShard,
- new SequenceNumber("fakeStartingState")));
+ KinesisProxyInterface kinesis = FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(500, 5, 500);
- TestSourceContext<String> sourceContext = new TestSourceContext<>();
-
- KinesisDeserializationSchemaWrapper<String> deserializationSchema = new KinesisDeserializationSchemaWrapper<>(
- new SimpleStringSchema());
- TestableKinesisDataFetcher<String> fetcher =
- new TestableKinesisDataFetcher<>(
- Collections.singletonList("fakeStream"),
- sourceContext,
- new Properties(),
- deserializationSchema,
- 10,
- 2,
- new AtomicReference<>(),
- subscribedShardsStateUnderTest,
- KinesisDataFetcher.createInitialSubscribedStreamsToLastDiscoveredShardsState(Collections.singletonList("fakeStream")),
- Mockito.mock(KinesisProxyInterface.class));
+ ShardMetricsReporter metrics = assertNumberOfMessagesReceivedFromKinesis(500, kinesis, fakeSequenceNumber());
+ assertEquals(500, metrics.getMillisBehindLatest());
+ assertEquals(10000, metrics.getMaxNumberOfRecordsPerFetch());
+ }
- ShardMetricsReporter shardMetricsReporter = new ShardMetricsReporter();
- long millisBehindLatest = 500L;
- new ShardConsumer<>(
- fetcher,
- 0,
- subscribedShardsStateUnderTest.get(0).getStreamShardHandle(),
- subscribedShardsStateUnderTest.get(0).getLastProcessedSequenceNum(),
- FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(1000, 9, millisBehindLatest),
- shardMetricsReporter,
- deserializationSchema)
- .run();
+ @Test
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithStartingSequenceNumber() throws Exception {
+ KinesisProxyInterface kinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(1000, 9, 500L));
- // the millisBehindLatest metric should have been reported
- assertEquals(millisBehindLatest, shardMetricsReporter.getMillisBehindLatest());
+ assertNumberOfMessagesReceivedFromKinesis(1000, kinesis, fakeSequenceNumber());
+ verify(kinesis).getShardIterator(any(), eq("AFTER_SEQUENCE_NUMBER"), eq("fakeStartingState"));
}
@Test
- public void testCorrectNumOfCollectedRecordsAndUpdatedState() {
- StreamShardHandle fakeToBeConsumedShard = getMockStreamShard("fakeStream", 0);
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithStartingSequenceSentinelTimestamp() throws Exception {
+ String format = "yyyy-MM-dd'T'HH:mm";
+ String timestamp = "2020-07-02T09:14";
+ Date expectedTimestamp = new SimpleDateFormat(format).parse(timestamp);
- LinkedList<KinesisStreamShardState> subscribedShardsStateUnderTest = new LinkedList<>();
- subscribedShardsStateUnderTest.add(
- new KinesisStreamShardState(KinesisDataFetcher.convertToStreamShardMetadata(fakeToBeConsumedShard),
- fakeToBeConsumedShard, new SequenceNumber("fakeStartingState")));
+ Properties consumerProperties = new Properties();
+ consumerProperties.setProperty(STREAM_INITIAL_TIMESTAMP, timestamp);
+ consumerProperties.setProperty(STREAM_TIMESTAMP_DATE_FORMAT, format);
+ SequenceNumber sequenceNumber = SENTINEL_AT_TIMESTAMP_SEQUENCE_NUM.get();
- TestSourceContext<String> sourceContext = new TestSourceContext<>();
+ KinesisProxyInterface kinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(10, 1, 0));
- KinesisDeserializationSchemaWrapper<String> deserializationSchema = new KinesisDeserializationSchemaWrapper<>(
- new SimpleStringSchema());
- TestableKinesisDataFetcher<String> fetcher =
- new TestableKinesisDataFetcher<>(
- Collections.singletonList("fakeStream"),
- sourceContext,
- new Properties(),
- deserializationSchema,
- 10,
- 2,
- new AtomicReference<>(),
- subscribedShardsStateUnderTest,
- KinesisDataFetcher.createInitialSubscribedStreamsToLastDiscoveredShardsState(Collections.singletonList("fakeStream")),
- Mockito.mock(KinesisProxyInterface.class));
+ assertNumberOfMessagesReceivedFromKinesis(10, kinesis, sequenceNumber, consumerProperties);
+ verify(kinesis).getShardIterator(any(), eq("AT_TIMESTAMP"), eq(expectedTimestamp));
+ }
- int shardIndex = fetcher.registerNewSubscribedShardState(subscribedShardsStateUnderTest.get(0));
- new ShardConsumer<>(
- fetcher,
- shardIndex,
- subscribedShardsStateUnderTest.get(0).getStreamShardHandle(),
- subscribedShardsStateUnderTest.get(0).getLastProcessedSequenceNum(),
- FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(1000, 9, 500L),
- new ShardMetricsReporter(),
- deserializationSchema)
- .run();
+ @Test
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithStartingSequenceSentinelEarliest() throws Exception {
+ SequenceNumber sequenceNumber = SENTINEL_EARLIEST_SEQUENCE_NUM.get();
- assertEquals(1000, sourceContext.getCollectedOutputs().size());
- assertEquals(
- SentinelSequenceNumber.SENTINEL_SHARD_ENDING_SEQUENCE_NUM.get(),
- subscribedShardsStateUnderTest.get(0).getLastProcessedSequenceNum());
+ KinesisProxyInterface kinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(50, 2, 0));
+
+ assertNumberOfMessagesReceivedFromKinesis(50, kinesis, sequenceNumber);
+ verify(kinesis).getShardIterator(any(), eq("TRIM_HORIZON"), eq(null));
}
@Test
public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithUnexpectedExpiredIterator() {
- StreamShardHandle fakeToBeConsumedShard = getMockStreamShard("fakeStream", 0);
+ KinesisProxyInterface kinesis = FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCallsWithUnexpectedExpiredIterator(1000, 9, 7, 500L);
- LinkedList<KinesisStreamShardState> subscribedShardsStateUnderTest = new LinkedList<>();
- subscribedShardsStateUnderTest.add(
- new KinesisStreamShardState(KinesisDataFetcher.convertToStreamShardMetadata(fakeToBeConsumedShard),
- fakeToBeConsumedShard, new SequenceNumber("fakeStartingState")));
+ // Get a total of 1000 records with 9 getRecords() calls,
+ // and the 7th getRecords() call will encounter an unexpected expired shard iterator
+ assertNumberOfMessagesReceivedFromKinesis(1000, kinesis, fakeSequenceNumber());
+ }
- TestSourceContext<String> sourceContext = new TestSourceContext<>();
+ @Test
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithAdaptiveReads() {
+ Properties consumerProperties = new Properties();
+ consumerProperties.setProperty("flink.shard.adaptivereads", "true");
Review comment:
Is there a constant for this?
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655371523
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit d2297eb49d52eb26e753feb4d61331d26dc2ed62 (Wed Jul 08 08:26:59 UTC 2020)
**Warnings:**
* **1 pom.xml files were touched**: Check for build and licensing issues.
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4823",
"triggerID" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811) Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329)
* fb8632b7371a8130ce4a7e9d0e60e5eb068bef43 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4823)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] xiaolong-sn commented on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
xiaolong-sn commented on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-656016232
@flinkbot approve description
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] dannycranmer commented on a change in pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
dannycranmer commented on a change in pull request #12850:
URL: https://github.com/apache/flink/pull/12850#discussion_r459469797
##########
File path: flink-connectors/flink-connector-kinesis/src/test/java/org/apache/flink/streaming/connectors/kinesis/internals/ShardConsumerTest.java
##########
@@ -51,148 +61,123 @@
@Test
public void testMetricsReporting() {
- StreamShardHandle fakeToBeConsumedShard = getMockStreamShard("fakeStream", 0);
-
- LinkedList<KinesisStreamShardState> subscribedShardsStateUnderTest = new LinkedList<>();
- subscribedShardsStateUnderTest.add(
- new KinesisStreamShardState(
- KinesisDataFetcher.convertToStreamShardMetadata(fakeToBeConsumedShard),
- fakeToBeConsumedShard,
- new SequenceNumber("fakeStartingState")));
+ KinesisProxyInterface kinesis = FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(500, 5, 500);
- TestSourceContext<String> sourceContext = new TestSourceContext<>();
-
- KinesisDeserializationSchemaWrapper<String> deserializationSchema = new KinesisDeserializationSchemaWrapper<>(
- new SimpleStringSchema());
- TestableKinesisDataFetcher<String> fetcher =
- new TestableKinesisDataFetcher<>(
- Collections.singletonList("fakeStream"),
- sourceContext,
- new Properties(),
- deserializationSchema,
- 10,
- 2,
- new AtomicReference<>(),
- subscribedShardsStateUnderTest,
- KinesisDataFetcher.createInitialSubscribedStreamsToLastDiscoveredShardsState(Collections.singletonList("fakeStream")),
- Mockito.mock(KinesisProxyInterface.class));
+ ShardMetricsReporter metrics = assertNumberOfMessagesReceivedFromKinesis(500, kinesis, fakeSequenceNumber());
+ assertEquals(500, metrics.getMillisBehindLatest());
+ assertEquals(10000, metrics.getMaxNumberOfRecordsPerFetch());
+ }
- ShardMetricsReporter shardMetricsReporter = new ShardMetricsReporter();
- long millisBehindLatest = 500L;
- new ShardConsumer<>(
- fetcher,
- 0,
- subscribedShardsStateUnderTest.get(0).getStreamShardHandle(),
- subscribedShardsStateUnderTest.get(0).getLastProcessedSequenceNum(),
- FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(1000, 9, millisBehindLatest),
- shardMetricsReporter,
- deserializationSchema)
- .run();
+ @Test
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithStartingSequenceNumber() throws Exception {
+ KinesisProxyInterface kinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(1000, 9, 500L));
- // the millisBehindLatest metric should have been reported
- assertEquals(millisBehindLatest, shardMetricsReporter.getMillisBehindLatest());
+ assertNumberOfMessagesReceivedFromKinesis(1000, kinesis, fakeSequenceNumber());
+ verify(kinesis).getShardIterator(any(), eq("AFTER_SEQUENCE_NUMBER"), eq("fakeStartingState"));
}
@Test
- public void testCorrectNumOfCollectedRecordsAndUpdatedState() {
- StreamShardHandle fakeToBeConsumedShard = getMockStreamShard("fakeStream", 0);
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithStartingSequenceSentinelTimestamp() throws Exception {
+ String format = "yyyy-MM-dd'T'HH:mm";
+ String timestamp = "2020-07-02T09:14";
+ Date expectedTimestamp = new SimpleDateFormat(format).parse(timestamp);
- LinkedList<KinesisStreamShardState> subscribedShardsStateUnderTest = new LinkedList<>();
- subscribedShardsStateUnderTest.add(
- new KinesisStreamShardState(KinesisDataFetcher.convertToStreamShardMetadata(fakeToBeConsumedShard),
- fakeToBeConsumedShard, new SequenceNumber("fakeStartingState")));
+ Properties consumerProperties = new Properties();
+ consumerProperties.setProperty(STREAM_INITIAL_TIMESTAMP, timestamp);
+ consumerProperties.setProperty(STREAM_TIMESTAMP_DATE_FORMAT, format);
+ SequenceNumber sequenceNumber = SENTINEL_AT_TIMESTAMP_SEQUENCE_NUM.get();
- TestSourceContext<String> sourceContext = new TestSourceContext<>();
+ KinesisProxyInterface kinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(10, 1, 0));
- KinesisDeserializationSchemaWrapper<String> deserializationSchema = new KinesisDeserializationSchemaWrapper<>(
- new SimpleStringSchema());
- TestableKinesisDataFetcher<String> fetcher =
- new TestableKinesisDataFetcher<>(
- Collections.singletonList("fakeStream"),
- sourceContext,
- new Properties(),
- deserializationSchema,
- 10,
- 2,
- new AtomicReference<>(),
- subscribedShardsStateUnderTest,
- KinesisDataFetcher.createInitialSubscribedStreamsToLastDiscoveredShardsState(Collections.singletonList("fakeStream")),
- Mockito.mock(KinesisProxyInterface.class));
+ assertNumberOfMessagesReceivedFromKinesis(10, kinesis, sequenceNumber, consumerProperties);
+ verify(kinesis).getShardIterator(any(), eq("AT_TIMESTAMP"), eq(expectedTimestamp));
+ }
- int shardIndex = fetcher.registerNewSubscribedShardState(subscribedShardsStateUnderTest.get(0));
- new ShardConsumer<>(
- fetcher,
- shardIndex,
- subscribedShardsStateUnderTest.get(0).getStreamShardHandle(),
- subscribedShardsStateUnderTest.get(0).getLastProcessedSequenceNum(),
- FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(1000, 9, 500L),
- new ShardMetricsReporter(),
- deserializationSchema)
- .run();
+ @Test
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithStartingSequenceSentinelEarliest() throws Exception {
+ SequenceNumber sequenceNumber = SENTINEL_EARLIEST_SEQUENCE_NUM.get();
- assertEquals(1000, sourceContext.getCollectedOutputs().size());
- assertEquals(
- SentinelSequenceNumber.SENTINEL_SHARD_ENDING_SEQUENCE_NUM.get(),
- subscribedShardsStateUnderTest.get(0).getLastProcessedSequenceNum());
+ KinesisProxyInterface kinesis = spy(FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCalls(50, 2, 0));
+
+ assertNumberOfMessagesReceivedFromKinesis(50, kinesis, sequenceNumber);
+ verify(kinesis).getShardIterator(any(), eq("TRIM_HORIZON"), eq(null));
}
@Test
public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithUnexpectedExpiredIterator() {
- StreamShardHandle fakeToBeConsumedShard = getMockStreamShard("fakeStream", 0);
+ KinesisProxyInterface kinesis = FakeKinesisBehavioursFactory.totalNumOfRecordsAfterNumOfGetRecordsCallsWithUnexpectedExpiredIterator(1000, 9, 7, 500L);
- LinkedList<KinesisStreamShardState> subscribedShardsStateUnderTest = new LinkedList<>();
- subscribedShardsStateUnderTest.add(
- new KinesisStreamShardState(KinesisDataFetcher.convertToStreamShardMetadata(fakeToBeConsumedShard),
- fakeToBeConsumedShard, new SequenceNumber("fakeStartingState")));
+ // Get a total of 1000 records with 9 getRecords() calls,
+ // and the 7th getRecords() call will encounter an unexpected expired shard iterator
+ assertNumberOfMessagesReceivedFromKinesis(1000, kinesis, fakeSequenceNumber());
+ }
- TestSourceContext<String> sourceContext = new TestSourceContext<>();
+ @Test
+ public void testCorrectNumOfCollectedRecordsAndUpdatedStateWithAdaptiveReads() {
+ Properties consumerProperties = new Properties();
+ consumerProperties.setProperty("flink.shard.adaptivereads", "true");
Review comment:
Yep, switched to the constant
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] xiaolong-sn removed a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
xiaolong-sn removed a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-656025637
> Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
> to review your pull request. We will use this comment to track the progress of the review.
>
> ## Automated Checks
> Last check on commit [d2297eb](https://github.com/apache/flink/commit/d2297eb49d52eb26e753feb4d61331d26dc2ed62) (Wed Jul 08 08:26:59 UTC 2020)
>
> **Warnings:**
>
> * **1 pom.xml files were touched**: Check for build and licensing issues.
> * No documentation files were touched! Remember to keep the Flink docs up to date!
>
> Mention the bot in a comment to re-run the automated checks.
>
> ## Review Progress
> * ❓ 1. The [description] looks good.
> * ❓ 2. There is [consensus] that the contribution should go into to Flink.
> * ❓ 3. Needs [attention] from.
> * ❓ 4. The change fits into the overall [architecture].
> * ❓ 5. Overall code [quality] is good.
>
> Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.
>
> Bot commands
@flinkbot approve description
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] dannycranmer commented on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
dannycranmer commented on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-657491318
@flinkbot run azure
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] tzulitai commented on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
tzulitai commented on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-671803671
Merging this now ...
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] asfgit closed pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #12850:
URL: https://github.com/apache/flink/pull/12850
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329) Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "fb8632b7371a8130ce4a7e9d0e60e5eb068bef43",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811) Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329)
* fb8632b7371a8130ce4a7e9d0e60e5eb068bef43 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #12850: [FLINK-18483][kinesis] Test coverage improvements for FlinkKinesisConsumer/ShardConsumer
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #12850:
URL: https://github.com/apache/flink/pull/12850#issuecomment-655383993
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"triggerType" : "PUSH"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
}, {
"hash" : "d2297eb49d52eb26e753feb4d61331d26dc2ed62",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329",
"triggerID" : "657491318",
"triggerType" : "MANUAL"
} ]
}-->
## CI report:
* d2297eb49d52eb26e753feb4d61331d26dc2ed62 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4811) Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=4329)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
----------------------------------------------------------------
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:
users@infra.apache.org