This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-mcp.git
The following commit(s) were added to refs/heads/main by this push:
new 20ecacba test(observability): re-enable OtlpExportIntegrationTest
(#198)
20ecacba is described below
commit 20ecacbafcacfa402e20238ad8906aa88872e0cb
Author: Aditya Parikh <[email protected]>
AuthorDate: Wed Sep 16 10:26:37 2026 -0400
test(observability): re-enable OtlpExportIntegrationTest (#198)
* test(observability): re-enable OtlpExportIntegrationTest
The class had been @Disabled since #41 because starting the Grafana LGTM
Testcontainer threw a ClassNotFoundException for
org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP. The Jetty
pin has since moved with the SolrJ 10 bump, jetty-client 12.0.34 is on the
test runtime classpath and contains that class, and the container now
starts cleanly.
With the annotation removed, three methods failed with
AuthenticationCredentialsNotFoundException: the test calls @PreAuthorize
service methods directly, with no MCP request and hence no principal. Rather
than switch http.security.enabled off, the test authenticates its own thread
with a TestingAuthenticationToken in @BeforeEach and clears it in
@AfterEach, so method security stays active while OTLP export is verified.
All seven methods pass; the build no longer reports any skipped tests.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_019zJ9WA8nNyA5Yxb8ueM7vV
Signed-off-by: Aditya Parikh <[email protected]>
* test(observability): drop stale disabled-note and redundant
setAuthenticated
The class javadoc still said the test was disabled for a Jetty
ClassNotFoundException; that paragraph now describes the LGTM container and
the self-authenticated test thread. TestingAuthenticationToken's authorities
constructor already marks the token authenticated, so the explicit call
goes.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ
Signed-off-by: Aditya Parikh <[email protected]>
---------
Signed-off-by: Aditya Parikh <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
---
.../observability/OtlpExportIntegrationTest.java | 34 +++++++++++++++-------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git
a/src/test/java/org/apache/solr/mcp/server/observability/OtlpExportIntegrationTest.java
b/src/test/java/org/apache/solr/mcp/server/observability/OtlpExportIntegrationTest.java
index 2c83aae4..2001521f 100644
---
a/src/test/java/org/apache/solr/mcp/server/observability/OtlpExportIntegrationTest.java
+++
b/src/test/java/org/apache/solr/mcp/server/observability/OtlpExportIntegrationTest.java
@@ -27,14 +27,17 @@ import
org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.mcp.server.TestcontainersConfiguration;
import org.apache.solr.mcp.server.indexing.IndexingService;
import org.apache.solr.mcp.server.search.SearchService;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import
org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Import;
+import org.springframework.security.authentication.TestingAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.context.ActiveProfiles;
import org.testcontainers.grafana.LgtmStackContainer;
import org.testcontainers.junit.jupiter.Container;
@@ -64,16 +67,10 @@ import org.testcontainers.junit.jupiter.Testcontainers;
* container integration which auto-configures OTLP export endpoints.
*
* <p>
- * <b>NOTE:</b> This test is currently disabled due to a Jetty HTTP client
- * ClassNotFoundException when using LgtmStackContainer. The
- * testcontainers-grafana module requires
- * {@code org.eclipse.jetty.client.transport.HttpClientTransportOverHTTP} which
- * is not properly resolved with the current Jetty BOM configuration. This is a
- * known issue and can be addressed separately. The core distributed tracing
- * functionality is tested by {@link DistributedTracingTest} which uses
- * SimpleTracer and passes all tests successfully.
+ * Runs against a real LGTM container and authenticates its own thread, because
+ * the http profile keeps method security on. {@link DistributedTracingTest}
+ * covers the same tracing paths in-memory without a container.
*/
-@Disabled("Jetty HTTP client ClassNotFoundException with LgtmStackContainer -
see class javadoc")
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {
@@ -118,6 +115,23 @@ class OtlpExportIntegrationTest {
createRequest.process(solrClient);
}
+ /**
+ * The http profile keeps secure-by-default on, so the {@code
@PreAuthorize}
+ * service methods this test calls directly need an authenticated
principal.
+ * Over MCP the OAuth2 filter chain supplies one; here the test thread
does,
+ * which keeps method security active rather than switching it off.
+ */
+ @BeforeEach
+ void authenticateTestThread() {
+ var authentication = new
TestingAuthenticationToken("otlp-test", null, "ROLE_USER");
+
SecurityContextHolder.getContext().setAuthentication(authentication);
+ }
+
+ @AfterEach
+ void clearAuthentication() {
+ SecurityContextHolder.clearContext();
+ }
+
@Test
void shouldExportTracesWithoutErrors() throws Exception {
// Given: Some test data