You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by kk...@apache.org on 2020/07/14 04:24:12 UTC
[kafka] branch 2.6 updated: KAFKA-10192: Wait for REST API to
become available before testing blocked connectors (#8928)
This is an automated email from the ASF dual-hosted git repository.
kkarantasis pushed a commit to branch 2.6
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/2.6 by this push:
new 36c5080 KAFKA-10192: Wait for REST API to become available before testing blocked connectors (#8928)
36c5080 is described below
commit 36c508065425b838ff824b847dc934fce62f742b
Author: Chris Egerton <ch...@confluent.io>
AuthorDate: Mon Jul 13 21:02:03 2020 -0700
KAFKA-10192: Wait for REST API to become available before testing blocked connectors (#8928)
The `testBlockInConnectorStop` test is failing semi-frequently on Jenkins. It's difficult to verify the cause without complete logs and I'm unable to reproduce locally, but I suspect the cause may be that the Connect worker hasn't completed startup yet by the time the test begins and so the initial REST request to create a connector times out with a 500 error. This isn't an issue for normal tests but we artificially reduce the REST request timeout for these tests as some requests are [...]
The changes here use a small hack to verify that the worker has started and is ready to handle all types of REST requests before tests start by querying the REST API for a non-existent connector.
Reviewers: Boyang Chan <bo...@confluent.io>, Konstantine Karantasis <k....@gmail.com>
---
.../kafka/connect/integration/BlockingConnectorTest.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/connect/runtime/src/test/java/org/apache/kafka/connect/integration/BlockingConnectorTest.java b/connect/runtime/src/test/java/org/apache/kafka/connect/integration/BlockingConnectorTest.java
index 02673eb..731a1f7 100644
--- a/connect/runtime/src/test/java/org/apache/kafka/connect/integration/BlockingConnectorTest.java
+++ b/connect/runtime/src/test/java/org/apache/kafka/connect/integration/BlockingConnectorTest.java
@@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
import static org.apache.kafka.connect.runtime.ConnectorConfig.CONNECTOR_CLASS_CONFIG;
import static org.apache.kafka.connect.runtime.ConnectorConfig.TASKS_MAX_CONFIG;
+import static org.apache.kafka.test.TestUtils.waitForCondition;
import static org.junit.Assert.assertThrows;
public class BlockingConnectorTest {
@@ -55,6 +56,7 @@ public class BlockingConnectorTest {
private static final String NORMAL_CONNECTOR_NAME = "normal-connector";
private static final String TEST_TOPIC = "normal-topic";
private static final int NUM_RECORDS_PRODUCED = 100;
+ private static final long CONNECT_WORKER_STARTUP_TIMEOUT = TimeUnit.SECONDS.toMillis(30);
private static final long RECORD_TRANSFER_DURATION_MS = TimeUnit.SECONDS.toMillis(30);
private static final long REST_REQUEST_TIMEOUT = Worker.CONNECTOR_GRACEFUL_SHUTDOWN_TIMEOUT_MS * 2;
@@ -62,7 +64,7 @@ public class BlockingConnectorTest {
private ConnectorHandle normalConnectorHandle;
@Before
- public void setup() {
+ public void setup() throws Exception {
// Artificially reduce the REST request timeout so that these don't take forever
ConnectorsResource.setRequestTimeout(REST_REQUEST_TIMEOUT);
// build a Connect cluster backed by Kafka and Zk
@@ -76,6 +78,15 @@ public class BlockingConnectorTest {
// start the clusters
connect.start();
+
+ // wait for the Connect REST API to become available. necessary because of the reduced REST
+ // request timeout; otherwise, we may get an unexpected 500 with our first real REST request
+ // if the worker is still getting on its feet.
+ waitForCondition(
+ () -> connect.requestGet(connect.endpointForResource("connectors/nonexistent")).getStatus() == 404,
+ CONNECT_WORKER_STARTUP_TIMEOUT,
+ "Worker did not complete startup in time"
+ );
}
@After