Search in sources :

Example 1 with ThreadSnapshot

use of io.confluent.ksql.test.util.ThreadTestUtil.ThreadSnapshot in project ksql by confluentinc.

the class RestQueryTranslationTest method tearDown.

@After
public void tearDown() {
    REST_APP.closePersistentQueries();
    REST_APP.dropSourcesExcept();
    // Sometimes a race-condition throws an error when deleting a changelog topic (created by
    // a CST query) that is later deleted automatically just before the Kafka API delete is called.
    // Let's retry a few more times before marking this deletion as failure.
    RetryUtil.retryWithBackoff(10, 10, (int) TimeUnit.SECONDS.toMillis(10), () -> TEST_HARNESS.getKafkaCluster().deleteAllTopics(TestKsqlRestApp.getCommandTopicName()));
    final ThreadSnapshot thread = STARTING_THREADS.get();
    if (thread == null) {
        // Only set once one full run completed to ensure all persistent threads created:
        STARTING_THREADS.set(ThreadTestUtil.threadSnapshot(filterBuilder().excludeTerminated().nameMatches(name -> !name.startsWith("ksql-workers")).nameMatches(name -> !name.startsWith("pull-query-coordinator")).nameMatches(name -> !name.startsWith("pull-query-router")).build()));
    } else {
        thread.assertSameThreads();
    }
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ThreadSnapshot(io.confluent.ksql.test.util.ThreadTestUtil.ThreadSnapshot) StreamsConfig(org.apache.kafka.streams.StreamsConfig) RunWith(org.junit.runner.RunWith) IntegrationTest(org.apache.kafka.test.IntegrationTest) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestFileContext(io.confluent.ksql.test.model.TestFileContext) ArrayList(java.util.ArrayList) TestFile(io.confluent.ksql.test.loader.TestFile) TestUtils(io.confluent.ksql.test.utils.TestUtils) ImmutableList(com.google.common.collect.ImmutableList) ThreadTestUtil(io.confluent.ksql.test.util.ThreadTestUtil) Objects.requireNonNull(java.util.Objects.requireNonNull) After(org.junit.After) Timeout(org.junit.rules.Timeout) ClassRule(org.junit.ClassRule) JsonTestLoader(io.confluent.ksql.test.loader.JsonTestLoader) Path(java.nio.file.Path) Parameterized(org.junit.runners.Parameterized) ZooKeeperClientException(kafka.zookeeper.ZooKeeperClientException) ThreadTestUtil.filterBuilder(io.confluent.ksql.test.util.ThreadTestUtil.filterBuilder) TestKsqlRestApp(io.confluent.ksql.rest.server.TestKsqlRestApp) Collection(java.util.Collection) KSQL_STREAMS_PREFIX(io.confluent.ksql.util.KsqlConfig.KSQL_STREAMS_PREFIX) ConsumerConfig(org.apache.kafka.clients.consumer.ConsumerConfig) Test(org.junit.Test) KsqlConfig(io.confluent.ksql.util.KsqlConfig) Category(org.junit.experimental.categories.Category) IntegrationTestHarness(io.confluent.ksql.integration.IntegrationTestHarness) RetryUtil(io.confluent.ksql.util.RetryUtil) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) RuleChain(org.junit.rules.RuleChain) List(java.util.List) Stream(java.util.stream.Stream) Rule(org.junit.Rule) Paths(java.nio.file.Paths) Retry(io.confluent.ksql.integration.Retry) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties) ThreadSnapshot(io.confluent.ksql.test.util.ThreadTestUtil.ThreadSnapshot) After(org.junit.After)

Aggregations

JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 ImmutableList (com.google.common.collect.ImmutableList)1 IntegrationTestHarness (io.confluent.ksql.integration.IntegrationTestHarness)1 Retry (io.confluent.ksql.integration.Retry)1 TestKsqlRestApp (io.confluent.ksql.rest.server.TestKsqlRestApp)1 JsonTestLoader (io.confluent.ksql.test.loader.JsonTestLoader)1 TestFile (io.confluent.ksql.test.loader.TestFile)1 TestFileContext (io.confluent.ksql.test.model.TestFileContext)1 ThreadTestUtil (io.confluent.ksql.test.util.ThreadTestUtil)1 ThreadSnapshot (io.confluent.ksql.test.util.ThreadTestUtil.ThreadSnapshot)1 ThreadTestUtil.filterBuilder (io.confluent.ksql.test.util.ThreadTestUtil.filterBuilder)1 TestUtils (io.confluent.ksql.test.utils.TestUtils)1 KsqlConfig (io.confluent.ksql.util.KsqlConfig)1 KSQL_STREAMS_PREFIX (io.confluent.ksql.util.KsqlConfig.KSQL_STREAMS_PREFIX)1 RetryUtil (io.confluent.ksql.util.RetryUtil)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1