From cddac7d696bf4796b1af44e5b58eeef4164d3cdd Mon Sep 17 00:00:00 2001 From: Paul Ferraro Date: Tue, 8 Mar 2022 13:02:32 -0500 Subject: [PATCH] Add distributed TimerService test case that uses infinispan-server for timer persistence. --- testsuite/integration/clustering/pom.xml | 2 + ...java => AbstractTimerServiceTestCase.java} | 33 +++------ .../ejb/timer/DistributedTimerTestCase.java | 49 +++++++++++++ .../HotRodPersistentTimerServiceTestCase.java | 73 +++++++++++++++++++ .../remote/InfinispanServerSetupTask.java | 47 ++++++++++++ .../cluster/ejb/timer/remote/jboss-ejb3.xml | 17 +++++ 6 files changed, 200 insertions(+), 21 deletions(-) rename testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/{DistributedTimerServiceTestCase.java => AbstractTimerServiceTestCase.java} (94%) create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerTestCase.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/HotRodPersistentTimerServiceTestCase.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/InfinispanServerSetupTask.java create mode 100644 testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/jboss-ejb3.xml diff --git a/testsuite/integration/clustering/pom.xml b/testsuite/integration/clustering/pom.xml index 490f47baa0f8..984345f1f888 100644 --- a/testsuite/integration/clustering/pom.xml +++ b/testsuite/integration/clustering/pom.xml @@ -669,6 +669,7 @@ ${test-group}/**/group/*TestCase.java ${test-group}/**/jms/*TestCase.java + ${test-group}/**/ejb/timer/remote/*TestCase.java ${test-group}/**/web/remote/*TestCase.java ${test-group}/**/sso/remote/*TestCase.java @@ -735,6 +736,7 @@ alphabetical + ${test-group}/**/ejb/timer/remote/*TestCase.java ${test-group}/**/web/remote/*TestCase.java ${test-group}/**/sso/remote/*TestCase.java diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerServiceTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/AbstractTimerServiceTestCase.java similarity index 94% rename from testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerServiceTestCase.java rename to testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/AbstractTimerServiceTestCase.java index 16961e7c15d5..df0872f7d63e 100644 --- a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerServiceTestCase.java +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/AbstractTimerServiceTestCase.java @@ -43,9 +43,7 @@ import org.apache.http.client.methods.HttpPut; import org.apache.http.client.utils.DateUtils; import org.apache.http.impl.client.CloseableHttpClient; -import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.OperateOnDeployment; -import org.jboss.arquillian.container.test.api.TargetsContainer; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase; @@ -67,36 +65,29 @@ * @author Paul Ferraro */ @RunWith(Arquillian.class) -public class DistributedTimerServiceTestCase extends AbstractClusteringTestCase { - private static final String MODULE_NAME = DistributedTimerServiceTestCase.class.getSimpleName(); +public class AbstractTimerServiceTestCase extends AbstractClusteringTestCase { - @Deployment(name = DEPLOYMENT_1, managed = false, testable = false) - @TargetsContainer(NODE_1) - public static Archive deployment0() { - return createArchive(); - } - - @Deployment(name = DEPLOYMENT_2, managed = false, testable = false) - @TargetsContainer(NODE_2) - public static Archive deployment1() { - return createArchive(); - } - - private static Archive createArchive() { - return ShrinkWrap.create(WebArchive.class, MODULE_NAME + ".war") + protected static Archive createArchive(Class testClass) { + return ShrinkWrap.create(WebArchive.class, testClass.getSimpleName() + ".war") .addPackage(TimerServlet.class.getPackage()) .addPackage(EJBDirectory.class.getPackage()) .addPackage(TimerBean.class.getPackage()) - .addAsWebInfResource(DistributedTimerServiceTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml") + .addAsWebInfResource(testClass.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml") ; } + private final String moduleName; + + protected AbstractTimerServiceTestCase() { + this.moduleName = this.getClass().getSimpleName(); + } + @Test public void test(@ArquillianResource(TimerServlet.class) @OperateOnDeployment(DEPLOYMENT_1) URL baseURL1, @ArquillianResource(TimerServlet.class) @OperateOnDeployment(DEPLOYMENT_2) URL baseURL2) throws IOException, URISyntaxException { Map uris = new TreeMap<>(); - uris.put(NODE_1, TimerServlet.createURI(baseURL1, MODULE_NAME)); - uris.put(NODE_2, TimerServlet.createURI(baseURL2, MODULE_NAME)); + uris.put(NODE_1, TimerServlet.createURI(baseURL1, this.moduleName)); + uris.put(NODE_2, TimerServlet.createURI(baseURL2, this.moduleName)); try (CloseableHttpClient client = TestHttpClientUtils.promiscuousCookieHttpClient()) { diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerTestCase.java new file mode 100644 index 000000000000..0cd928ee7ce5 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/DistributedTimerTestCase.java @@ -0,0 +1,49 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2022, 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. + */ + +package org.jboss.as.test.clustering.cluster.ejb.timer; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.shrinkwrap.api.Archive; + +/** + * @author Paul Ferraro + */ +public class DistributedTimerTestCase extends AbstractTimerServiceTestCase { + + @Deployment(name = DEPLOYMENT_1, managed = false, testable = false) + @TargetsContainer(NODE_1) + public static Archive deployment0() { + return createArchive(); + } + + @Deployment(name = DEPLOYMENT_2, managed = false, testable = false) + @TargetsContainer(NODE_2) + public static Archive deployment1() { + return createArchive(); + } + + private static Archive createArchive() { + return createArchive(DistributedTimerTestCase.class); + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/HotRodPersistentTimerServiceTestCase.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/HotRodPersistentTimerServiceTestCase.java new file mode 100644 index 000000000000..4930788ecdc0 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/HotRodPersistentTimerServiceTestCase.java @@ -0,0 +1,73 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2022, 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. + */ + +package org.jboss.as.test.clustering.cluster.ejb.timer.remote; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.container.test.api.TargetsContainer; +import org.jboss.as.arquillian.api.ServerSetup; +import org.jboss.as.test.clustering.cluster.ejb.timer.AbstractTimerServiceTestCase; +import org.jboss.as.test.shared.CLIServerSetupTask; +import org.jboss.shrinkwrap.api.Archive; +import org.junit.ClassRule; +import org.junit.rules.TestRule; + +/** + * @author Paul Ferraro + */ +@ServerSetup({ InfinispanServerSetupTask.class, HotRodPersistentTimerServiceTestCase.ServerSetupTask.class }) +public class HotRodPersistentTimerServiceTestCase extends AbstractTimerServiceTestCase { + + @ClassRule + public static final TestRule INFINISPAN_SERVER_RULE = infinispanServerTestRule(); + + @Deployment(name = DEPLOYMENT_1, managed = false, testable = false) + @TargetsContainer(NODE_1) + public static Archive deployment0() { + return createArchive(); + } + + @Deployment(name = DEPLOYMENT_2, managed = false, testable = false) + @TargetsContainer(NODE_2) + public static Archive deployment1() { + return createArchive(); + } + + private static Archive createArchive() { + return createArchive(HotRodPersistentTimerServiceTestCase.class); + } + + static class ServerSetupTask extends CLIServerSetupTask { + ServerSetupTask() { + this.builder.node(THREE_NODES) + .setup("/subsystem=infinispan/cache-container=ejb/invalidation-cache=hotrod-persistent:add") + .setup("/subsystem=infinispan/cache-container=ejb/invalidation-cache=hotrod-persistent/component=expiration:add(interval=0)") + .setup("/subsystem=infinispan/cache-container=ejb/invalidation-cache=hotrod-persistent/component=locking:add(isolation=REPEATABLE_READ)") + .setup("/subsystem=infinispan/cache-container=ejb/invalidation-cache=hotrod-persistent/component=transaction:add(mode=BATCH)") + .setup("/subsystem=infinispan/cache-container=ejb/invalidation-cache=hotrod-persistent/store=hotrod:add(remote-cache-container=ejb, cache-configuration=default, fetch-state=false, purge=false, passivation=false, shared=true)") + .setup("/subsystem=distributable-ejb/infinispan-timer-management=hotrod:add(cache-container=ejb, cache=hotrod-persistent)") + .teardown("/subsystem=distributable-ejb/infinispan-timer-management=hotrod:remove") + .teardown("/subsystem=infinispan/cache-container=ejb/invalidation-cache=hotrod-persistent:remove") + ; + } + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/InfinispanServerSetupTask.java b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/InfinispanServerSetupTask.java new file mode 100644 index 000000000000..65968a7405c6 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/InfinispanServerSetupTask.java @@ -0,0 +1,47 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2019, 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. + */ + +package org.jboss.as.test.clustering.cluster.ejb.timer.remote; + +import static org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase.INFINISPAN_APPLICATION_PASSWORD; +import static org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase.INFINISPAN_APPLICATION_USER; +import static org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase.INFINISPAN_SERVER_ADDRESS; +import static org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase.INFINISPAN_SERVER_PORT; + +import org.jboss.as.test.clustering.cluster.AbstractClusteringTestCase; +import org.jboss.as.test.shared.CLIServerSetupTask; + +/** + * Server setup task that configures a hotrod client to connect to an Infinispan server. + * @author Paul Ferraro + */ +public class InfinispanServerSetupTask extends CLIServerSetupTask { + public InfinispanServerSetupTask() { + this.builder.node(AbstractClusteringTestCase.THREE_NODES) + .setup("/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=infinispan-server:add(port=%d,host=%s)", INFINISPAN_SERVER_PORT, INFINISPAN_SERVER_ADDRESS) + .setup("/subsystem=infinispan/remote-cache-container=ejb:add(default-remote-cluster=infinispan-server-cluster, tcp-keep-alive=true, marshaller=PROTOSTREAM, module=org.wildfly.clustering.ejb.infinispan, properties={infinispan.client.hotrod.auth_username=%s, infinispan.client.hotrod.auth_password=%s}, statistics-enabled=true)", INFINISPAN_APPLICATION_USER, INFINISPAN_APPLICATION_PASSWORD) + .setup("/subsystem=infinispan/remote-cache-container=ejb/remote-cluster=infinispan-server-cluster:add(socket-bindings=[infinispan-server])") + .teardown("/subsystem=infinispan/remote-cache-container=ejb:remove") + .teardown("/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=infinispan-server:remove") + ; + } +} diff --git a/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/jboss-ejb3.xml b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/jboss-ejb3.xml new file mode 100644 index 000000000000..b01b4858c4e0 --- /dev/null +++ b/testsuite/integration/clustering/src/test/java/org/jboss/as/test/clustering/cluster/ejb/timer/remote/jboss-ejb3.xml @@ -0,0 +1,17 @@ + + + + + * + hotrod + + +