This is an automated email from the ASF dual-hosted git repository. jlmonteiro pushed a commit to branch fault-tolerance in repository https://gitbox.apache.org/repos/asf/tomee.git
commit d3891f20b36bb4bbda1978779d4960024ac745e7 Author: Jean-Louis Monteiro <[email protected]> AuthorDate: Mon Sep 12 19:01:08 2022 +0200 Initial commit for Fault Tolerance --- boms/tomee-microprofile/pom.xml | 35 +++++++++++++- boms/tomee-plume/pom.xml | 35 +++++++++++++- boms/tomee-plus/pom.xml | 35 +++++++++++++- pom.xml | 2 +- tck/microprofile-tck/fault-tolerance/pom.xml | 13 ++--- .../tck/fault/tolerance/LoggingTestListener.java | 56 ++++++++++++++++++++++ ...roProfileFaultToleranceDeploymentProcessor.java | 53 ++++++++++++++++++++ .../MicroProfileFaultToleranceExtension.java | 30 ++++++++++++ .../tck/fault/tolerance/RetryTckOnMac.java | 56 ++++++++++++++++++++++ ...org.jboss.arquillian.core.spi.LoadableExtension | 1 + .../src/test/resources/arquillian.xml | 1 + tck/microprofile-tck/fault-tolerance/tck-dev.xml | 25 ++++++++++ tck/microprofile-tck/pom.xml | 2 +- tomee/tomee-microprofile/mp-common/pom.xml | 2 +- .../microprofile/TomEEMicroProfileListener.java | 1 + 15 files changed, 331 insertions(+), 16 deletions(-) diff --git a/boms/tomee-microprofile/pom.xml b/boms/tomee-microprofile/pom.xml index 996d744a03..ac0dc7ca83 100644 --- a/boms/tomee-microprofile/pom.xml +++ b/boms/tomee-microprofile/pom.xml @@ -364,10 +364,43 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance-api</artifactId> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance-autoconfig-core</artifactId> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.smallrye</groupId> <artifactId>smallrye-fault-tolerance-core</artifactId> - <version>6.0.0-RC1</version> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance</artifactId> + <version>6.0.0-RC4</version> <exclusions> <exclusion> <artifactId>*</artifactId> diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml index 247953c7e2..497bc3fb66 100644 --- a/boms/tomee-plume/pom.xml +++ b/boms/tomee-plume/pom.xml @@ -375,10 +375,43 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance-api</artifactId> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance-autoconfig-core</artifactId> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.smallrye</groupId> <artifactId>smallrye-fault-tolerance-core</artifactId> - <version>6.0.0-RC1</version> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance</artifactId> + <version>6.0.0-RC4</version> <exclusions> <exclusion> <artifactId>*</artifactId> diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml index 91e16806b6..8d734339e4 100644 --- a/boms/tomee-plus/pom.xml +++ b/boms/tomee-plus/pom.xml @@ -386,10 +386,43 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance-api</artifactId> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance-autoconfig-core</artifactId> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>io.smallrye</groupId> <artifactId>smallrye-fault-tolerance-core</artifactId> - <version>6.0.0-RC1</version> + <version>6.0.0-RC4</version> + <exclusions> + <exclusion> + <artifactId>*</artifactId> + <groupId>*</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.smallrye</groupId> + <artifactId>smallrye-fault-tolerance</artifactId> + <version>6.0.0-RC4</version> <exclusions> <exclusion> <artifactId>*</artifactId> diff --git a/pom.xml b/pom.xml index 875b11b4b6..ba36fdc70a 100644 --- a/pom.xml +++ b/pom.xml @@ -228,7 +228,7 @@ <microprofile.fault-tolerance.version>4.0</microprofile.fault-tolerance.version> <microprofile.fault-tolerance.tck.version>4.0</microprofile.fault-tolerance.tck.version> - <microprofile.fault-tolerance.impl.version>6.0.0-RC1</microprofile.fault-tolerance.impl.version> + <microprofile.fault-tolerance.impl.version>6.0.0-RC4</microprofile.fault-tolerance.impl.version> <microprofile.health.version>4.0</microprofile.health.version> <microprofile.health.tck.version>4.0</microprofile.health.tck.version> diff --git a/tck/microprofile-tck/fault-tolerance/pom.xml b/tck/microprofile-tck/fault-tolerance/pom.xml index 766bdfd91b..2ebad16765 100644 --- a/tck/microprofile-tck/fault-tolerance/pom.xml +++ b/tck/microprofile-tck/fault-tolerance/pom.xml @@ -84,16 +84,9 @@ <dependencies> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>microprofile-fault-tolerance-api-shade</artifactId> - <version>${project.version}</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.eclipse.microprofile.fault-tolerance</groupId> - <artifactId>microprofile-fault-tolerance-api</artifactId> - </exclusion> - </exclusions> + <groupId>org.eclipse.microprofile.fault-tolerance</groupId> + <artifactId>microprofile-fault-tolerance-api</artifactId> + <version>${microprofile.fault-tolerance.version}</version> </dependency> <dependency> diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/LoggingTestListener.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/LoggingTestListener.java new file mode 100644 index 0000000000..bf2abd9c7c --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/LoggingTestListener.java @@ -0,0 +1,56 @@ +/* + * Copyright 2017 Red Hat, Inc, and individual contributors. + * + * Licensed 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 org.testng.ITestContext; +import org.testng.ITestListener; +import org.testng.ITestResult; + + +public class LoggingTestListener implements ITestListener { + + @Override + public void onTestStart(ITestResult result) { + System.out.println("Starting " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName()); + } + + @Override + public void onTestSuccess(ITestResult result) { + System.out.println("Succeeded " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName()); + } + + @Override + public void onTestFailure(ITestResult result) { + System.out.println("Failed " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName()); + } + + @Override + public void onTestSkipped(ITestResult result) { + System.out.println("Skipped " + result.getTestClass().getName() + "#" + result.getMethod().getMethodName()); + } + + @Override + public void onTestFailedButWithinSuccessPercentage(ITestResult result) { + } + + @Override + public void onStart(ITestContext context) { + } + + @Override + public void onFinish(ITestContext context) { + } +} 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 new file mode 100644 index 0000000000..77c7913f7b --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceDeploymentProcessor.java @@ -0,0 +1,53 @@ +/* + * Copyright 2017 Red Hat, Inc, and individual contributors. + * + * Licensed 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 org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +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.container.ClassContainer; +import org.jboss.shrinkwrap.api.container.LibraryContainer; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +import java.util.logging.Logger; + +public class MicroProfileFaultToleranceDeploymentProcessor implements ApplicationArchiveProcessor { + + private static final Logger LOGGER = Logger.getLogger(MicroProfileFaultToleranceDeploymentProcessor.class.getName()); + + @Override + public void process(Archive<?> applicationArchive, TestClass testClass) { + if (!(applicationArchive instanceof ClassContainer)) { + LOGGER.warning("Unable to add additional classes - not a class/resource container: " + applicationArchive); + return; + } + ClassContainer<?> classContainer = (ClassContainer<?>) applicationArchive; + + if (applicationArchive instanceof LibraryContainer) { + JavaArchive additionalBeanArchive = ShrinkWrap.create(JavaArchive.class); + additionalBeanArchive.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + ((LibraryContainer<?>) applicationArchive).addAsLibrary(additionalBeanArchive); + } else { + classContainer.addAsResource(EmptyAsset.INSTANCE, "META-INF/beans.xml"); + } + + if (!applicationArchive.contains("META-INF/beans.xml")) { + applicationArchive.add(EmptyAsset.INSTANCE, "META-INF/beans.xml"); + } + } +} diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceExtension.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceExtension.java new file mode 100644 index 0000000000..ec2d53d811 --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/MicroProfileFaultToleranceExtension.java @@ -0,0 +1,30 @@ +/* + * 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 org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; + +public class MicroProfileFaultToleranceExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder builder) { + builder.service(ApplicationArchiveProcessor.class, MicroProfileFaultToleranceDeploymentProcessor.class); + builder.service(ApplicationArchiveProcessor.class, RetryTckOnMac.class); + } + +} diff --git a/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/RetryTckOnMac.java b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/RetryTckOnMac.java new file mode 100644 index 0000000000..73fe71da29 --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/src/test/java/org/apache/tomee/microprofile/tck/fault/tolerance/RetryTckOnMac.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.tomee.microprofile.tck.fault.tolerance; + +import org.eclipse.microprofile.fault.tolerance.tck.RetryTest; +import org.eclipse.microprofile.fault.tolerance.tck.config.ConfigAnnotationAsset; +import org.eclipse.microprofile.fault.tolerance.tck.retry.clientserver.RetryClassLevelClientForMaxRetries; +import org.eclipse.microprofile.faulttolerance.Retry; +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; + +import java.util.Locale; + +/** + * Copied from SmallRye Fault Tolerance + */ +public class RetryTckOnMac implements ApplicationArchiveProcessor { + // TODO + // The `RetryTest.testClassLevelRetryMaxDuration` TCK test often fails in CI on the macOS machines. + // This is because the test doesn't properly scale delays and timeouts, unlike majority of the tests + // in the TCK, and `Thread.sleep(100)` often takes roughly 200 millis on the macOS machines in CI. + // Here, we work around that problem by reducing jitter on the affected method to 0, thereby significantly + // reducing the impact of the `Thread.sleep()` slowdown. + + @Override + public void process(Archive<?> applicationArchive, TestClass testClass) { + if (isMac() && RetryTest.class.getName().equals(testClass.getName())) { + ConfigAnnotationAsset config = (ConfigAnnotationAsset) applicationArchive + .getAsType(JavaArchive.class, "/WEB-INF/lib/ftRetry.jar") + .get("/META-INF/microprofile-config.properties") + .getAsset(); + config.set(RetryClassLevelClientForMaxRetries.class, "serviceB", Retry.class, "jitter", "0"); + } + } + + private boolean isMac() { + String os = System.getProperty("os.name", "unknown").toLowerCase(Locale.ROOT); + return os.contains("mac") || os.contains("darwin"); + } +} diff --git a/tck/microprofile-tck/fault-tolerance/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/tck/microprofile-tck/fault-tolerance/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000000..b468993d5e --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1 @@ +org.apache.tomee.microprofile.tck.fault.tolerance.MicroProfileFaultToleranceExtension \ No newline at end of file diff --git a/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml b/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml index 9fc654b381..a4f0db9288 100644 --- a/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml +++ b/tck/microprofile-tck/fault-tolerance/src/test/resources/arquillian.xml @@ -26,6 +26,7 @@ <property name="httpPort">-1</property> <property name="ajpPort">-1</property> <property name="stopPort">-1</property> + <property name="debug">true</property> <property name="classifier">microprofile</property> <property name="conf">src/test/conf</property> <property name="dir">target/tomee</property> diff --git a/tck/microprofile-tck/fault-tolerance/tck-dev.xml b/tck/microprofile-tck/fault-tolerance/tck-dev.xml new file mode 100644 index 0000000000..ddd61fb854 --- /dev/null +++ b/tck/microprofile-tck/fault-tolerance/tck-dev.xml @@ -0,0 +1,25 @@ +<!-- + 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. + --> +<suite name="microprofile-fault-tolerance-TCK" verbose="2" configfailurepolicy="continue" > + + <test name="microprofile-fault-tolerance TCK"> + <classes> + <class name="org.eclipse.microprofile.fault.tolerance.tck.CircuitBreakerLateSuccessTest"></class> + </classes> + </test> + +</suite> \ No newline at end of file diff --git a/tck/microprofile-tck/pom.xml b/tck/microprofile-tck/pom.xml index da59e095b7..ea598abf6d 100644 --- a/tck/microprofile-tck/pom.xml +++ b/tck/microprofile-tck/pom.xml @@ -36,9 +36,9 @@ <module>metrics</module> <module>rest-client</module> <module>openapi</module> + <module>fault-tolerance</module> <!-- <module>opentracing</module> - <module>fault-tolerance</module> --> </modules> </project> diff --git a/tomee/tomee-microprofile/mp-common/pom.xml b/tomee/tomee-microprofile/mp-common/pom.xml index 8e7b1dcd47..fe376ccc9a 100644 --- a/tomee/tomee-microprofile/mp-common/pom.xml +++ b/tomee/tomee-microprofile/mp-common/pom.xml @@ -101,7 +101,7 @@ <dependency> <groupId>io.smallrye</groupId> - <artifactId>smallrye-fault-tolerance-core</artifactId> + <artifactId>smallrye-fault-tolerance</artifactId> <version>${microprofile.fault-tolerance.impl.version}</version> <exclusions> <exclusion> diff --git a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java index 4b3502a9b0..23a1920d15 100644 --- a/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java +++ b/tomee/tomee-microprofile/mp-common/src/main/java/org/apache/tomee/microprofile/TomEEMicroProfileListener.java @@ -56,6 +56,7 @@ public class TomEEMicroProfileListener { "io.smallrye.config.inject.ConfigExtension", "io.smallrye.metrics.setup.MetricCdiInjectionExtension", "io.smallrye.opentracing.SmallRyeTracingDynamicFeature", + "io.smallrye.faulttolerance.FaultToleranceExtension", }; @SuppressWarnings("Duplicates")
