SOLR-12938 - fix test case for handling of bogus collection names

that was failing when HttpClusterStateProvider is used instead of
ZkClusterStateProvider
This commit is contained in:
Gus Heck 2018-11-07 20:05:32 -05:00
parent 4794a1617c
commit 53482e510c
2 changed files with 16 additions and 6 deletions

View File

@ -112,7 +112,9 @@ public class ClusterStatus {
DocCollection clusterStateCollection = entry.getValue();
if (clusterStateCollection == null) {
if (collection != null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found");
SolrException solrException = new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found");
solrException.setMetadata("CLUSTERSTATUS","NOT_FOUND");
throw solrException;
} else {
//collection might have got deleted at the same time
continue;

View File

@ -95,7 +95,13 @@ public class HttpClusterStateProvider implements ClusterStateProvider {
withHttpClient(httpClient).build()) {
ClusterState cs = fetchClusterState(client, collection, null);
return cs.getCollectionRef(collection);
} catch (SolrServerException | RemoteSolrException | IOException e) {
} catch (SolrServerException | IOException e) {
log.warn("Attempt to fetch cluster state from " +
Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e);
} catch (RemoteSolrException e) {
if ("NOT_FOUND".equals(e.getMetadata("CLUSTERSTATUS"))) {
return null;
}
log.warn("Attempt to fetch cluster state from " +
Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e);
} catch (NotACollectionException e) {
@ -257,9 +263,9 @@ public class HttpClusterStateProvider implements ClusterStateProvider {
log.warn("Attempt to fetch cluster state from " +
Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e);
} catch (NotACollectionException e) {
// Cluster state for the given collection was not found, could be an alias.
// Lets fetch/update our aliases:
getAliases(true);
// not possible! (we passed in null for collection so it can't be an alias)
throw new RuntimeException("null should never cause NotACollectionException in " +
"fetchClusterState() Please report this as a bug!");
}
}
throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes +". However, "
@ -282,7 +288,9 @@ public class HttpClusterStateProvider implements ClusterStateProvider {
log.warn("Attempt to fetch cluster state from " +
Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e);
} catch (NotACollectionException e) {
// should be an an alias, don't care
// not possible! (we passed in null for collection so it can't be an alias)
throw new RuntimeException("null should never cause NotACollectionException in " +
"fetchClusterState() Please report this as a bug!");
}
}
throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes + ". However, "