mirror of https://github.com/apache/lucene.git
Harden RequestRateLimiter Tests (#1736)
* Harden RequestRateLimiter Tests This commit adds higher data size and load in the test path. Also improves the asserts that are performed.
This commit is contained in:
parent
97c9bb732a
commit
1d2749295b
|
@ -66,15 +66,17 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
||||||
|
|
||||||
solrDispatchFilter.replaceRateLimitManager(rateLimitManager);
|
solrDispatchFilter.replaceRateLimitManager(rateLimitManager);
|
||||||
|
|
||||||
processTest(client);
|
int numDocs = TEST_NIGHTLY ? 10000 : 100;
|
||||||
|
|
||||||
|
processTest(client, numDocs, 350 /* number of queries */);
|
||||||
|
|
||||||
MockRequestRateLimiter mockQueryRateLimiter = (MockRequestRateLimiter) rateLimitManager.getRequestRateLimiter(SolrRequest.SolrRequestType.QUERY);
|
MockRequestRateLimiter mockQueryRateLimiter = (MockRequestRateLimiter) rateLimitManager.getRequestRateLimiter(SolrRequest.SolrRequestType.QUERY);
|
||||||
|
|
||||||
assertEquals(25, mockQueryRateLimiter.incomingRequestCount.get());
|
assertEquals(350, mockQueryRateLimiter.incomingRequestCount.get());
|
||||||
assertTrue("Incoming accepted new request count did not match. Expected 5 incoming " + mockQueryRateLimiter.acceptedNewRequestCount.get(),
|
|
||||||
mockQueryRateLimiter.acceptedNewRequestCount.get() < 25);
|
assertTrue(mockQueryRateLimiter.acceptedNewRequestCount.get() > 0);
|
||||||
assertTrue("Incoming rejected new request count did not match. Expected 20 incoming " + mockQueryRateLimiter.rejectedRequestCount.get(),
|
assertTrue((mockQueryRateLimiter.acceptedNewRequestCount.get() == mockQueryRateLimiter.incomingRequestCount.get()
|
||||||
mockQueryRateLimiter.rejectedRequestCount.get() > 0);
|
|| mockQueryRateLimiter.rejectedRequestCount.get() > 0));
|
||||||
assertEquals(mockQueryRateLimiter.incomingRequestCount.get(),
|
assertEquals(mockQueryRateLimiter.incomingRequestCount.get(),
|
||||||
mockQueryRateLimiter.acceptedNewRequestCount.get() + mockQueryRateLimiter.rejectedRequestCount.get());
|
mockQueryRateLimiter.acceptedNewRequestCount.get() + mockQueryRateLimiter.rejectedRequestCount.get());
|
||||||
}
|
}
|
||||||
|
@ -99,7 +101,9 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
||||||
|
|
||||||
solrDispatchFilter.replaceRateLimitManager(rateLimitManager);
|
solrDispatchFilter.replaceRateLimitManager(rateLimitManager);
|
||||||
|
|
||||||
processTest(client);
|
int numDocs = TEST_NIGHTLY ? 10000 : 100;
|
||||||
|
|
||||||
|
processTest(client, numDocs, 400 /* Number of queries */);
|
||||||
|
|
||||||
MockRequestRateLimiter mockIndexRateLimiter = (MockRequestRateLimiter) rateLimitManager.getRequestRateLimiter(SolrRequest.SolrRequestType.UPDATE);
|
MockRequestRateLimiter mockIndexRateLimiter = (MockRequestRateLimiter) rateLimitManager.getRequestRateLimiter(SolrRequest.SolrRequestType.UPDATE);
|
||||||
|
|
||||||
|
@ -107,9 +111,9 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
||||||
mockIndexRateLimiter.borrowedSlotCount.get() > 0);
|
mockIndexRateLimiter.borrowedSlotCount.get() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTest(CloudSolrClient client) throws Exception {
|
private void processTest(CloudSolrClient client, int numDocuments, int numQueries) throws Exception {
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < numDocuments; i++) {
|
||||||
SolrInputDocument doc = new SolrInputDocument();
|
SolrInputDocument doc = new SolrInputDocument();
|
||||||
|
|
||||||
doc.setField("id", i);
|
doc.setField("id", i);
|
||||||
|
@ -124,12 +128,12 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
||||||
List<Future<Boolean>> futures;
|
List<Future<Boolean>> futures;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 25; i++) {
|
for (int i = 0; i < numQueries; i++) {
|
||||||
callableList.add(() -> {
|
callableList.add(() -> {
|
||||||
try {
|
try {
|
||||||
QueryResponse response = client.query(new SolrQuery("*:*"));
|
QueryResponse response = client.query(new SolrQuery("*:*"));
|
||||||
|
|
||||||
assertEquals(100, response.getResults().getNumFound());
|
assertEquals(numDocuments, response.getResults().getNumFound());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e.getMessage());
|
throw new RuntimeException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue