Skip to content

Commit d89a35c

Browse files
authored
Need to add "raw" as a node/container level request writer (#4123)
This follows up PR#4073 to complete the migration.
1 parent d54f49a commit d89a35c

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

solr/core/src/java/org/apache/solr/response/ResponseWritersRegistry.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ private ResponseWritersRegistry() {
5555
jsonWriter, // Alias for JSON
5656
"xml",
5757
new XMLResponseWriter(),
58+
"raw",
59+
new RawResponseWriter(),
5860
PROMETHEUS_METRICS_WT,
5961
prometheusWriter,
6062
OPEN_METRICS_WT,
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.solr.handler.admin;
18+
19+
import java.io.IOException;
20+
import org.apache.solr.client.solrj.SolrClient;
21+
import org.apache.solr.client.solrj.SolrRequest;
22+
import org.apache.solr.client.solrj.SolrServerException;
23+
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
24+
import org.apache.solr.client.solrj.request.GenericSolrRequest;
25+
import org.apache.solr.client.solrj.response.SimpleSolrResponse;
26+
import org.apache.solr.client.solrj.response.json.JsonMapResponseParser;
27+
import org.apache.solr.cloud.SolrCloudTestCase;
28+
import org.apache.solr.common.params.CommonParams;
29+
import org.apache.solr.common.params.ModifiableSolrParams;
30+
import org.apache.solr.common.util.NamedList;
31+
import org.junit.BeforeClass;
32+
import org.junit.Test;
33+
34+
/** Basic tests for {@link ZookeeperInfoHandler} */
35+
public class ZookeeperInfoHandlerTest extends SolrCloudTestCase {
36+
37+
@BeforeClass
38+
public static void setupCluster() throws Exception {
39+
configureCluster(1).addConfig("conf", configset("cloud-minimal")).configure();
40+
}
41+
42+
@Test
43+
public void testZkInfoHandler() throws SolrServerException, IOException {
44+
SolrClient client = cluster.getSolrClient();
45+
46+
ModifiableSolrParams params = new ModifiableSolrParams();
47+
params.set(CommonParams.PATH, "/");
48+
params.set("detail", "true");
49+
GenericSolrRequest req =
50+
new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/zookeeper", params);
51+
req.setResponseParser(new JsonMapResponseParser());
52+
53+
NamedList<Object> response = client.request(req);
54+
assertNotNull("Response should not be null", response);
55+
56+
// ZK handler should return 'znode' for detail requests
57+
assertNotNull(response.get("znode"));
58+
}
59+
60+
@Test
61+
public void testZkInfoHandlerCollectionsView() throws Exception {
62+
// Create a test collection first
63+
String collectionName = "zkinfo_test_collection";
64+
CollectionAdminRequest.createCollection(collectionName, "conf", 1, 1)
65+
.process(cluster.getSolrClient());
66+
cluster.waitForActiveCollection(collectionName, 1, 1);
67+
68+
SolrClient client = cluster.getSolrClient();
69+
// Test collections view (graph view with clusterstate.json)
70+
ModifiableSolrParams params = new ModifiableSolrParams();
71+
params.set(CommonParams.PATH, "/clusterstate.json");
72+
params.set("view", "graph");
73+
74+
GenericSolrRequest req =
75+
new GenericSolrRequest(SolrRequest.METHOD.GET, "/admin/zookeeper", params);
76+
req.setResponseParser(new JsonMapResponseParser());
77+
78+
// Verify the request completes and returns collection data
79+
SimpleSolrResponse response = req.process(client);
80+
NamedList<Object> responseData = response.getResponse();
81+
82+
// Collections view should return znode with collection data
83+
assertNotNull("Response should not be null", responseData);
84+
85+
assertNotNull(
86+
"Response should contain 'znode' for collections view", responseData.get("znode"));
87+
}
88+
}

0 commit comments

Comments
 (0)