-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-14890] [tests] Add missing test harnesses for broadcast functions #10286
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 6484be5 (Wed Dec 04 15:16:52 UTC 2019) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. 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 Bot commandsThe @flinkbot bot supports the following commands:
|
Thanks for your contribution! I think this mixes up to (potentially) orthogonal issues:
I would not be opposed to fixing both issues, but they should be considered separately (at least separate commits). If we want to fix 1. we should also add convenience methods for the other user functions but that seems to be a bigger undertaking. Also, we should have tests for newly added code. |
fbb2dfa
to
0082506
Compare
@aljoscha |
2d8039c
to
76da268
Compare
|
||
// --- ProcessFunction --- | ||
public static <IN, OUT> | ||
OneInputStreamOperatorTestHarness<IN, OUT> getInitializedTestHarness( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer method names like forProcessFunction()
, forKeyedProcessFunction()
and so on.
* and watermarks into the operator. {@link java.util.Deque}s containing the emitted elements and | ||
* watermarks can be retrieved. They are safe to be modified. | ||
*/ | ||
public class CoBroadcastWithKeyedOperatorTestHarness<K, IN1, IN2, OUT> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer KeyedBroadcastOperatorTestHarness
(and BroadcastOperatorTestHarness
for the other one). These names are more generic and we don't have to tie the implementation to CoBroadcastWithKeyedOperator
, you could put any operator in one of these harnesses.
76da268
to
a5ba7d7
Compare
Addressed the comments. One question - I have nothing smart to say in the javadocs about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The utility functions look very good now! ☕Could you please also add a simple unit test that checks each of the functions. Pushing in an element and verifying the result should be enough here.
And please change the titles of the PRs to include [FLINK-14890]
at the beginning.
Regarding the exceptions, I also don't have anything clever to say. We could even think about wrapping them in a RuntimeException
and not adding them to the method signature.
import org.apache.flink.streaming.api.operators.co.CoBroadcastWithNonKeyedOperator; | ||
|
||
/** | ||
* A test harness for testing a {@link CoBroadcastWithNonKeyedOperator}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would relax this constraint and maybe say A test harness for testing a {@link TwoInputStreamOperator} in a broadcast context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relaxing this constraint and switching to TwoInputStreamOperator
would prevent access to the BroadcastState
via the current method getBroadcastState()
in the new test harnesses. It seemed to me like this ability would be handy from the user perspective. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code below, i.e.
twoInputOperator.getOperatorStateBackend().getBroadcastState(stateDescriptor);
works just as well on a regular TwoInputStreamOperator
. Is that what you're referring to?
private final CoBroadcastWithNonKeyedOperator<IN1, IN2, OUT> twoInputOperator; | ||
|
||
public BroadcastOperatorTestHarness( | ||
CoBroadcastWithNonKeyedOperator<IN1, IN2, OUT> operator, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, this could be TwoInputStreamOperator
.
|
||
|
||
/** | ||
* A test harness for testing a {@link CoBroadcastWithKeyedOperator}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for the other operator.
I was also initially thinking about wrapping it into a |
a5ba7d7
to
c14d233
Compare
c14d233
to
6484be5
Compare
Thanks! I merged this and put some minor changes on top. 👌 |
What is the purpose of the change
Adds missing test harnesses for broadcast functions
Brief change log
Two new test harnesses are added - one for keyed one for non-keyed broadcast functions.
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation