Add retry around query loop in ITWikipediaQueryTest.testQueryLaningLaneIsLimited (#11077)

This commit is contained in:
Jonathan Wei 2021-04-09 10:54:34 -07:00 committed by GitHub
parent 4576152e4a
commit e7b2ecd0fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 48 additions and 28 deletions

View File

@ -21,6 +21,7 @@ package org.apache.druid.tests.query;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject; 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.java.util.http.client.response.StatusResponseHolder;
import org.apache.druid.query.Druids; import org.apache.druid.query.Druids;
import org.apache.druid.query.QueryCapacityExceededException; import org.apache.druid.query.QueryCapacityExceededException;
@ -47,6 +48,8 @@ import java.util.concurrent.Future;
@Guice(moduleFactory = DruidTestModuleFactory.class) @Guice(moduleFactory = DruidTestModuleFactory.class)
public class ITWikipediaQueryTest public class ITWikipediaQueryTest
{ {
private static final Logger LOG = new Logger(ITWikipediaQueryTest.class);
public static final String WIKIPEDIA_DATA_SOURCE = "wikipedia_editstream"; public static final String WIKIPEDIA_DATA_SOURCE = "wikipedia_editstream";
private static final String WIKI_LOOKUP = "wiki-simple"; private static final String WIKI_LOOKUP = "wiki-simple";
private static final String WIKIPEDIA_QUERIES_RESOURCE = "/queries/wikipedia_editstream_queries.json"; private static final String WIKIPEDIA_QUERIES_RESOURCE = "/queries/wikipedia_editstream_queries.json";
@ -85,11 +88,15 @@ public class ITWikipediaQueryTest
@Test @Test
public void testQueryLaningLaneIsLimited() throws Exception public void testQueryLaningLaneIsLimited() throws Exception
{ {
ITRetryUtil.retryUntil(
() -> {
// the broker is configured with a manually defined query lane, 'one' with limit 1 // the broker is configured with a manually defined query lane, 'one' with limit 1
// -Ddruid.query.scheduler.laning.type=manual // -Ddruid.query.scheduler.laning.type=manual
// -Ddruid.query.scheduler.laning.lanes.one=1 // -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 // 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 // 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; final int numQueries = 50;
List<Future<StatusResponseHolder>> futures = new ArrayList<>(numQueries); List<Future<StatusResponseHolder>> futures = new ArrayList<>(numQueries);
for (int i = 0; i < numQueries; i++) { for (int i = 0; i < numQueries; i++) {
@ -114,8 +121,21 @@ public class ITWikipediaQueryTest
} }
} }
try {
Assert.assertTrue(success > 0); Assert.assertTrue(success > 0);
Assert.assertTrue(limited > 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 // test another to make sure we can still issue one query at a time
StatusResponseHolder followUp = queryClient.queryAsync( StatusResponseHolder followUp = queryClient.queryAsync(