You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/08/17 09:08:09 UTC
[GitHub] [flink] PatrickRen opened a new pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
PatrickRen opened a new pull request #16860:
URL: https://github.com/apache/flink/pull/16860
## What is the purpose of the change
This pull request adds more logging utils for ```KafkaTableTestBase``` in order to reveal more information if test hangs.
## Brief change log
- Redirect KafkaContainer's STDOUT and STDERR to log4j
- Add debugging log if the test hangs for 5 minutes
## 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:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (no)
- If yes, how is the feature documented? (not applicable)
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b6b9a6c734c897d7a3704486fc74e5d31bae7e73 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] PatrickRen commented on a change in pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
PatrickRen commented on a change in pull request #16860:
URL: https://github.com/apache/flink/pull/16860#discussion_r690247105
##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaTableTestBase.java
##########
@@ -27,44 +27,101 @@
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.admin.TopicListing;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;
+import java.time.Duration;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.stream.Collectors;
/** Base class for Kafka Table IT Cases. */
public abstract class KafkaTableTestBase extends AbstractTestBase {
+ private static final Logger LOG = LoggerFactory.getLogger(KafkaTableTestBase.class);
+
private static final String INTER_CONTAINER_KAFKA_ALIAS = "kafka";
private static final Network NETWORK = Network.newNetwork();
private static final int zkTimeoutMills = 30000;
- @ClassRule
- public static final KafkaContainer KAFKA_CONTAINER =
- new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
- .withEmbeddedZookeeper()
- .withNetwork(NETWORK)
- .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ public static KafkaContainer kafkaContainer;
protected StreamExecutionEnvironment env;
protected StreamTableEnvironment tEnv;
+ // Timer for scheduling logging task if the test hangs
+ private final Timer loggingTimer = new Timer("Debug Logging Timer");
+
+ @BeforeClass
+ public static void startTestEnv() {
+ kafkaContainer =
+ new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
+ .withEmbeddedZookeeper()
+ .withNetwork(NETWORK)
+ .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ kafkaContainer.start();
+ if (LOG.isInfoEnabled()) {
+ kafkaContainer.followOutput(new Slf4jLogConsumer(LOG));
+ }
+ }
+
+ @AfterClass
+ public static void tearDownTestEnv() {
+ kafkaContainer.stop();
+ }
Review comment:
Fixed by d6bfdd9
##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaTableTestBase.java
##########
@@ -27,44 +27,101 @@
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.admin.TopicListing;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;
+import java.time.Duration;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.stream.Collectors;
/** Base class for Kafka Table IT Cases. */
public abstract class KafkaTableTestBase extends AbstractTestBase {
+ private static final Logger LOG = LoggerFactory.getLogger(KafkaTableTestBase.class);
+
private static final String INTER_CONTAINER_KAFKA_ALIAS = "kafka";
private static final Network NETWORK = Network.newNetwork();
private static final int zkTimeoutMills = 30000;
- @ClassRule
- public static final KafkaContainer KAFKA_CONTAINER =
- new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
- .withEmbeddedZookeeper()
- .withNetwork(NETWORK)
- .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ public static KafkaContainer kafkaContainer;
protected StreamExecutionEnvironment env;
protected StreamTableEnvironment tEnv;
+ // Timer for scheduling logging task if the test hangs
+ private final Timer loggingTimer = new Timer("Debug Logging Timer");
+
+ @BeforeClass
+ public static void startTestEnv() {
+ kafkaContainer =
+ new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
+ .withEmbeddedZookeeper()
+ .withNetwork(NETWORK)
+ .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ kafkaContainer.start();
+ if (LOG.isInfoEnabled()) {
+ kafkaContainer.followOutput(new Slf4jLogConsumer(LOG));
+ }
+ }
+
+ @AfterClass
+ public static void tearDownTestEnv() {
+ kafkaContainer.stop();
+ }
+
@Before
public void setup() {
env = StreamExecutionEnvironment.getExecutionEnvironment();
tEnv = StreamTableEnvironment.create(env);
env.getConfig().setRestartStrategy(RestartStrategies.noRestart());
+
+ // Print debug log if the test has been hanging for 5 minutes
+ scheduleTimeoutLogger(
+ Duration.ofMinutes(5),
+ () -> {
+ // List all non-internal topics
+ final Map<String, TopicDescription> topicDescriptions =
+ describeExternalTopics();
+ LOG.info("Current existing topics: {}", topicDescriptions.keySet());
+
+ // Log status in topics
+ logTopicPartitionStatus(topicDescriptions);
+
+ // Cancel the timer
+ loggingTimer.cancel();
+ });
Review comment:
Fixed by d6bfdd9
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
}, {
"hash" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381",
"triggerID" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d6bfdd97c618e764305515917075f97a38ebcd32 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
}, {
"hash" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b6b9a6c734c897d7a3704486fc74e5d31bae7e73 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377)
* d6bfdd97c618e764305515917075f97a38ebcd32 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b6b9a6c734c897d7a3704486fc74e5d31bae7e73 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot commented on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900136526
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.
## Automated Checks
Last check on commit b6b9a6c734c897d7a3704486fc74e5d31bae7e73 (Tue Aug 17 09:21:52 UTC 2021)
**Warnings:**
* No documentation files were touched! Remember to keep the Flink docs up to date!
<sub>Mention the bot in a comment to re-run the automated checks.</sub>
## Review Progress
* ❓ 1. The [description] looks good.
* ❓ 2. There is [consensus] that the contribution should go into to Flink.
* ❓ 3. Needs [attention] from.
* ❓ 4. The change fits into the overall [architecture].
* ❓ 5. Overall code [quality] is good.
Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
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 <summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
- `@flinkbot approve all` to approve all aspects
- `@flinkbot approve-until architecture` to approve everything until `architecture`
- `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
- `@flinkbot disapprove architecture` to remove an approval you gave earlier
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] PatrickRen commented on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
PatrickRen commented on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900187005
Thanks for the review @xintongsong ! I made another push based on your comments. Also I leave these logging as INFO level for debugging FLINK-22198. Could you please have another review? Thanks!
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
}, {
"hash" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381",
"triggerID" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b6b9a6c734c897d7a3704486fc74e5d31bae7e73 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377)
* d6bfdd97c618e764305515917075f97a38ebcd32 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong closed pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
xintongsong closed pull request #16860:
URL: https://github.com/apache/flink/pull/16860
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #16860:
URL: https://github.com/apache/flink/pull/16860#discussion_r690849889
##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaTableTestBase.java
##########
@@ -95,4 +142,71 @@ public void deleteTestTopic(String topic) {
admin.deleteTopics(Collections.singletonList(topic));
}
}
+
+ // ------------------------ For Debug Logging Purpose ----------------------------------
+
+ protected void scheduleTimeoutLogger(Duration period, Runnable loggingAction) {
Review comment:
These methods can be `private`.
- scheduleTimeoutLogger
- cancelTimeoutLogger
- describeExternalTopics
- logTopicPartitionStatus
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong closed pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
xintongsong closed pull request #16860:
URL: https://github.com/apache/flink/pull/16860
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #16860:
URL: https://github.com/apache/flink/pull/16860#discussion_r690849889
##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaTableTestBase.java
##########
@@ -95,4 +142,71 @@ public void deleteTestTopic(String topic) {
admin.deleteTopics(Collections.singletonList(topic));
}
}
+
+ // ------------------------ For Debug Logging Purpose ----------------------------------
+
+ protected void scheduleTimeoutLogger(Duration period, Runnable loggingAction) {
Review comment:
These methods can be `private`.
- scheduleTimeoutLogger
- cancelTimeoutLogger
- describeExternalTopics
- logTopicPartitionStatus
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
}, {
"hash" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381",
"triggerID" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"triggerType" : "PUSH"
}, {
"hash" : "b2f0a44536b7206856c366dfddd3f58e01766033",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "b2f0a44536b7206856c366dfddd3f58e01766033",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d6bfdd97c618e764305515917075f97a38ebcd32 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381)
* b2f0a44536b7206856c366dfddd3f58e01766033 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "DELETED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
}, {
"hash" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"status" : "FAILURE",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381",
"triggerID" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"triggerType" : "PUSH"
}, {
"hash" : "b2f0a44536b7206856c366dfddd3f58e01766033",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22426",
"triggerID" : "b2f0a44536b7206856c366dfddd3f58e01766033",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* d6bfdd97c618e764305515917075f97a38ebcd32 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381)
* b2f0a44536b7206856c366dfddd3f58e01766033 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22426)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] flinkbot edited a comment on pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #16860:
URL: https://github.com/apache/flink/pull/16860#issuecomment-900154319
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"status" : "CANCELED",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377",
"triggerID" : "b6b9a6c734c897d7a3704486fc74e5d31bae7e73",
"triggerType" : "PUSH"
}, {
"hash" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"status" : "PENDING",
"url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381",
"triggerID" : "d6bfdd97c618e764305515917075f97a38ebcd32",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* b6b9a6c734c897d7a3704486fc74e5d31bae7e73 Azure: [CANCELED](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22377)
* d6bfdd97c618e764305515917075f97a38ebcd32 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=22381)
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run travis` re-run the last Travis build
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink] xintongsong commented on a change in pull request #16860: [FLINK-22198][connector/kafka] Redirect KafkaContainer output to log4j and print debug log if test hangs
Posted by GitBox <gi...@apache.org>.
xintongsong commented on a change in pull request #16860:
URL: https://github.com/apache/flink/pull/16860#discussion_r690207576
##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaTableTestBase.java
##########
@@ -27,44 +27,101 @@
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.admin.TopicListing;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;
+import java.time.Duration;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.stream.Collectors;
/** Base class for Kafka Table IT Cases. */
public abstract class KafkaTableTestBase extends AbstractTestBase {
+ private static final Logger LOG = LoggerFactory.getLogger(KafkaTableTestBase.class);
+
private static final String INTER_CONTAINER_KAFKA_ALIAS = "kafka";
private static final Network NETWORK = Network.newNetwork();
private static final int zkTimeoutMills = 30000;
- @ClassRule
- public static final KafkaContainer KAFKA_CONTAINER =
- new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
- .withEmbeddedZookeeper()
- .withNetwork(NETWORK)
- .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ public static KafkaContainer kafkaContainer;
protected StreamExecutionEnvironment env;
protected StreamTableEnvironment tEnv;
+ // Timer for scheduling logging task if the test hangs
+ private final Timer loggingTimer = new Timer("Debug Logging Timer");
+
+ @BeforeClass
+ public static void startTestEnv() {
+ kafkaContainer =
+ new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
+ .withEmbeddedZookeeper()
+ .withNetwork(NETWORK)
+ .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ kafkaContainer.start();
+ if (LOG.isInfoEnabled()) {
+ kafkaContainer.followOutput(new Slf4jLogConsumer(LOG));
+ }
+ }
+
+ @AfterClass
+ public static void tearDownTestEnv() {
+ kafkaContainer.stop();
+ }
+
@Before
public void setup() {
env = StreamExecutionEnvironment.getExecutionEnvironment();
tEnv = StreamTableEnvironment.create(env);
env.getConfig().setRestartStrategy(RestartStrategies.noRestart());
+
+ // Print debug log if the test has been hanging for 5 minutes
+ scheduleTimeoutLogger(
+ Duration.ofMinutes(5),
+ () -> {
+ // List all non-internal topics
+ final Map<String, TopicDescription> topicDescriptions =
+ describeExternalTopics();
+ LOG.info("Current existing topics: {}", topicDescriptions.keySet());
+
+ // Log status in topics
+ logTopicPartitionStatus(topicDescriptions);
+
+ // Cancel the timer
+ loggingTimer.cancel();
+ });
Review comment:
What is the rationality behind the behavior that prints debug logs for once at the 5min timeout?
- If the test case is expected to finish within 5min, we should also fail is on timeout.
- If there's no assumption that the case should finish within 5min, we may print the logs before the test case stuck.
I'd suggest to simply probe the topics periodically, to decouple the logging logs from the testing logics.
##########
File path: flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/table/KafkaTableTestBase.java
##########
@@ -27,44 +27,101 @@
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.admin.TopicDescription;
+import org.apache.kafka.clients.admin.TopicListing;
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.KafkaConsumer;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.serialization.StringDeserializer;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
-import org.junit.ClassRule;
+import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
import org.testcontainers.utility.DockerImageName;
+import java.time.Duration;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.stream.Collectors;
/** Base class for Kafka Table IT Cases. */
public abstract class KafkaTableTestBase extends AbstractTestBase {
+ private static final Logger LOG = LoggerFactory.getLogger(KafkaTableTestBase.class);
+
private static final String INTER_CONTAINER_KAFKA_ALIAS = "kafka";
private static final Network NETWORK = Network.newNetwork();
private static final int zkTimeoutMills = 30000;
- @ClassRule
- public static final KafkaContainer KAFKA_CONTAINER =
- new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
- .withEmbeddedZookeeper()
- .withNetwork(NETWORK)
- .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ public static KafkaContainer kafkaContainer;
protected StreamExecutionEnvironment env;
protected StreamTableEnvironment tEnv;
+ // Timer for scheduling logging task if the test hangs
+ private final Timer loggingTimer = new Timer("Debug Logging Timer");
+
+ @BeforeClass
+ public static void startTestEnv() {
+ kafkaContainer =
+ new KafkaContainer(DockerImageName.parse(DockerImageVersions.KAFKA))
+ .withEmbeddedZookeeper()
+ .withNetwork(NETWORK)
+ .withNetworkAliases(INTER_CONTAINER_KAFKA_ALIAS);
+ kafkaContainer.start();
+ if (LOG.isInfoEnabled()) {
+ kafkaContainer.followOutput(new Slf4jLogConsumer(LOG));
+ }
+ }
+
+ @AfterClass
+ public static void tearDownTestEnv() {
+ kafkaContainer.stop();
+ }
Review comment:
Is it possible to achieve this by overriding `KafkaContainer#doStart()`?
What the current approach make me uncomfortable are:
- It makes `kafkaContainer` non-final, which lead to potential problems like NPEs or so.
- As an abstract class, `startTestEnv` and `tearDownTestEnv` could be overridden.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org