-
Notifications
You must be signed in to change notification settings - Fork 768
SOLR-17945: fix flaky test CloudHttp2SolrClientTest#testHttpCspPerf #3742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9ba9c46
SOLR-17945
jdyer1 556312b
Add a doc comment expaining what this test is doing and why we are se…
jdyer1 faf3e0f
tidy
jdyer1 e651f12
Update solr/solrj/src/test/org/apache/solr/client/solrj/impl/ClusterS…
jdyer1 ecf1d68
Update solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHtt…
jdyer1 b543570
Do not clear system properties. test framework does it for us.
jdyer1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
*/ | ||
package org.apache.solr.client.solrj.impl; | ||
|
||
import static org.apache.solr.client.solrj.impl.BaseHttpClusterStateProvider.SYS_PROP_CACHE_TIMEOUT_SECONDS; | ||
import static org.apache.solr.client.solrj.impl.CloudSolrClient.RouteResponse; | ||
|
||
import java.io.IOException; | ||
|
@@ -256,47 +257,58 @@ public void testAliasHandling() throws Exception { | |
@Test | ||
@LogLevel("org.apache.solr.servlet.HttpSolrCall=DEBUG") | ||
public void testHttpCspPerf() throws Exception { | ||
// This ensures CH2SC is caching cluster status by counting the number of logged calls to the | ||
// admin endpoint. Too many calls to CLUSTERSTATUS might mean insufficient caching and | ||
// peformance regressions! | ||
try { | ||
// BaseHttpClusterStateProvider has a background job that pre-fetches data from CLUSTERSTATUS | ||
// on timed intervals. This can pollute this test, so we set the interval very high to | ||
// prevent it from running. | ||
System.setProperty(SYS_PROP_CACHE_TIMEOUT_SECONDS, "" + Integer.MAX_VALUE); | ||
|
||
String collectionName = "HTTPCSPTEST"; | ||
CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1) | ||
.process(cluster.getSolrClient()); | ||
cluster.waitForActiveCollection(collectionName, 2, 2); | ||
String collectionName = "HTTPCSPTEST"; | ||
CollectionAdminRequest.createCollection(collectionName, "conf", 2, 1) | ||
.process(cluster.getSolrClient()); | ||
cluster.waitForActiveCollection(collectionName, 2, 2); | ||
|
||
try (LogListener adminLogs = LogListener.info(HttpSolrCall.class).substring("[admin]"); | ||
CloudSolrClient solrClient = createHttpCSPBasedCloudSolrClient(); ) { | ||
solrClient.getClusterStateProvider().getLiveNodes(); // talks to Solr | ||
try (LogListener adminLogs = LogListener.info(HttpSolrCall.class).substring("[admin]"); | ||
CloudSolrClient solrClient = createHttpCSPBasedCloudSolrClient(); ) { | ||
solrClient.getClusterStateProvider().getLiveNodes(); // talks to Solr | ||
|
||
assertEquals(1, adminLogs.getCount()); | ||
assertTrue( | ||
adminLogs | ||
.pollMessage() | ||
.contains( | ||
"path=/admin/collections params={prs=true&liveNodes=true&action" | ||
+ "=CLUSTERSTATUS&includeAll=false")); | ||
|
||
SolrInputDocument doc = new SolrInputDocument("id", "1", "title_s", "my doc"); | ||
solrClient.add(collectionName, doc); | ||
|
||
// getCount seems to return a cumulative count, but add() results in only 1 additional admin | ||
// request to fetch CLUSTERSTATUS for the collection | ||
assertEquals(2, adminLogs.getCount()); | ||
assertTrue( | ||
adminLogs | ||
.pollMessage() | ||
.contains( | ||
"path=/admin/collections " | ||
+ "params={prs=true&action=CLUSTERSTATUS&includeAll=false")); | ||
assertEquals(1, adminLogs.getCount()); | ||
assertTrue( | ||
adminLogs | ||
.pollMessage() | ||
.contains( | ||
"path=/admin/collections params={prs=true&liveNodes=true&action" | ||
+ "=CLUSTERSTATUS&includeAll=false")); | ||
|
||
solrClient.commit(collectionName); | ||
// No additional admin requests sent | ||
assertEquals(2, adminLogs.getCount()); | ||
SolrInputDocument doc = new SolrInputDocument("id", "1", "title_s", "my doc"); | ||
solrClient.add(collectionName, doc); | ||
|
||
for (int i = 0; i < 3; i++) { | ||
assertEquals( | ||
1, solrClient.query(collectionName, params("q", "*:*")).getResults().getNumFound()); | ||
// getCount seems to return a cumulative count, but add() results in only 1 additional admin | ||
// request to fetch CLUSTERSTATUS for the collection | ||
assertEquals(2, adminLogs.getCount()); | ||
assertTrue( | ||
adminLogs | ||
.pollMessage() | ||
.contains( | ||
"path=/admin/collections " | ||
+ "params={prs=true&action=CLUSTERSTATUS&includeAll=false")); | ||
|
||
solrClient.commit(collectionName); | ||
// No additional admin requests sent | ||
assertEquals(2, adminLogs.getCount()); | ||
|
||
for (int i = 0; i < 3; i++) { | ||
assertEquals( | ||
1, solrClient.query(collectionName, params("q", "*:*")).getResults().getNumFound()); | ||
// No additional admin requests sent | ||
assertEquals(2, adminLogs.getCount()); | ||
} | ||
} | ||
} finally { | ||
System.clearProperty(SYS_PROP_CACHE_TIMEOUT_SECONDS); | ||
|
||
} | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.