You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by jo...@apache.org on 2021/04/09 17:54:58 UTC
[druid] branch master updated: Add retry around query loop in
ITWikipediaQueryTest.testQueryLaningLaneIsLimited (#11077)
This is an automated email from the ASF dual-hosted git repository.
jonwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new e7b2ecd Add retry around query loop in ITWikipediaQueryTest.testQueryLaningLaneIsLimited (#11077)
e7b2ecd is described below
commit e7b2ecd0fd3f79069aa8f6065b85e8072ee773eb
Author: Jonathan Wei <jo...@users.noreply.github.com>
AuthorDate: Fri Apr 9 10:54:34 2021 -0700
Add retry around query loop in ITWikipediaQueryTest.testQueryLaningLaneIsLimited (#11077)
---
.../druid/tests/query/ITWikipediaQueryTest.java | 82 ++++++++++++++--------
1 file changed, 51 insertions(+), 31 deletions(-)
diff --git a/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java b/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java
index b5652b9..9fc5209 100644
--- a/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java
+++ b/integration-tests/src/test/java/org/apache/druid/tests/query/ITWikipediaQueryTest.java
@@ -21,6 +21,7 @@ package org.apache.druid.tests.query;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
+import org.apache.druid.java.util.common.logger.Logger;
import org.apache.druid.java.util.http.client.response.StatusResponseHolder;
import org.apache.druid.query.Druids;
import org.apache.druid.query.QueryCapacityExceededException;
@@ -47,6 +48,8 @@ import java.util.concurrent.Future;
@Guice(moduleFactory = DruidTestModuleFactory.class)
public class ITWikipediaQueryTest
{
+ private static final Logger LOG = new Logger(ITWikipediaQueryTest.class);
+
public static final String WIKIPEDIA_DATA_SOURCE = "wikipedia_editstream";
private static final String WIKI_LOOKUP = "wiki-simple";
private static final String WIKIPEDIA_QUERIES_RESOURCE = "/queries/wikipedia_editstream_queries.json";
@@ -85,37 +88,54 @@ public class ITWikipediaQueryTest
@Test
public void testQueryLaningLaneIsLimited() throws Exception
{
- // the broker is configured with a manually defined query lane, 'one' with limit 1
- // -Ddruid.query.scheduler.laning.type=manual
- // -Ddruid.query.scheduler.laning.lanes.one=1
- // by issuing 50 queries, at least 1 of them will succeed on 'one', and at least 1 of them will overlap enough to
- // get limited
- final int numQueries = 50;
- List<Future<StatusResponseHolder>> futures = new ArrayList<>(numQueries);
- for (int i = 0; i < numQueries; i++) {
- futures.add(
- queryClient.queryAsync(
- queryHelper.getQueryURL(config.getBrokerUrl()),
- getQueryBuilder().build()
- )
- );
- }
-
- int success = 0;
- int limited = 0;
-
- for (Future<StatusResponseHolder> future : futures) {
- StatusResponseHolder status = future.get();
- if (status.getStatus().getCode() == QueryCapacityExceededException.STATUS_CODE) {
- limited++;
- Assert.assertTrue(status.getContent().contains(QueryCapacityExceededException.makeLaneErrorMessage("one", 1)));
- } else if (status.getStatus().getCode() == HttpResponseStatus.OK.getCode()) {
- success++;
- }
- }
-
- Assert.assertTrue(success > 0);
- Assert.assertTrue(limited > 0);
+ ITRetryUtil.retryUntil(
+ () -> {
+ // the broker is configured with a manually defined query lane, 'one' with limit 1
+ // -Ddruid.query.scheduler.laning.type=manual
+ // -Ddruid.query.scheduler.laning.lanes.one=1
+ // by issuing 50 queries, at least 1 of them will succeed on 'one', and at least 1 of them will overlap enough to
+ // get limited.
+ // It's possible but unlikely that these queries execute in a way that none of them overlap, so we
+ // retry this test a few times to compensate for this.
+ final int numQueries = 50;
+ List<Future<StatusResponseHolder>> futures = new ArrayList<>(numQueries);
+ for (int i = 0; i < numQueries; i++) {
+ futures.add(
+ queryClient.queryAsync(
+ queryHelper.getQueryURL(config.getBrokerUrl()),
+ getQueryBuilder().build()
+ )
+ );
+ }
+
+ int success = 0;
+ int limited = 0;
+
+ for (Future<StatusResponseHolder> future : futures) {
+ StatusResponseHolder status = future.get();
+ if (status.getStatus().getCode() == QueryCapacityExceededException.STATUS_CODE) {
+ limited++;
+ Assert.assertTrue(status.getContent().contains(QueryCapacityExceededException.makeLaneErrorMessage("one", 1)));
+ } else if (status.getStatus().getCode() == HttpResponseStatus.OK.getCode()) {
+ success++;
+ }
+ }
+
+ try {
+ Assert.assertTrue(success > 0);
+ Assert.assertTrue(limited > 0);
+ return true;
+ }
+ catch (AssertionError ae) {
+ LOG.error(ae, "Got assertion error in testQueryLaningLaneIsLimited");
+ return false;
+ }
+ },
+ true,
+ 5000,
+ 3,
+ "testQueryLaningLaneIsLimited"
+ );
// test another to make sure we can still issue one query at a time
StatusResponseHolder followUp = queryClient.queryAsync(
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org