From 242e9ac838134ec3f69b587b6cdba71e2d393d9d Mon Sep 17 00:00:00 2001 From: Radoslav Husar Date: Thu, 28 Sep 2017 01:51:53 +0200 Subject: [PATCH] WFLY-9371 Fix failing RemoteEJBTwoClusterTestCase * fix regression where all nodes clustered together instead of 2 clusters * do not rename caches; only rename cluster * remove the logic that tolerated 10% failure rate; fail immediatelly * make it run by default * simplify deployments per test case * remove deprecated @Clustered anotation * expand the test case variants using ejb client api * fix intermittent failures using graceful shutdown * code cleanup * don't create unnecessary -tmp dirs * heavy cleanup of unncessary scripting, targets --- testsuite/integration/clustering/pom.xml | 17 +- .../clustering/ClusteringTestConstants.java | 6 - .../AbstractRemoteEJBTwoClusterTestCase.java | 216 ++++++++++ .../NonTxClientEJBTwoClusterTestCase.java | 37 ++ .../NonTxRemoteEJBTwoClusterTestCase.java | 82 ++++ .../RemoteEJBTwoClusterTestCase.java | 370 ------------------ .../TxClientEJBTwoClusterTestCase.java | 37 ++ .../TxRemoteEJBTwoClusterTestCase.java | 82 ++++ .../twoclusters/bean/SerialBean.java | 39 -- .../bean/common/CommonStatefulSB.java | 27 +- .../bean/common/CommonStatefulSBImpl.java | 51 ++- .../AbstractForwardingStatefulSBImpl.java | 69 ++-- .../forwarding/ForwardingStatefulSBImpl.java | 36 +- .../NonTxForwardingStatefulSBImpl.java | 31 +- .../bean/stateful/LocalStatefulSB.java | 20 - .../bean/stateful/RemoteStatefulSB.java | 25 +- .../bean/stateful/RemoteStatefulSBImpl.java | 30 +- .../forwarder-jboss-ejb-client.properties | 37 -- .../twoclusters/jboss-ejb-client.xml | 38 +- .../src/test/scripts/clustering-build.xml | 29 +- .../scripts/clustering-common-targets.xml | 108 +---- .../src/test/scripts/common-targets.xml | 4 +- .../integration/src/test/xslt/addChannel.xsl | 30 -- .../xslt/changeCacheContainerChannelName.xsl | 56 --- .../test/xslt/changeCacheContainerName.xsl | 37 -- .../src/test/xslt/changeClusterName.xsl | 58 +++ .../changeEJBRemoteConnectorClusterName.xsl | 53 --- ...angePassivationStoreCacheContainerName.xsl | 56 --- 28 files changed, 742 insertions(+), 939 deletions(-) create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/AbstractRemoteEJBTwoClusterTestCase.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxClientEJBTwoClusterTestCase.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxRemoteEJBTwoClusterTestCase.java delete mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/RemoteEJBTwoClusterTestCase.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxClientEJBTwoClusterTestCase.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxRemoteEJBTwoClusterTestCase.java delete mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/SerialBean.java delete mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/LocalStatefulSB.java delete mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/forwarder-jboss-ejb-client.properties delete mode 100644 testsuite/integration/src/test/xslt/addChannel.xsl delete mode 100644 testsuite/integration/src/test/xslt/changeCacheContainerChannelName.xsl delete mode 100644 testsuite/integration/src/test/xslt/changeCacheContainerName.xsl create mode 100644 testsuite/integration/src/test/xslt/changeClusterName.xsl delete mode 100644 testsuite/integration/src/test/xslt/changeEJBRemoteConnectorClusterName.xsl delete mode 100644 testsuite/integration/src/test/xslt/changePassivationStoreCacheContainerName.xsl diff --git a/testsuite/integration/clustering/pom.xml b/testsuite/integration/clustering/pom.xml index 2eb2476d07a4..5dfbc05e26b2 100644 --- a/testsuite/integration/clustering/pom.xml +++ b/testsuite/integration/clustering/pom.xml @@ -559,11 +559,11 @@ ts.clustering.two.clusters.profile - extendedTests - - + + + !ts.noClustering + + @@ -617,15 +617,20 @@ test test + + false + - org/jboss/as/test/clustering/twoclusters/RemoteEJBTwoClusterTestCase.java + org/jboss/as/test/clustering/twoclusters/**/*TestCase.java clustering-two-clusters standalone-ha.xml + + ${surefire.system.args} ${jvm.args.ip} ${jvm.args.other} ${jvm.args.timeouts} -Dnode0=${node0} -Dnode1=${node1} -Dmcast=${mcast} -Dmcast.ttl=${mcast.ttl} ${jvm.args.dirs} udp diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/ClusteringTestConstants.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/ClusteringTestConstants.java index ded3e36e733d..00e0b1d101f2 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/ClusteringTestConstants.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/ClusteringTestConstants.java @@ -27,7 +27,6 @@ * Test constants statically imported used across the clustering tests. * * @author Radoslav Husar - * @version Feb 2012 */ public interface ClusteringTestConstants { @@ -67,11 +66,6 @@ public interface ClusteringTestConstants { String NODE_NAME_PROPERTY = "jboss.node.name"; - /** - * Name of cluster for remote client. - */ - String CLUSTER_NAME = "ejb"; - /** * Timeouts. */ diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/AbstractRemoteEJBTwoClusterTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/AbstractRemoteEJBTwoClusterTestCase.java new file mode 100644 index 000000000000..b858dd8d7d17 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/AbstractRemoteEJBTwoClusterTestCase.java @@ -0,0 +1,216 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.test.clustering.twoclusters; + +import static org.junit.Assert.fail; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +import javax.naming.NamingException; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.RunAsClient; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.arquillian.junit.Arquillian; +import org.jboss.as.test.clustering.cluster.ExtendedClusterAbstractTestCase; +import org.jboss.as.test.clustering.ejb.EJBDirectory; +import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSB; +import org.jboss.as.test.clustering.twoclusters.bean.forwarding.AbstractForwardingStatefulSBImpl; +import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; +import org.jboss.as.test.shared.TimeoutUtil; +import org.jboss.logging.Logger; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.wildfly.common.function.ExceptionSupplier; + +/** + * Test EJBClient functionality across two clusters with fail-over. + *

