chia7712 commented on a change in pull request #9888:
URL: https://github.com/apache/kafka/pull/9888#discussion_r559574891
##########
File path:
streams/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java
##########
@@ -198,21 +248,27 @@ public void
shouldAddAndRemoveStreamThreadsWhileKeepingNamesCorrect() throws Exc
.toArray(),
equalTo(new String[] {"1", "2", "3"})
);
- waitForApplicationState(Collections.singletonList(kafkaStreams),
KafkaStreams.State.RUNNING, DEFAULT_DURATION);
+ assertThat(waitForTransitionFromRebalancingToRunning(), is(true));
oldThreadCount = kafkaStreams.localThreadsMetadata().size();
+ stateTransitionHistory.clear();
+ // remove a thread
Review comment:
unnecessary comment
##########
File path:
streams/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java
##########
@@ -119,37 +157,44 @@ public void shouldAddStreamThread() throws Exception {
.sorted().toArray(),
equalTo(new String[] {"1", "2", "3"})
);
- waitForApplicationState(Collections.singletonList(kafkaStreams),
KafkaStreams.State.REBALANCING, DEFAULT_DURATION);
- waitForApplicationState(Collections.singletonList(kafkaStreams),
KafkaStreams.State.RUNNING, DEFAULT_DURATION);
+
+ assertThat(waitForTransitionFromRebalancingToRunning(), is(true));
Review comment:
It seems to me the method
```waitForTransitionFromRebalancingToRunning``` can do the assert as well
because we always call
```assertThat(waitForTransitionFromRebalancingToRunning(), is(true)``` in this
test.
##########
File path:
streams/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java
##########
@@ -90,24 +91,61 @@ public void setup() {
);
}
+ private void startStreamsAndWaitForRunning(final KafkaStreams
kafkaStreams) throws InterruptedException {
+ kafkaStreams.start();
+ waitForRunning();
+ }
+
@After
public void teardown() throws IOException {
+ stateTransitionHistory.clear();
Review comment:
This is unnecessary as junit always create a new test class for each
test case.
##########
File path:
streams/src/test/java/org/apache/kafka/streams/integration/AdjustStreamThreadCountTest.java
##########
@@ -198,21 +248,27 @@ public void
shouldAddAndRemoveStreamThreadsWhileKeepingNamesCorrect() throws Exc
.toArray(),
equalTo(new String[] {"1", "2", "3"})
);
- waitForApplicationState(Collections.singletonList(kafkaStreams),
KafkaStreams.State.RUNNING, DEFAULT_DURATION);
+ assertThat(waitForTransitionFromRebalancingToRunning(), is(true));
oldThreadCount = kafkaStreams.localThreadsMetadata().size();
+ stateTransitionHistory.clear();
+ // remove a thread
final Optional<String> removedThread =
kafkaStreams.removeStreamThread();
assertThat(removedThread, not(Optional.empty()));
assertThat(kafkaStreams.localThreadsMetadata().size(),
equalTo(oldThreadCount - 1));
+ assertThat(waitForTransitionFromRebalancingToRunning(), is(true));
+
+ stateTransitionHistory.clear();
+ // add a new thread again
Review comment:
unnecessary comment
----------------------------------------------------------------
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]