From 996d5da51557371091b03c6f9ae7e46d2177889f Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Wed, 19 Feb 2025 16:47:54 -0500 Subject: [PATCH] NO-JIRA Removing RetryRule --- pom.xml | 10 +- .../broker/artemiswrapper/RetryRule.java | 133 ------------------ .../failover/FailoverClusterTest.java | 5 - 3 files changed, 1 insertion(+), 147 deletions(-) delete mode 100644 tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/RetryRule.java diff --git a/pom.xml b/pom.xml index 4fe14cbbb4..b78571afc2 100644 --- a/pom.xml +++ b/pom.xml @@ -83,7 +83,6 @@ 17 17 - false log4j2-tests-config.properties --add-modules java.sql,jdk.unsupported @@ -254,7 +253,7 @@ ${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version} - -Dorg.apache.activemq.artemis.utils.RetryRule.retry=${retryTests} -Dbrokerconfig.maxDiskUsage=100 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_QUIET_PERIOD=0 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_SHUTDOWN_TIMEOUT=0 + -Dbrokerconfig.maxDiskUsage=100 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_QUIET_PERIOD=0 -Dorg.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_SHUTDOWN_TIMEOUT=0 -Djava.library.path="${activemq.basedir}/target/bin/lib/linux-x86_64:${activemq.basedir}/target/bin/lib/linux-i686" -Djgroups.bind_addr=localhost -Djava.net.preferIPv4Stack=true -Dbasedir=${basedir} -Djdk.attach.allowAttachSelf=true @@ -503,13 +502,6 @@ - - - tests-retry - - true - - diff --git a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/RetryRule.java b/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/RetryRule.java deleted file mode 100644 index 237d3eaee5..0000000000 --- a/tests/activemq5-unit-tests/src/main/java/org/apache/activemq/broker/artemiswrapper/RetryRule.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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.activemq.broker.artemiswrapper; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.lang.invoke.MethodHandles; - -import org.junit.internal.AssumptionViolatedException; -import org.junit.rules.MethodRule; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.Statement; - -/** - * Please use this only if you have to. - * Try to fix the test first. - */ -public class RetryRule implements MethodRule { - - public static final String PROPERTY_NAME = "org.apache.activemq.artemis.utils.RetryRule.retry"; - - private static Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - final int defaultNumberOfRetries; - final boolean retrySuccess; - - public RetryRule() { - this(0); - } - - public RetryRule(int defaultNumberOfRetries) { - this.defaultNumberOfRetries = defaultNumberOfRetries; - this.retrySuccess = false; - } - - /** - * - * @param defaultNumberOfRetries - * @param retrySuccess if true, it will keep retrying until it failed or the number of retries have reached an end, opposite rule. - */ - public RetryRule(int defaultNumberOfRetries, boolean retrySuccess) { - this.defaultNumberOfRetries = defaultNumberOfRetries; - this.retrySuccess = retrySuccess; - } - - private int getNumberOfRetries(final FrameworkMethod method) { - - if (!Boolean.parseBoolean(System.getProperty(PROPERTY_NAME))) { - return 0; - } - RetryMethod retry = method.getAnnotation(RetryMethod.class); - if (retry != null) { - return retry.retries(); - } else { - return defaultNumberOfRetries; - } - } - - @Override - public Statement apply(final Statement base, final FrameworkMethod method, Object target) { - if (retrySuccess) { - return retrySuccess(base, method, target); - } else { - return retryIfFailed(base, method, target); - } - } - - protected Statement retrySuccess(Statement base, FrameworkMethod method, Object target) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - int retries = getNumberOfRetries(method) + 1; - for (int i = 0; i < retries; i++) { - logger.warn("LOOP {}", i); - base.evaluate(); - } - } - }; - } - - - protected Statement retryIfFailed(Statement base, FrameworkMethod method, Object target) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - Throwable currentException = null; - try { - base.evaluate(); - } catch (Throwable t) { - - if (t instanceof AssumptionViolatedException) { - throw t; - } - - currentException = t; - - int retries = getNumberOfRetries(method); - - for (int retryNr = 0; retryNr < retries; retryNr++) { - logger.warn("RETRY {} of {} on {}::{}", (retryNr + 1), retries, target.getClass(), method.getName(), currentException); - currentException = null; - try { - base.evaluate(); - logger.warn("RETRY {} of {} on {}::{} succeeded", (retryNr + 1), retries, target.getClass(), method.getName()); - break; - } catch (Throwable t2) { - logger.warn("RETRY {} of {} on {}::{} failed", (retryNr + 1), retries, target.getClass(), method.getName(), t2); - currentException = t2; - } - } - if (currentException != null) { - throw currentException; - } - } - } - }; - } -} \ No newline at end of file diff --git a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java index 4795b5054d..d0a809b0e0 100644 --- a/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java +++ b/tests/activemq5-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverClusterTest.java @@ -35,18 +35,13 @@ import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl; import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS; import org.apache.activemq.broker.artemiswrapper.OpenwireArtemisBaseTest; -import org.apache.activemq.broker.artemiswrapper.RetryRule; import org.junit.After; import org.junit.Assert; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; public class FailoverClusterTest extends OpenwireArtemisBaseTest { - @Rule - public RetryRule retryRule = new RetryRule(2); - private static final int NUMBER = 10; private String clientUrl;