-
Notifications
You must be signed in to change notification settings - Fork 14k
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-4648: Improve test coverage StreamTask #2451
Conversation
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
LGTM |
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.
Overall LGTM
@Test(expected = IllegalStateException.class) | ||
public void shouldThrowIllegalStateExceptionIfCurrentNodeIsNotNullWhenPunctuateCalled() throws Exception { | ||
((ProcessorContextImpl) task.processorContext()).setCurrentNode(processor); | ||
task.punctuate(processor, 10); |
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.
wrap with try-catch
instead of expected
annotation -- more than one line test.
@SuppressWarnings("unchecked") | ||
@Test | ||
public void shouldCloseAllProcessorNodesWhenExceptionsRaised() throws Exception { | ||
final MockSourceNode processorNode = new MockSourceNode(topic1, intDeserializer, intDeserializer) { |
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.
Unify "create task" code with shouldThrowExceptionIfAnyExceptionsRaisedDuringCloseTopology
-- it's almost the same and both test cases can use the same topology structure.
resolved merge conflicts and addressed feedback. @guozhangwang can you please merge? |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
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.
Minor comments, otherwise LGTM.
final StreamTask streamTask = new StreamTask(new TaskId(0, 0), "applicationId", partitions, | ||
topology, consumer, restoreStateConsumer, config, streamsMetrics, stateDirectory, new ThreadCache("testCache", 0, streamsMetrics), new MockTime(), recordCollector); | ||
|
||
task = new StreamTask(taskId00, applicationId, partitions, |
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.
Could we just initialize the task in setUp
with the testCache so that we do not need to explicit re-initialize it here? If not we need to at least close the task before re-initialize it.
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.
It needs the topology that is constructed just above, so no.
@SuppressWarnings("unchecked") | ||
@Test | ||
public void shouldThrowExceptionIfAnyExceptionsRaisedDuringCloseTopology() throws Exception { | ||
task = createTaskThatThrowsExceptionOnClose(); |
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.
Should we close the task first before re-initialize it to another StreamTask? Ditto below.
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.
it doesn't really matter. It is not like the topology has created any state stores, but if it makes you feel better...
final List<ProcessorNode> processorNodes = Arrays.asList(processorNode, processor, source1, source2); | ||
final Map<String, SourceNode> sourceNodes | ||
= Collections.<String, SourceNode>singletonMap(topic1[0], processorNode); | ||
final ProcessorTopology topology = new ProcessorTopology(processorNodes, |
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.
Could we reuse the class's own private topology here?
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.
No - the topology is different.
updated |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
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.
Merged to trunk.
Provide test coverage for exception paths in:
schedule()
,closeTopology()
, andpunctuate()