You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/04/28 22:57:07 UTC
[GitHub] [kafka] vvcephei commented on a change in pull request #8578: KAFKA-9875: Make integration tests more resilient
vvcephei commented on a change in pull request #8578:
URL: https://github.com/apache/kafka/pull/8578#discussion_r416969713
##########
File path: streams/src/test/java/org/apache/kafka/streams/integration/GlobalThreadShutDownOrderTest.java
##########
@@ -101,8 +102,8 @@ public void before() throws Exception {
builder = new StreamsBuilder();
createTopics();
streamsConfiguration = new Properties();
- final String applicationId = "global-thread-shutdown-test" + testName.getMethodName();
- streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId);
+ final String safeTestName = safeUniqueTestName(getClass(), testName);
+ streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "app-" + safeTestName);
Review comment:
I've standardized all the usages to be just "app", followed by the generated name, since the generated name contains the same information that we previously hand-wrote into the prefix or suffix. All we really need to do is ensure that the app id won't collide with a group name that we might use in a verification consumer, for example. For that reason, I've never used the generated name "plain", but always scoped it to the usage (app id, group id, input topic, etc.).
It's not super important to apply these ideas universally, but I felt it would make it easier to write more tests like it in the future if I just made a full pass on all the tests to make them all look the same.
##########
File path: streams/src/test/java/org/apache/kafka/streams/integration/LagFetchIntegrationTest.java
##########
@@ -88,16 +89,17 @@
private String stateStoreName;
@Rule
- public TestName name = new TestName();
+ public TestName testName = new TestName();
@Before
public void before() {
- inputTopicName = "input-topic-" + name.getMethodName();
- outputTopicName = "output-topic-" + name.getMethodName();
- stateStoreName = "lagfetch-test-store" + name.getMethodName();
+ final String safeTestName = safeUniqueTestName(getClass(), testName);
+ inputTopicName = "input-topic-" + safeTestName;
+ outputTopicName = "output-topic-" + safeTestName;
+ stateStoreName = "lagfetch-test-store" + safeTestName;
streamsConfiguration = new Properties();
- streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "lag-fetch-" + name.getMethodName());
+ streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "lag-fetch-" + safeTestName);
Review comment:
```suggestion
streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, "app-" + safeTestName);
```
##########
File path: streams/src/test/java/org/apache/kafka/streams/integration/utils/IntegrationTestUtils.java
##########
@@ -145,12 +162,12 @@ public static void cleanStateBeforeTest(final EmbeddedKafkaCluster cluster, fina
}
}
- public static void cleanStateAfterTest(final EmbeddedKafkaCluster cluster, final KafkaStreams driver) {
- driver.cleanUp();
+ public static void quietlyCleanStateAfterTest(final EmbeddedKafkaCluster cluster, final KafkaStreams driver) {
try {
+ driver.cleanUp();
cluster.deleteAllTopicsAndWait(DEFAULT_TIMEOUT);
- } catch (final InterruptedException e) {
- throw new RuntimeException(e);
+ } catch (final RuntimeException | InterruptedException e) {
+ LOG.warn("Ignoring failure to clean test state", e);
}
Review comment:
This is really the fix for KAFKA-9875. The other change just hopefully reduces the probability that ignoring the exceptions could cause subsequent failures (e.g., if the topics don't get deleted before the next test, at least the next one will have different topic names).
I've verified that all usages of this method are ok to ignore potential exceptions. Namely, as long as the test logic itself doesn't want to ensure that any topics got deleted, and as long as this method is the last line in the method, then it should be fine just to ignore failures here.
I also considered just deleting the method, but if it does succeed, then it leaves less garbage around for subsequent tests, so it feels better to at least attempt a cleanup.
##########
File path: streams/src/test/java/org/apache/kafka/test/StreamsTestUtils.java
##########
@@ -106,7 +106,9 @@ public static void startKafkaStreamsAndWaitForRunningState(final KafkaStreams ka
kafkaStreams.start();
assertThat(
"KafkaStreams did not transit to RUNNING state within " + timeoutMs + " milli seconds.",
- countDownLatch.await(timeoutMs, TimeUnit.MILLISECONDS), equalTo(true));
+ countDownLatch.await(timeoutMs, TimeUnit.MILLISECONDS),
+ equalTo(true)
+ );
Review comment:
just fixing the formatting.
----------------------------------------------------------------
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