This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch mp7 in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 0b21e2c719cea85f5aa0c274070dd98df8d64e26 Author: Richard Zowalla <[email protected]> AuthorDate: Tue Mar 17 19:04:00 2026 +0100 Fault Tolerance 4.1 TCK: all 439 tests pass - Exclude old MP Metrics-based tests (org.eclipse.microprofile.fault.tolerance.tck.metrics.**) replaced by *TelemetryTest variants in FT 4.1 - Add GlobalOpenTelemetryResetListener (ServletContainerInitializer) to reset GlobalOpenTelemetry before each deployment, enabling OTel SDK re-initialization with app-specific ServiceLoader providers (InMemoryMetricReader) - Set reuseForks=false to ensure clean OTel state per test class --- tck/microprofile-tck/fault-tolerance/pom.xml | 6 +++- .../GlobalOpenTelemetryResetListener.java | 37 ++++++++++++++++++++++ ...roProfileFaultToleranceDeploymentProcessor.java | 11 +++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/tck/microprofile-tck/fault-tolerance/pom.xml b/tck/microprofile-tck/fault-tolerance/pom.xml index 69ea748821..683d6dc57c 100644 --- a/tck/microprofile-tck/fault-tolerance/pom.xml +++ b/tck/microprofile-tck/fault-tolerance/pom.xml @@ -35,12 +35,16 @@ <artifactId>maven-surefire-plugin</artifactId> <version>3.5.5</version> <configuration> - <reuseForks>true</reuseForks> + <reuseForks>false</reuseForks> <forkCount>1</forkCount> <dependenciesToScan> <dependency>org.eclipse.microprofile.fault-tolerance:microprofile-fault-tolerance-tck</dependency> </dependenciesToScan> <trimStackTrace>false</trimStackTrace> + <excludes> + <!-- Old MP Metrics-based tests - MP Metrics removed in MP 7.1, replaced by *TelemetryTest --> + <exclude>org.eclipse.microprofile.fault.tolerance.tck.metrics.**</exclude> + </excludes> <systemPropertyVariables> <java.io.tmpdir>./target</java.io.tmpdir> </systemPropertyVariables> diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/GlobalOpenTelemetryResetListener.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/GlobalOpenTelemetryResetListener.java new file mode 100644 index 0000000000..456752112c --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/GlobalOpenTelemetryResetListener.java @@ -0,0 +1,37 @@ +/* + * 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.tomee.microprofile.tck.fault.tolerance; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import jakarta.servlet.ServletContainerInitializer; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; + +import java.util.Set; + +/** + * Resets GlobalOpenTelemetry before each app deployment so that the OTel SDK + * is re-initialized with the app's ServiceLoader providers (e.g. InMemoryMetricReader + * for telemetry tests). Uses ServletContainerInitializer to run before CDI startup. + */ +public class GlobalOpenTelemetryResetListener implements ServletContainerInitializer { + + @Override + public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException { + GlobalOpenTelemetry.resetForTest(); + } +} diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java index 77c7913f7b..4848b5be78 100644 --- a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java +++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java @@ -20,9 +20,11 @@ import org.jboss.arquillian.test.spi.TestClass; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; +import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.container.ClassContainer; import org.jboss.shrinkwrap.api.container.LibraryContainer; import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; import java.util.logging.Logger; @@ -49,5 +51,14 @@ public class MicroProfileFaultToleranceDeploymentProcessor implements Applicatio if (!applicationArchive.contains("META-INF/beans.xml")) { applicationArchive.add(EmptyAsset.INSTANCE, "META-INF/beans.xml"); } + + // Reset GlobalOpenTelemetry before each deployment so the OTel SDK is + // re-initialized with app-specific ServiceLoader providers + if (applicationArchive instanceof WebArchive webapp) { + webapp.addClass(GlobalOpenTelemetryResetListener.class); + webapp.addAsResource( + new StringAsset(GlobalOpenTelemetryResetListener.class.getName()), + "META-INF/services/jakarta.servlet.ServletContainerInitializer"); + } } }
