igiguere commented on code in PR #4057:
URL: https://github.com/apache/solr/pull/4057#discussion_r2713970574


##########
solr/core/src/test/org/apache/solr/handler/admin/api/GetMetricsTest.java:
##########
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.handler.admin.api;
+
+import jakarta.ws.rs.core.StreamingOutput;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.Map;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.core.CoreContainer;
+import org.apache.solr.metrics.MetricsUtil;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.apache.solr.response.SolrQueryResponse;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class GetMetricsTest extends SolrTestCaseJ4 {
+
+  private static CoreContainer cc;
+  private static Path outputPath;
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig-minimal.xml", "schema.xml");
+    h.getCoreContainer().waitForLoadingCoresToFinish(30000);
+    cc = h.getCoreContainer();
+    outputPath = createTempDir();
+  }
+
+  @AfterClass
+  public static void afterClass() throws Exception {
+    SolrTestCaseJ4.teardownTestCases();
+  }
+
+  @Test
+  public void testGetMetricsDefault() throws IOException {
+    String expectedHelp = "# HELP solr_core_disk_space_megabytes";
+    String expectedType = "# TYPE solr_core_disk_space_megabytes";
+    String expectedDiskSpaceMetric =
+        """
+        
solr_core_disk_space_megabytes{category="CORE",core="collection1",otel_scope_name="org.apache.solr",type="total_space"}
+        """;
+    SolrQueryRequest req = new SolrQueryRequestBase(h.getCore(), new 
ModifiableSolrParams()) {};
+    SolrQueryResponse resp = new SolrQueryResponse();
+
+    GetMetrics get = new GetMetrics(cc, req, resp);

Review Comment:
   I see that at least some of the tests for the JAX-RS V2 APIs 
(GetSchemaAPITest, RelaodCoreAPITest, maybe others) also  instantiate the API 
implementation class, and invoke it directly.
   To send a HTTP request, the most useful classes and methods are deprecated, 
and in the process of being changed (there's another PR for that), so adding 
more tests using these methods would mean more refactoring at the time of 
merging this.
   I'll see what I can do without using the existing deprecated HTTP request 
helpers... But, if I have too much trouble, I'll leave the tests as they are.
     



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to