+ * A client makes an invocation on one clustered app (on cluster A) which in turn + * forwards the invocation on a second clustered app (on cluster B). + *

+ * cluster A = {node0, node1} + * cluster B = {node2, node3} + *

+ * Under constant client load, we stop and then restart individual servers. + *

+ * We expect that client invocations will not be affected. + * + * @author Richard Achmatowicz + * @author Radoslav Husar + */ +@RunWith(Arquillian.class) +@RunAsClient +public abstract class AbstractRemoteEJBTwoClusterTestCase extends ExtendedClusterAbstractTestCase { + + private static long FAILURE_FREE_TIME = TimeoutUtil.adjust(5000); + private static long SERVER_DOWN_TIME = TimeoutUtil.adjust(5000); + private static long INVOCATION_WAIT = TimeoutUtil.adjust(100); + + private final ExceptionSupplier directorySupplier; + private final String implementationClass; + + private static final Logger logger = Logger.getLogger(AbstractRemoteEJBTwoClusterTestCase.class); + + AbstractRemoteEJBTwoClusterTestCase(ExceptionSupplier directorySupplier, String implementationClass) { + this.directorySupplier = directorySupplier; + this.implementationClass = implementationClass; + } + + @Deployment(name = DEPLOYMENT_3, managed = false, testable = false) + @TargetsContainer(CONTAINER_3) + public static Archive deployment2() { + return createNonForwardingDeployment(); + } + + @Deployment(name = DEPLOYMENT_4, managed = false, testable = false) + @TargetsContainer(CONTAINER_4) + public static Archive deployment3() { + return createNonForwardingDeployment(); + } + + private static Archive createNonForwardingDeployment() { + JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, AbstractForwardingStatefulSBImpl.MODULE_NAME + ".jar"); + ejbJar.addPackage(CommonStatefulSB.class.getPackage()); + ejbJar.addPackage(RemoteStatefulSB.class.getPackage()); + return ejbJar; + } + + /** + * Tests that EJBClient invocations on stateful session beans can still successfully be processed + * as long as one node in each cluster is available. + */ + @Test + public void test() throws Exception { + ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); + + try (EJBDirectory directory = directorySupplier.get()) { + // get the correct forwarder deployment on cluster A + RemoteStatefulSB bean = directory.lookupStateful(implementationClass, RemoteStatefulSB.class); + + // Allow sufficient time for client to receive full topology + logger.info("Waiting for clusters to form."); + Thread.sleep(FAILURE_FREE_TIME); + + int newSerialValue = bean.getSerialAndIncrement(); + logger.debugf("First invocation: serial = %d", newSerialValue); + + ClientInvocationTask client = new ClientInvocationTask(bean, newSerialValue); + + // set up the client invocations + executor.scheduleWithFixedDelay(client, 0, INVOCATION_WAIT, TimeUnit.MILLISECONDS); + + // a few seconds of non-failure behaviour + Thread.sleep(FAILURE_FREE_TIME); + client.assertNoExceptions("at the beginning of the test"); + + logger.debug("------ Shutdown clusterA-node0 -----"); + stop(GRACEFUL_SHUTDOWN_TIMEOUT, CONTAINER_1); + Thread.sleep(SERVER_DOWN_TIME); + client.assertNoExceptions("after clusterA-node0 was shut down"); + + logger.debug("------ Startup clusterA-node0 -----"); + start(CONTAINER_1); + Thread.sleep(FAILURE_FREE_TIME); + client.assertNoExceptions("after clusterA-node0 was brought up"); + + logger.debug("----- Shutdown clusterA-node1 -----"); + stop(GRACEFUL_SHUTDOWN_TIMEOUT, CONTAINER_2); + Thread.sleep(SERVER_DOWN_TIME); + + logger.info("------ Startup clusterA-node1 -----"); + start(CONTAINER_2); + Thread.sleep(FAILURE_FREE_TIME); + client.assertNoExceptions("after clusterA-node1 was brought back up"); + + logger.debug("----- Shutdown clusterB-node0 -----"); + stop(GRACEFUL_SHUTDOWN_TIMEOUT, CONTAINER_3); + Thread.sleep(SERVER_DOWN_TIME); + client.assertNoExceptions("after clusterB-node0 was shut down"); + + logger.info("------ Startup clusterB-node0 -----"); + start(CONTAINER_3); + Thread.sleep(FAILURE_FREE_TIME); + client.assertNoExceptions("after clusterB-node0 was brought back up"); + + logger.debug("----- Shutdown clusterB-node1 -----"); + stop(GRACEFUL_SHUTDOWN_TIMEOUT, CONTAINER_4); + Thread.sleep(SERVER_DOWN_TIME); + + logger.debug("------ Startup clusterB-node1 -----"); + start(CONTAINER_4); + Thread.sleep(FAILURE_FREE_TIME); + + // final assert + client.assertNoExceptions("after clusterB-node1 was brought back up"); + } finally { + executor.shutdownNow(); + } + } + + private class ClientInvocationTask implements Runnable { + private final RemoteStatefulSB bean; + private int expectedSerial; + private volatile Exception firstException; + private int invocationCount; + + ClientInvocationTask(RemoteStatefulSB bean, int serial) { + this.bean = bean; + this.expectedSerial = serial; + } + + /** + * Asserts that there were no exception during the last test period. + */ + void assertNoExceptions(String when) throws Exception { + if (firstException != null) { + logger.error(firstException); + fail("Client threw an exception " + when + ": " + firstException); // Arrays.stream(firstException.getStackTrace()).map(StackTraceElement::toString).collect(Collectors.joining("\n"))); + } + } + + @Override + public void run() { + invocationCount++; + + try { + int serial = this.bean.getSerialAndIncrement(); + logger.debugf("EJB client invocation #%d on bean, received serial #%d.", this.invocationCount, serial); + + if (serial != ++expectedSerial) { + logger.warnf("Expected (%d) and received serial (%d) numbers do not match! Resetting.", expectedSerial, serial); + expectedSerial = serial; + } + } catch (Exception clientException) { + if (this.firstException == null) { + this.firstException = clientException; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxClientEJBTwoClusterTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxClientEJBTwoClusterTestCase.java new file mode 100644 index 000000000000..db1de8b69f83 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxClientEJBTwoClusterTestCase.java @@ -0,0 +1,37 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.test.clustering.twoclusters; + +import org.jboss.as.test.clustering.ejb.ClientEJBDirectory; + +/** + * Tests concurrent fail-over without a managed transaction context on the forwarder and using the client "API". + * + * @author Radoslav Husar + */ +public class NonTxClientEJBTwoClusterTestCase extends NonTxRemoteEJBTwoClusterTestCase { + + public NonTxClientEJBTwoClusterTestCase() { + super(() -> new ClientEJBDirectory(MODULE_NAME)); + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxRemoteEJBTwoClusterTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxRemoteEJBTwoClusterTestCase.java new file mode 100644 index 000000000000..21941964e5a4 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/NonTxRemoteEJBTwoClusterTestCase.java @@ -0,0 +1,82 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.test.clustering.twoclusters; + +import javax.naming.NamingException; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.as.test.clustering.ejb.EJBDirectory; +import org.jboss.as.test.clustering.ejb.NamingEJBDirectory; +import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory; +import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSB; +import org.jboss.as.test.clustering.twoclusters.bean.forwarding.AbstractForwardingStatefulSBImpl; +import org.jboss.as.test.clustering.twoclusters.bean.forwarding.NonTxForwardingStatefulSBImpl; +import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.wildfly.common.function.ExceptionSupplier; + +/** + * Tests concurrent fail-over without a managed transaction context on the forwarder. + * + * @author Radoslav Husar + */ +public class NonTxRemoteEJBTwoClusterTestCase extends AbstractRemoteEJBTwoClusterTestCase { + + public static final String MODULE_NAME = "twocluster-forwarder-nontx"; + + public NonTxRemoteEJBTwoClusterTestCase() { + this(() -> new RemoteEJBDirectory(MODULE_NAME)); + } + + NonTxRemoteEJBTwoClusterTestCase(ExceptionSupplier directorySupplier) { + super(directorySupplier, NonTxForwardingStatefulSBImpl.class.getSimpleName()); + } + + @Deployment(name = DEPLOYMENT_1, managed = false, testable = false) + @TargetsContainer(CONTAINER_1) + public static Archive deployment0() { + return createForwardingDeployment(); + } + + @Deployment(name = DEPLOYMENT_2, managed = false, testable = false) + @TargetsContainer(CONTAINER_2) + public static Archive deployment1() { + return createForwardingDeployment(); + } + + private static Archive createForwardingDeployment() { + JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); + ejbJar.addClass(CommonStatefulSB.class); + ejbJar.addClass(RemoteStatefulSB.class); + // the forwarding classes + ejbJar.addClass(AbstractForwardingStatefulSBImpl.class); + ejbJar.addClass(NonTxForwardingStatefulSBImpl.class); + ejbJar.addClasses(EJBDirectory.class, NamingEJBDirectory.class, RemoteEJBDirectory.class); + // remote outbound connection configuration + ejbJar.addAsManifestResource(AbstractRemoteEJBTwoClusterTestCase.class.getPackage(), "jboss-ejb-client.xml", "jboss-ejb-client.xml"); + return ejbJar; + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/RemoteEJBTwoClusterTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/RemoteEJBTwoClusterTestCase.java deleted file mode 100644 index 0b9b41b05872..000000000000 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/RemoteEJBTwoClusterTestCase.java +++ /dev/null @@ -1,370 +0,0 @@ -package org.jboss.as.test.clustering.twoclusters; - -import org.jboss.arquillian.container.test.api.Deployment; -import org.jboss.arquillian.container.test.api.RunAsClient; -import org.jboss.arquillian.container.test.api.TargetsContainer; -import org.jboss.arquillian.junit.Arquillian; -import org.jboss.arquillian.junit.InSequence; -import org.jboss.as.test.clustering.EJBClientContextSelector; -import org.jboss.as.test.clustering.ejb.EJBDirectory; -import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory; -import org.jboss.as.test.clustering.cluster.ExtendedClusterAbstractTestCase; -import org.jboss.as.test.clustering.twoclusters.bean.SerialBean; -import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSB; -import org.jboss.as.test.clustering.twoclusters.bean.forwarding.AbstractForwardingStatefulSBImpl; -import org.jboss.as.test.clustering.twoclusters.bean.forwarding.ForwardingStatefulSBImpl; -import org.jboss.as.test.clustering.twoclusters.bean.forwarding.NonTxForwardingStatefulSBImpl; -import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; -import org.jboss.as.test.shared.TimeoutUtil; -import org.jboss.logging.Logger; -import org.jboss.shrinkwrap.api.Archive; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.naming.NamingException; -import java.util.concurrent.CancellationException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Test EJBClient functionality across two clusters with fail-over. - *

- * A client makes an invocation on one clustered app (on cluster A) which in turn - * forwards the invocation on a second clustered app (on cluster B). - *

- * cluster A = {node0, node1} - * cluster B = {node2, node3} - *

- * Under constant client load, we stop and then restart individual servers. - *

- * We expect that client invocations will not be affected. - * - * @author Richard Achmatowicz - */ -@RunWith(Arquillian.class) -@RunAsClient -public class RemoteEJBTwoClusterTestCase extends ExtendedClusterAbstractTestCase { - - private static final Logger logger = Logger.getLogger(RemoteEJBTwoClusterTestCase.class); - private static final String FORWARDER_MODULE_NAME = "clusterbench-ee6-ejb-forwarder"; - private static final String FORWARDER_WITH_TXN_MODULE_NAME = "clusterbench-ee6-ejb-forwarder-with-txn"; - private static final String RECEIVER_MODULE_NAME = "clusterbench-ee6-ejb"; - // EJBClient configuartion to cluster A - private static final String FORWARDER_CLIENT_PROPERTIES = "org/jboss/as/test/clustering/twoclusters/forwarder-jboss-ejb-client.properties"; - - private static long CLIENT_TOPOLOGY_UPDATE_WAIT = TimeoutUtil.adjust(5000); - private static long FAILURE_FREE_TIME = TimeoutUtil.adjust(5000); - // 200 ms keeps the test stable - private static long INVOCATION_WAIT = TimeoutUtil.adjust(200); - private static long SERVER_DOWN_TIME = TimeoutUtil.adjust(5000); - // allowed percentage of exceptions (exceptions / invocations) - private static double EXCEPTION_PERCENTAGE = 0.1; - - // EJB deployment lookup helpers - private static EJBDirectory beanDirectory; - private static EJBDirectory txnBeanDirectory; - - @Deployment(name = DEPLOYMENT_1, managed = false, testable = false) - @TargetsContainer(CONTAINER_1) - public static Archive deployment0() { - return getNonTxForwardingDeployment(); - } - - @Deployment(name = DEPLOYMENT_2, managed = false, testable = false) - @TargetsContainer(CONTAINER_2) - public static Archive deployment1() { - return getNonTxForwardingDeployment(); - } - - @Deployment(name = DEPLOYMENT_3, managed = false, testable = false) - @TargetsContainer(CONTAINER_3) - public static Archive deployment2() { - return getNonForwardingDeployment(); - } - - @Deployment(name = DEPLOYMENT_4, managed = false, testable = false) - @TargetsContainer(CONTAINER_4) - public static Archive deployment3() { - return getNonForwardingDeployment(); - } - - @Deployment(name = "deployment-4", managed = false, testable = false) - @TargetsContainer(CONTAINER_1) - public static Archive deployment0_txn() { - return getTxForwardingDeployment(); - } - - @Deployment(name = "deployment-5", managed = false, testable = false) - @TargetsContainer(CONTAINER_2) - public static Archive deployment1_txn() { - return getTxForwardingDeployment(); - } - - private static Archive getTxForwardingDeployment() { - final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, FORWARDER_WITH_TXN_MODULE_NAME + ".jar"); - ejbJar.addPackage(CommonStatefulSB.class.getPackage()); - ejbJar.addPackage(RemoteStatefulSB.class.getPackage()); - ejbJar.addClass(SerialBean.class.getName()); - // the forwarding classes - ejbJar.addClass(AbstractForwardingStatefulSBImpl.class.getName()); - ejbJar.addPackage(ForwardingStatefulSBImpl.class.getPackage()); - // remote outbound connection configuration - ejbJar.addAsManifestResource(RemoteEJBTwoClusterTestCase.class.getPackage(), "jboss-ejb-client.xml", "jboss-ejb-client.xml"); - return ejbJar; - } - - private static Archive getNonTxForwardingDeployment() { - final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, FORWARDER_MODULE_NAME + ".jar"); - ejbJar.addPackage(CommonStatefulSB.class.getPackage()); - ejbJar.addPackage(RemoteStatefulSB.class.getPackage()); - ejbJar.addClass(SerialBean.class.getName()); - // the forwarding classes - ejbJar.addClass(AbstractForwardingStatefulSBImpl.class.getName()); - ejbJar.addClass(NonTxForwardingStatefulSBImpl.class.getName()); - // remote outbound connection configuration - ejbJar.addAsManifestResource(RemoteEJBTwoClusterTestCase.class.getPackage(), "jboss-ejb-client.xml", "jboss-ejb-client.xml"); - return ejbJar; - } - - private static Archive getNonForwardingDeployment() { - final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, RECEIVER_MODULE_NAME + ".jar"); - ejbJar.addPackage(CommonStatefulSB.class.getPackage()); - ejbJar.addPackage(RemoteStatefulSB.class.getPackage()); - ejbJar.addClass(SerialBean.class.getName()); - return ejbJar; - } - - /* - * In the test case framework: - * - containers are deployed by the framework before any test runs - * - containers are undeployed by the test case itself - * - deployments are deployed by the test case itself - * - deployments are undeployed by the test case itself - */ - - @BeforeClass - public static void beforeTest() throws NamingException { - beanDirectory = new RemoteEJBDirectory(FORWARDER_MODULE_NAME); - txnBeanDirectory = new RemoteEJBDirectory(FORWARDER_WITH_TXN_MODULE_NAME); - } - - @AfterClass - public static void destroy() throws Exception { - beanDirectory.close(); - txnBeanDirectory.close(); - } - - @After - public void afterTest() throws Exception { - } - - /* - * Tests concurrent fail-over without a managed transaction context on the forwarder. - */ - @Test - @InSequence(1) - public void testConcurrentFailoverOverWithoutTransactions() throws Exception { - - testConcurrentFailoverOverWithTwoClusters(false); - } - - /* - * Tests concurrent fail-over with a managed transaction context on the forwarder. - */ - @Test - @InSequence(2) - public void testConcurrentFailoverOverWithTransactions() throws Exception { - // some additional transaction-oriented deployments for containers 1 and 2 - this.deploy("deployment-4", "deployment-5"); - - testConcurrentFailoverOverWithTwoClusters(true); - - // additional un-deployments for containers 1 and 2 - this.undeploy("deployment-4", "deployment-5"); - } - - /* - * Tests that EJBClient invocations on stateful session beans can still successfully be processed - * as long as one node in each cluster is available. - */ - public void testConcurrentFailoverOverWithTwoClusters(boolean useTransactions) throws Exception { - // TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties - // that should be used for this test using FORWARDER_CLIENT_PROPERTIES and ensure the EJB client context is reset - // to its original state at the end of the test - EJBClientContextSelector.setup(FORWARDER_CLIENT_PROPERTIES); - - try { - // get the correct forwarder deployment on cluster A - RemoteStatefulSB bean = null; - if (useTransactions) - bean = txnBeanDirectory.lookupStateful(ForwardingStatefulSBImpl.class, RemoteStatefulSB.class); - else - bean = beanDirectory.lookupStateful(NonTxForwardingStatefulSBImpl.class, RemoteStatefulSB.class); - - AtomicInteger count = new AtomicInteger(); - - // Allow sufficient time for client to receive full topology - logger.trace("Waiting for clusters to form:"); - Thread.sleep(CLIENT_TOPOLOGY_UPDATE_WAIT); - - int newSerialValue = bean.getSerialAndIncrement(); - int newCountValue = count.getAndIncrement(); - logger.trace("First invocation: count = " + newCountValue + ", serial = " + newSerialValue); - - // - ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); - CountDownLatch latch = new CountDownLatch(1); - ClientInvocationTask client = new ClientInvocationTask(bean, latch, count); - - try { - // set up the client invocations - Future future = executor.scheduleWithFixedDelay(client, 0, INVOCATION_WAIT, TimeUnit.MILLISECONDS); - latch.await(); - - // a few seconds of non-failure behaviour - Thread.sleep(FAILURE_FREE_TIME); - - logger.trace("------ Shutdown clusterA-node0 -----"); - // stop cluster A node 0 - stop(CONTAINER_1); - // Let the server stay down for a while - Thread.sleep(SERVER_DOWN_TIME); - logger.trace("------ Startup clusterA-node0 -----"); - start(CONTAINER_1); - - // a few seconds of non-failure behaviour - Thread.sleep(FAILURE_FREE_TIME); - - logger.trace("----- Shutdown clusterA-node1 -----"); - // stop cluster A node 1 - stop(CONTAINER_2); - // Let the server stay down for a while - Thread.sleep(SERVER_DOWN_TIME); - logger.trace("------ Startup clusterA-node1 -----"); - start(CONTAINER_2); - - // a few seconds of non-failure behaviour - Thread.sleep(FAILURE_FREE_TIME); - - logger.trace("----- Shutdown clusterB-node0 -----"); - // stop cluster B node 0 - stop(CONTAINER_3); - // Let the server stay down for a while - Thread.sleep(SERVER_DOWN_TIME); - logger.trace("------ Startup clusterB-node0 -----"); - start(CONTAINER_3); - - // a few seconds of non-failure behaviour - Thread.sleep(FAILURE_FREE_TIME); - - logger.trace("----- Shutdown clusterB-node1 -----"); - // stop cluster B node 1 - stop(CONTAINER_4); - // Let the server stay down for a while - Thread.sleep(SERVER_DOWN_TIME); - logger.trace("------ Startup clusterB-node1 -----"); - start(CONTAINER_4); - - // a few seconds of non-failure behaviour - Thread.sleep(FAILURE_FREE_TIME); - - // cancel the executor and wait for it to complete - future.cancel(false); - try { - future.get(); - } catch (CancellationException e) { - logger.trace("Could not cancel future: " + e.toString()); - } - - // test is completed, report results - double invocations = client.getInvocationCount(); - double exceptions = client.getExceptionCount(); - logger.trace("Total invocations = " + invocations + ", total exceptions = " + exceptions); - Assert.assertTrue("Too many exceptions! percentage = " + 100 * (exceptions/invocations), (exceptions/invocations) < EXCEPTION_PERCENTAGE); - - } catch (Exception e) { - Assert.fail("Exception occurred on client: " + e.getMessage() + ", test did not complete successfully (inner)"); - - } finally { - logger.trace("Shutting down executor"); - executor.shutdownNow(); - } - - } catch (Exception e) { - Assert.fail("Exception occurred on client: " + e.getMessage() + ", test did not complete successfully (outer)"); - - } - } - - private class ClientInvocationTask implements Runnable { - private final RemoteStatefulSB bean; - private final CountDownLatch latch; - private final AtomicInteger count; - // count of exceptional responses - private int invocationCount; - private int exceptionCount; - // true of the last invocation resulted in an exception - private boolean lastWasException; - private boolean firstTime; - - ClientInvocationTask(RemoteStatefulSB bean, CountDownLatch latch, AtomicInteger count) { - this.bean = bean; - this.latch = latch; - this.count = count; - this.invocationCount = 0; - this.exceptionCount = 0; - - this.lastWasException = false; - this.firstTime = true; - } - - public int getExceptionCount() { - return exceptionCount; - } - - public int getInvocationCount() { - return invocationCount; - } - - @Override - public void run() { - try { - // make an invocation on the remote SFSB - this.invocationCount++; - logger.trace("CLIENT: start invocation (" + this.invocationCount + ")"); - int value = this.bean.getSerialAndIncrement(); - - // check to see if the previous invocation was exceptional - if (this.lastWasException) { - // reset the value of the counter - this.count.set(value+1); - this.lastWasException = false; - logger.trace("CLIENT: made invocation (" + this.invocationCount + ") on bean, resetting count = " + (value+1)); - } else { - int count = this.count.getAndIncrement(); - logger.trace("CLIENT: made invocation (" + this.invocationCount + ") on bean, count = " + count + ", value = " + value); - } - } catch (Exception e) { - // log the occurrence of the exception - logger.trace("CLIENT: Exception invoking (" + this.invocationCount + ") on bean from client: " + e.getMessage()); - this.exceptionCount++; - this.lastWasException = true; - } finally { - if (firstTime) { - this.firstTime = false; - this.latch.countDown(); - } - } - } - } -} \ No newline at end of file diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxClientEJBTwoClusterTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxClientEJBTwoClusterTestCase.java new file mode 100644 index 000000000000..d74d4f3afb51 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxClientEJBTwoClusterTestCase.java @@ -0,0 +1,37 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.test.clustering.twoclusters; + +import org.jboss.as.test.clustering.ejb.ClientEJBDirectory; + +/** + * Tests concurrent fail-over with a managed transaction context on the forwarder and using the client "API". + * + * @author Radoslav Husar + */ +public class TxClientEJBTwoClusterTestCase extends TxRemoteEJBTwoClusterTestCase { + + public TxClientEJBTwoClusterTestCase() { + super(() -> new ClientEJBDirectory(MODULE_NAME)); + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxRemoteEJBTwoClusterTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxRemoteEJBTwoClusterTestCase.java new file mode 100644 index 000000000000..ae950d393fa9 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/TxRemoteEJBTwoClusterTestCase.java @@ -0,0 +1,82 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + +package org.jboss.as.test.clustering.twoclusters; + +import javax.naming.NamingException; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.as.test.clustering.ejb.EJBDirectory; +import org.jboss.as.test.clustering.ejb.NamingEJBDirectory; +import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory; +import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSB; +import org.jboss.as.test.clustering.twoclusters.bean.forwarding.AbstractForwardingStatefulSBImpl; +import org.jboss.as.test.clustering.twoclusters.bean.forwarding.ForwardingStatefulSBImpl; +import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; +import org.jboss.shrinkwrap.api.Archive; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.wildfly.common.function.ExceptionSupplier; + +/** + * Tests concurrent fail-over with a managed transaction context on the forwarder. + * + * @author Radoslav Husar + */ +public class TxRemoteEJBTwoClusterTestCase extends AbstractRemoteEJBTwoClusterTestCase { + + public static final String MODULE_NAME = "twocluster-forwarder-tx"; + + public TxRemoteEJBTwoClusterTestCase() { + this(() -> new RemoteEJBDirectory(MODULE_NAME)); + } + + TxRemoteEJBTwoClusterTestCase(ExceptionSupplier directorySupplier) { + super(directorySupplier, ForwardingStatefulSBImpl.class.getSimpleName()); + } + + @Deployment(name = DEPLOYMENT_1, managed = false, testable = false) + @TargetsContainer(CONTAINER_1) + public static Archive deployment0() { + return createForwardingDeployment(); + } + + @Deployment(name = DEPLOYMENT_2, managed = false, testable = false) + @TargetsContainer(CONTAINER_2) + public static Archive deployment1() { + return createForwardingDeployment(); + } + + private static Archive createForwardingDeployment() { + JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); + ejbJar.addClass(CommonStatefulSB.class); + ejbJar.addClass(RemoteStatefulSB.class); + // the forwarding classes + ejbJar.addClass(AbstractForwardingStatefulSBImpl.class); + ejbJar.addClass(ForwardingStatefulSBImpl.class); + ejbJar.addClasses(EJBDirectory.class, NamingEJBDirectory.class, RemoteEJBDirectory.class); + // remote outbound connection configuration + ejbJar.addAsManifestResource(AbstractRemoteEJBTwoClusterTestCase.class.getPackage(), "jboss-ejb-client.xml", "jboss-ejb-client.xml"); + return ejbJar; + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/SerialBean.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/SerialBean.java deleted file mode 100644 index 787c6eb2a8b7..000000000000 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/SerialBean.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.jboss.as.test.clustering.twoclusters.bean; - -import java.io.Serializable; -import java.util.Random; - -public class SerialBean implements Serializable { - - private int serial; - private byte[] cargo; - - public SerialBean() { - this.serial = 0; - this.cargo = new byte[4 * 1024]; - Random rand = new Random(); - rand.nextBytes(cargo); - } - - public byte[] getCargo() { - return cargo; - } - - public void setCargo(byte[] cargo) { - this.cargo = cargo; - } - - public int getSerial() { - return serial; - } - - public int getSerialAndIncrement() { - int retVal = this.getSerial(); - serial++; - return retVal; - } - - public void setSerial(int serial) { - this.serial = serial; - } -} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSB.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSB.java index 73559a19a408..b01ef8cf4a0f 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSB.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSB.java @@ -1,11 +1,28 @@ -package org.jboss.as.test.clustering.twoclusters.bean.common; +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jboss.as.test.clustering.twoclusters.bean.common; public interface CommonStatefulSB { - int getSerial(); - int getSerialAndIncrement(); - - byte[] getCargo(); } diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSBImpl.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSBImpl.java index bd0b736fee44..4fae9e42caff 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSBImpl.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/common/CommonStatefulSBImpl.java @@ -1,49 +1,58 @@ -package org.jboss.as.test.clustering.twoclusters.bean.common; +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ -import org.jboss.as.test.clustering.twoclusters.bean.SerialBean; +package org.jboss.as.test.clustering.twoclusters.bean.common; import javax.annotation.PostConstruct; import javax.ejb.Remove; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; + import org.jboss.logging.Logger; @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public class CommonStatefulSBImpl implements CommonStatefulSB { - private SerialBean bean; + private int serial; private static final Logger log = Logger.getLogger(CommonStatefulSBImpl.class.getName()); @PostConstruct private void init() { - bean = new SerialBean(); - log.tracef("New SFSB created: %s.", this); - } - - @Override - public int getSerial() { - log.trace("getSerial() called on non-forwarding node " + getCurrentNode()); - return bean.getSerial(); + serial = 0; + log.infof("New SFSB created: %s.", this); } @Override public int getSerialAndIncrement() { - log.trace("getSerialAndIncrement() called on non-forwarding node " + getCurrentNode()); - return bean.getSerialAndIncrement(); - } - - @Override - public byte[] getCargo() { - log.trace("getCargo() called on non-forwarding node " + getCurrentNode()); - return bean.getCargo(); + log.infof("getSerialAndIncrement() called on non-forwarding node %s", getCurrentNode()); + return serial++; } @Remove private void destroy() { - // Let the container do the work. + serial = -1; } - private String getCurrentNode() { + private static String getCurrentNode() { return System.getProperty("jboss.node.name", "unknown"); } } diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/AbstractForwardingStatefulSBImpl.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/AbstractForwardingStatefulSBImpl.java index 451e71a35036..9d370e84f013 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/AbstractForwardingStatefulSBImpl.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/AbstractForwardingStatefulSBImpl.java @@ -1,62 +1,65 @@ -package org.jboss.as.test.clustering.twoclusters.bean.forwarding; +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ -import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; -import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSBImpl; +package org.jboss.as.test.clustering.twoclusters.bean.forwarding; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; -import javax.naming.Context; -import javax.naming.InitialContext; -import java.util.Hashtable; + +import org.jboss.as.test.clustering.ejb.EJBDirectory; +import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory; +import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; import org.jboss.logging.Logger; +/** + * @author Radoslav Husar + */ @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) -public class AbstractForwardingStatefulSBImpl { +public abstract class AbstractForwardingStatefulSBImpl { private static final Logger log = Logger.getLogger(AbstractForwardingStatefulSBImpl.class.getName()); + public static final String MODULE_NAME = "twocluster-terminus"; private RemoteStatefulSB bean; - private final String appName = ""; - private final String moduleName = "clusterbench-ee6-ejb"; - private final String distinctName = "" ; - private final String beanName = RemoteStatefulSBImpl.class.getSimpleName(); - private final String viewClassName = RemoteStatefulSB.class.getName() ; - - private final String EJB_NAME = "ejb:" + appName + "/" + moduleName + "/" + distinctName + "/" + beanName + "!" + viewClassName + "?stateful"; - @SuppressWarnings("unchecked") private RemoteStatefulSB forward() { if (bean == null) { - try { - Hashtable props = new Hashtable(); - props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); - Context context = new InitialContext(props); - bean = (RemoteStatefulSB) context.lookup(EJB_NAME); + try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) { + bean = directory.lookupStateful("RemoteStatefulSBImpl", RemoteStatefulSB.class); } catch (Exception e) { - log.info("exception occurred looking up name " + EJB_NAME + " on forwarding node " + getCurrentNode()); + log.infof("exception occurred looking up ejb on forwarding node %s", getCurrentNode()); throw new RuntimeException(e); } } return bean; } - public int getSerial() { - log.trace("getSerial() called on forwarding node " + getCurrentNode()); - return forward().getSerial(); - } - public int getSerialAndIncrement() { - log.trace("getSerialAndIncrement() called on forwarding node " + getCurrentNode()); + log.infof("getSerialAndIncrement() called on forwarding node %s", getCurrentNode()); return forward().getSerialAndIncrement(); } - public byte[] getCargo() { - log.trace("getCargo() called on forwarding node " + getCurrentNode()); - return forward().getCargo(); - } - - private String getCurrentNode() { + private static String getCurrentNode() { return System.getProperty("jboss.node.name", "unknown"); } } diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/ForwardingStatefulSBImpl.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/ForwardingStatefulSBImpl.java index 9580e8ef0629..111e1288e149 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/ForwardingStatefulSBImpl.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/ForwardingStatefulSBImpl.java @@ -1,3 +1,25 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.as.test.clustering.twoclusters.bean.forwarding; import javax.ejb.Stateful; @@ -5,27 +27,15 @@ import javax.ejb.TransactionAttributeType; import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; -import org.jboss.ejb3.annotation.Clustered; @Stateful -@Clustered @TransactionAttribute(TransactionAttributeType.REQUIRED) // this is the default anyway public class ForwardingStatefulSBImpl extends AbstractForwardingStatefulSBImpl implements RemoteStatefulSB { - // we need to override these methods so that the TransactionAttribute gets processed on this class! - - @Override - public int getSerial() { - return super.getSerial(); - } + // We need to override these methods so that the TransactionAttribute gets processed on this class! @Override public int getSerialAndIncrement() { return super.getSerialAndIncrement(); } - - @Override - public byte[] getCargo() { - return super.getCargo(); - } } diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/NonTxForwardingStatefulSBImpl.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/NonTxForwardingStatefulSBImpl.java index db9c0fb9bcff..27d72d62ef89 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/NonTxForwardingStatefulSBImpl.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/forwarding/NonTxForwardingStatefulSBImpl.java @@ -1,11 +1,34 @@ -package org.jboss.as.test.clustering.twoclusters.bean.forwarding; +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ -import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; -import org.jboss.ejb3.annotation.Clustered; +package org.jboss.as.test.clustering.twoclusters.bean.forwarding; import javax.ejb.Stateful; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; + +import org.jboss.as.test.clustering.twoclusters.bean.stateful.RemoteStatefulSB; @Stateful -@Clustered +@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public class NonTxForwardingStatefulSBImpl extends AbstractForwardingStatefulSBImpl implements RemoteStatefulSB { } diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/LocalStatefulSB.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/LocalStatefulSB.java deleted file mode 100644 index b97709a4de81..000000000000 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/LocalStatefulSB.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.jboss.as.test.clustering.twoclusters.bean.stateful; - -import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSBImpl; -import org.jboss.ejb3.annotation.Clustered; - -import javax.ejb.LocalBean; -import javax.ejb.Stateful; -import javax.enterprise.context.SessionScoped; - -/** - * @author Radoslav Husar - * @version Dec 2011 - */ -@Stateful -@LocalBean -@SessionScoped -@Clustered -public class LocalStatefulSB extends CommonStatefulSBImpl { - // Inherit. -} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSB.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSB.java index e99268c191da..68842cb70799 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSB.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSB.java @@ -1,16 +1,37 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ + package org.jboss.as.test.clustering.twoclusters.bean.stateful; import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSB; import javax.ejb.Remote; + /** * The enterprise bean must implement a business interface. That is, remote clients may not access an enterprise bean through a * no-interface view. * * @author Radoslav Husar - * @version Dec 2011 */ @Remote public interface RemoteStatefulSB extends CommonStatefulSB { - // Inherit. } \ No newline at end of file diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSBImpl.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSBImpl.java index b34290fd9f27..dbd34114886f 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSBImpl.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/bean/stateful/RemoteStatefulSBImpl.java @@ -1,16 +1,34 @@ -package org.jboss.as.test.clustering.twoclusters.bean.stateful; +/* + * JBoss, Home of Professional Open Source. + * Copyright 2017, Red Hat Middleware LLC, and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ -import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSBImpl; -import org.jboss.ejb3.annotation.Clustered; +package org.jboss.as.test.clustering.twoclusters.bean.stateful; import javax.ejb.Stateful; +import org.jboss.as.test.clustering.twoclusters.bean.common.CommonStatefulSBImpl; + /** * @author Radoslav Husar - * @version Dec 2011 */ @Stateful -@Clustered public class RemoteStatefulSBImpl extends CommonStatefulSBImpl implements RemoteStatefulSB { - // Inherit. } diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/forwarder-jboss-ejb-client.properties b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/forwarder-jboss-ejb-client.properties deleted file mode 100644 index dfbd6ebb4f07..000000000000 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/forwarder-jboss-ejb-client.properties +++ /dev/null @@ -1,37 +0,0 @@ -# -# JBoss, Home of Professional Open Source. -# Copyright 2013, Red Hat, Inc., and individual contributors -# as indicated by the @author tags. See the copyright.txt file in the -# distribution for a full listing of individual contributors. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# -remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false - -remote.connections=default - -remote.connection.default.host=${node0:localhost} -remote.connection.default.port=8080 -remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false -remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false -remote.connection.default.connect.options.org.xnio.Options.WORKER_TASK_MAX_THREADS=4 -callback.handler.class=org.jboss.as.test.shared.integration.ejb.security.CallbackHandler - -remote.clusters=ejb-forwarder - -remote.cluster.ejb-forwarder.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false -remote.cluster.ejb-forwarder.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false -remote.cluster.ejb-forwarder.connect.options.org.xnio.Options.WORKER_TASK_MAX_THREADS=4 diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/jboss-ejb-client.xml b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/jboss-ejb-client.xml index 8e4562cef617..829ee03c34d6 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/jboss-ejb-client.xml +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/twoclusters/jboss-ejb-client.xml @@ -1,22 +1,30 @@ + + - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/testsuite/integration/src/test/scripts/clustering-build.xml b/testsuite/integration/src/test/scripts/clustering-build.xml index aea7f35f626f..6cda15b88e3a 100644 --- a/testsuite/integration/src/test/scripts/clustering-build.xml +++ b/testsuite/integration/src/test/scripts/clustering-build.xml @@ -276,45 +276,31 @@ - + - - - - - + - + - - - - - + - + @@ -323,12 +309,9 @@ - + - diff --git a/testsuite/integration/src/test/scripts/clustering-common-targets.xml b/testsuite/integration/src/test/scripts/clustering-common-targets.xml index e4867e7b9723..3d013ebbe78a 100644 --- a/testsuite/integration/src/test/scripts/clustering-common-targets.xml +++ b/testsuite/integration/src/test/scripts/clustering-common-targets.xml @@ -473,93 +473,13 @@ - - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -567,28 +487,6 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/integration/src/test/scripts/common-targets.xml b/testsuite/integration/src/test/scripts/common-targets.xml index 26d846e1561f..1d1f4c522b78 100644 --- a/testsuite/integration/src/test/scripts/common-targets.xml +++ b/testsuite/integration/src/test/scripts/common-targets.xml @@ -257,7 +257,7 @@ - @@ -272,7 +272,7 @@ - + diff --git a/testsuite/integration/src/test/xslt/addChannel.xsl b/testsuite/integration/src/test/xslt/addChannel.xsl deleted file mode 100644 index f22bc5fb22b0..000000000000 --- a/testsuite/integration/src/test/xslt/addChannel.xsl +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/integration/src/test/xslt/changeCacheContainerChannelName.xsl b/testsuite/integration/src/test/xslt/changeCacheContainerChannelName.xsl deleted file mode 100644 index 940740782693..000000000000 --- a/testsuite/integration/src/test/xslt/changeCacheContainerChannelName.xsl +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/integration/src/test/xslt/changeCacheContainerName.xsl b/testsuite/integration/src/test/xslt/changeCacheContainerName.xsl deleted file mode 100644 index 036c927cc655..000000000000 --- a/testsuite/integration/src/test/xslt/changeCacheContainerName.xsl +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/integration/src/test/xslt/changeClusterName.xsl b/testsuite/integration/src/test/xslt/changeClusterName.xsl new file mode 100644 index 000000000000..359aa330dc8c --- /dev/null +++ b/testsuite/integration/src/test/xslt/changeClusterName.xsl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testsuite/integration/src/test/xslt/changeEJBRemoteConnectorClusterName.xsl b/testsuite/integration/src/test/xslt/changeEJBRemoteConnectorClusterName.xsl deleted file mode 100644 index 39821d4c9421..000000000000 --- a/testsuite/integration/src/test/xslt/changeEJBRemoteConnectorClusterName.xsl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/testsuite/integration/src/test/xslt/changePassivationStoreCacheContainerName.xsl b/testsuite/integration/src/test/xslt/changePassivationStoreCacheContainerName.xsl deleted file mode 100644 index 788d3e9b95c7..000000000000 --- a/testsuite/integration/src/test/xslt/changePassivationStoreCacheContainerName.xsl +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -