-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
KAFKA-6474: Rewrite tests to use new public TopologyTestDriver [cleanup] #4939
Conversation
driver = new TopologyTestDriver(builder.build(), props); | ||
} | ||
|
||
@After | ||
public void cleanup() { | ||
if (driver != null) { |
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.
This should never happen, right? maybe we just don't check it and get an NPE if somehow driver gets set to null after the setup.
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.
Yes, since the driver in always created in @Before
, something would have to be very wrong with a test for the driver to be null. I'll get rid of that check on @After
.
driver = new TopologyTestDriver(builder.build(), props, 0L); | ||
} | ||
|
||
@After | ||
public void cleanup() { | ||
if (driver != null) { |
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.
ditto on (what I think is) the impossibility of this condition being false.
driver = new TopologyTestDriver(builder.build(), props, 0L); | ||
} | ||
|
||
@After | ||
public void cleanup() { | ||
if (driver != null) { |
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.
ditto
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.
LGTM! Sorry for the extra work, but thanks for cleaning this stuff up.
I just had one minor thought that checking for the driver potentially being null should be unnecessary, so maybe we should just take it out. But it's your call.
Thanks again,
-John
@guozhangwang @bbejeck Can you take a look also? These were changes I requested after the last PR got merged. |
No problem @vvcephei . I already knew my way around these classes so implementing your suggestions was fairly straightforward. The code is definitely much clearer now. Thanks! |
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.
Sorry for the late response. Thanks for the follow-up PR @h314to. LGTM.
@h314to, sorry for the bother, but can you rebase this? |
@h314to Could you rebase the PR again so it can be merged? About |
Yes, no problem. I'll squash the commits and rebase on the current trunk. @guozhangwang I'm currently working on migrating the remaining classes from |
* Add method to create test properties to StreamsTestUtils * Make TopologyTestDriver protected constructor package-private * Add comment suggesting the use of TopologyTestDriver to KStreamTestDriver * Cleanup: - GlobalKTableJoinsTest - KGroupedStreamImplTest - KGroupedTableImplTest - KStreamBranchTest - KStreamFilterTest - KStreamFlatMapTest - KStreamFlatMapValuesTest - KStreamForeachTest - KStreamGlobalKTableJoinTest - KStreamGlobalKTableLeftJoinTest - KStreamImplTest - KStreamKStreamJoinTest - KStreamKStreamLeftJoinTest - KStreamGlobalKTableLeftJoinTest - KStreamKTableJoinTest - KStreamKTableLeftJoinTest - KStreamMapTest - KStreamMapValuesTest - KStreamPeekTest - StreamsBuilderTest - KStreamSelectKeyTest - KStreamTransformTest - KStreamTransformValuesTest - KStreamWindowAggregateTest - KTableForeachTest * Address reviewer's comments: - Remove check for null driver in @after
dc57565
to
87ffe7a
Compare
@h314to Thanks for the update @h314to , much appreciated. About deprecating |
@guozhangwang I think the functionality gaps are mostly due to the balance between keeping the For instance, we need to access the |
@h314to Thanks for the information. That makes sense to me. |
Merged to trunk. |
…up] (apache#4939) * Add method to create test properties to StreamsTestUtils * Make TopologyTestDriver protected constructor package-private * Add comment suggesting the use of TopologyTestDriver to KStreamTestDriver * Cleanup: - GlobalKTableJoinsTest - KGroupedStreamImplTest - KGroupedTableImplTest - KStreamBranchTest - KStreamFilterTest - KStreamFlatMapTest - KStreamFlatMapValuesTest - KStreamForeachTest - KStreamGlobalKTableJoinTest - KStreamGlobalKTableLeftJoinTest - KStreamImplTest - KStreamKStreamJoinTest - KStreamKStreamLeftJoinTest - KStreamGlobalKTableLeftJoinTest - KStreamKTableJoinTest - KStreamKTableLeftJoinTest - KStreamMapTest - KStreamMapValuesTest - KStreamPeekTest - StreamsBuilderTest - KStreamSelectKeyTest - KStreamTransformTest - KStreamTransformValuesTest - KStreamWindowAggregateTest - KTableForeachTest Reviewers: John Roesler <john@confluent.io>, Bill Bejeck <bill@confluent.io>, Guozhang Wang <wangguoz@gmail.com>
This implements the suggestions made after the previous PR for KAFKA-6474 was merged.
The majority of changes deals with using try-with-resources and a new method in
StreamsTestUtils
to set the test properties and instantiate theTopologyTestDriver
, thus allowing the removal of the cumbersome@Before
and@After
methods.I also replaced
stringSerde
andintSerde
variables with (almost equally succinct) inline calls toSerdes.String()
andSerdes.Integer()
.