SOLR-13484:

autoscaling/diagnostics APIshould be able to give diagnostics output from config pasted as a payload
This commit is contained in:
noble 2019-05-22 16:22:20 +10:00
parent 87e936f1bb
commit 750a5fdd02
2 changed files with 28 additions and 4 deletions

View File

@ -144,11 +144,15 @@ public class AutoScalingHandler extends RequestHandlerBase implements Permission
if (path != null) {
List<String> parts = StrUtils.splitSmart(path, '/');
if (parts.get(0).isEmpty()) parts.remove(0);
if (parts.size() == 3 && SUGGESTIONS.equals(parts.get(2))) {
if(parts.size() == 3) {
Map map = (Map) Utils.fromJSON(req.getContentStreams().iterator().next().getStream());
AutoScalingConfig config = new AutoScalingConfig(map);
handleSuggestions(rsp, config);
return;
if (SUGGESTIONS.equals(parts.get(2))) {
handleSuggestions(rsp, new AutoScalingConfig(map));
return;
} else if (DIAGNOSTICS.equals(parts.get(2))) {
handleDiagnostics(rsp, new AutoScalingConfig(map));
return;
}
}
}

View File

@ -127,6 +127,26 @@ public class AutoScalingHandlerTest extends SolrCloudTestCase {
CollectionAdminRequest.deleteCollection(COLLNAME)
.process(cluster.getSolrClient());
}
public void testDiagnosticsWithPayload() throws Exception {
CloudSolrClient solrClient = cluster.getSolrClient();
String COLLNAME = "testDiagnosticsWithPayload.COLL";
CollectionAdminResponse adminResponse = CollectionAdminRequest.createCollection(COLLNAME, CONFIGSET_NAME, 1, 2)
.setMaxShardsPerNode(4)
.process(solrClient);
cluster.waitForActiveCollection(COLLNAME, 1, 2);
DocCollection collection = solrClient.getClusterStateProvider().getCollection(COLLNAME);
Replica aReplica = collection.getReplicas().get(0);
String configPayload = "{\n" +
" 'cluster-policy': [{'replica': 0, 'node': '_NODE'}]\n" +
"}";
configPayload = configPayload.replaceAll("_NODE", aReplica.getNodeName());
SolrRequest req = AutoScalingRequest.create(SolrRequest.METHOD.POST, "/diagnostics", configPayload);
NamedList<Object> response = solrClient.request(req);
assertEquals(response._getStr("diagnostics/violations[0]/node",null),response._getStr("diagnostics/violations[0]/node",null));
CollectionAdminRequest.deleteCollection(COLLNAME)
.process(cluster.getSolrClient());
}
@Test
public void testSuspendTrigger() throws Exception {