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);
|
||||
|
||||
processTest(client);
|
||||
int numDocs = TEST_NIGHTLY ? 10000 : 100;
|
||||
|
||||
processTest(client, numDocs, 350 /* number of queries */);
|
||||
|
||||
MockRequestRateLimiter mockQueryRateLimiter = (MockRequestRateLimiter) rateLimitManager.getRequestRateLimiter(SolrRequest.SolrRequestType.QUERY);
|
||||
|
||||
assertEquals(25, mockQueryRateLimiter.incomingRequestCount.get());
|
||||
assertTrue("Incoming accepted new request count did not match. Expected 5 incoming " + mockQueryRateLimiter.acceptedNewRequestCount.get(),
|
||||
mockQueryRateLimiter.acceptedNewRequestCount.get() < 25);
|
||||
assertTrue("Incoming rejected new request count did not match. Expected 20 incoming " + mockQueryRateLimiter.rejectedRequestCount.get(),
|
||||
mockQueryRateLimiter.rejectedRequestCount.get() > 0);
|
||||
assertEquals(350, mockQueryRateLimiter.incomingRequestCount.get());
|
||||
|
||||
assertTrue(mockQueryRateLimiter.acceptedNewRequestCount.get() > 0);
|
||||
assertTrue((mockQueryRateLimiter.acceptedNewRequestCount.get() == mockQueryRateLimiter.incomingRequestCount.get()
|
||||
|| mockQueryRateLimiter.rejectedRequestCount.get() > 0));
|
||||
assertEquals(mockQueryRateLimiter.incomingRequestCount.get(),
|
||||
mockQueryRateLimiter.acceptedNewRequestCount.get() + mockQueryRateLimiter.rejectedRequestCount.get());
|
||||
}
|
||||
|
@ -99,7 +101,9 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
|||
|
||||
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);
|
||||
|
||||
|
@ -107,9 +111,9 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
|||
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();
|
||||
|
||||
doc.setField("id", i);
|
||||
|
@ -124,12 +128,12 @@ public class TestRequestRateLimiter extends SolrCloudTestCase {
|
|||
List<Future<Boolean>> futures;
|
||||
|
||||
try {
|
||||
for (int i = 0; i < 25; i++) {
|
||||
for (int i = 0; i < numQueries; i++) {
|
||||
callableList.add(() -> {
|
||||
try {
|
||||
QueryResponse response = client.query(new SolrQuery("*:*"));
|
||||
|
||||
assertEquals(100, response.getResults().getNumFound());
|
||||
assertEquals(numDocuments, response.getResults().getNumFound());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue