Skip to content

Commit

Permalink
retry on 503 along with 404 in this test
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_4x@1369369 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markrmiller committed Aug 4, 2012
1 parent 99ca0f4 commit 9ec6a42
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private void testCollectionsAPI() throws Exception {
HttpSolrServer collectionClient = new HttpSolrServer(url);

// poll for a second - it can take a moment before we are ready to serve
waitForNon404(collectionClient);
waitForNon404or503(collectionClient);
}

List<String> collectionNameList = new ArrayList<String>();
Expand Down Expand Up @@ -500,20 +500,21 @@ private String getUrlFromZk(String collection) {
throw new RuntimeException("Could not find a live node for collection:" + collection);
}

private void waitForNon404(HttpSolrServer collectionClient)
private void waitForNon404or503(HttpSolrServer collectionClient)
throws Exception {

SolrException exp = null;
long timeoutAt = System.currentTimeMillis() + 30000;

while (System.currentTimeMillis() < timeoutAt) {
boolean missing = false;

try {
collectionClient.query(new SolrQuery("*:*"));
} catch (SolrException e) {
// How do I get the response code!?
if (!e.getMessage().contains("(404)")) {
if (!(e.code() == 403 || e.code() == 503)) {
throw e;
}
exp = e;
missing = true;
}
if (!missing) {
Expand All @@ -522,7 +523,7 @@ private void waitForNon404(HttpSolrServer collectionClient)
Thread.sleep(50);
}
printLayout();
fail("Could not find the new collection - 404 : " + collectionClient.getBaseURL());
fail("Could not find the new collection - " + exp.code() + " : " + collectionClient.getBaseURL());
}

private void checkForCollection(String collectionName, int expectedSlices)
Expand Down

0 comments on commit 9ec6a42

Please sign in to comment.