jerryshao commented on code in PR #12922:
URL: https://github.com/apache/gravitino/pull/12922#discussion_r3933728555


##########
iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/TestRESTService.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.gravitino.iceberg;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import org.junit.jupiter.api.Test;
+
+public class TestRESTService {
+
+  /**
+   * RESTService.initServer() previously registered /metrics and 
/prometheus/metrics (added by
+   * JettyServer#initialize() itself, outside ICEBERG_SPEC) with no audit 
coverage at all, and
+   * nothing in the build caught it. This test pins the fix by inspecting the 
source directly, since
+   * RESTService's initServer() has too many external dependencies (catalog 
backends, config
+   * providers) to boot in a plain unit test. See GH-12760.
+   */
+  @Test
+  public void testMetricsPathsHaveAuditFilterCoverage() throws IOException {
+    Path sourceFile = 
Path.of("src/main/java/org/apache/gravitino/iceberg/RESTService.java");
+    String source = Files.readString(sourceFile);
+
+    int loopStart = source.indexOf("for (String pathSpec : METRICS_PATHS)");
+    assertTrue(
+        loopStart >= 0,
+        "RESTService must wire filters onto every path in METRICS_PATHS, see 
GH-12760");
+
+    int loopEnd = source.indexOf("}", loopStart);
+    assertTrue(loopEnd > loopStart, "Malformed METRICS_PATHS filter loop");
+
+    String loopBody = source.substring(loopStart, loopEnd);

Review Comment:
   Fixed in both TestRESTService and TestLanceRESTService — extracted the 
filter-registration logic into a package-private static 
registerMetricsPathFilters(JettyServer, EventBus) in each service, and the 
tests now exercise it directly against a plain JettyServer + real 
ServletHandler introspection instead of parsing source text. Verified each test 
actually fails when the coverage it checks is broken.



-- 
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]

Reply via email to