forked from infinispan/infinispan
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JBQA-8324 server tests for cache-container element
- Loading branch information
Showing
8 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
...testsuite/src/test/java/org/infinispan/server/test/cachecontainer/CacheContainerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package org.infinispan.server.test.cachecontainer; | ||
|
||
import java.util.Scanner; | ||
|
||
import javax.management.ObjectName; | ||
|
||
import org.infinispan.arquillian.core.InfinispanResource; | ||
import org.infinispan.arquillian.core.RemoteInfinispanServer; | ||
import org.infinispan.arquillian.core.WithRunningServer; | ||
import org.infinispan.arquillian.utils.MBeanServerConnectionProvider; | ||
import org.infinispan.client.hotrod.RemoteCache; | ||
import org.infinispan.client.hotrod.RemoteCacheManager; | ||
import org.infinispan.client.hotrod.configuration.Configuration; | ||
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* - test start, default-cache, eviction-executor, listener-executor and replication-queue-executor attributes of cache-container element | ||
* - test the cache-container attribute of hotrod-connector, so that we can have different hotrod endpoints for different containers | ||
* | ||
* @author <a href="mailto:[email protected]">Martin Gencur</a> | ||
* @author <a href="mailto:[email protected]">Jakub Markos</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@WithRunningServer("cachecontainer") | ||
public class CacheContainerTest { | ||
|
||
@InfinispanResource("cachecontainer") | ||
RemoteInfinispanServer server1; | ||
|
||
final int managementPort = 9999; | ||
|
||
final String dumpServicesBean = "jboss.msc:type=container,name=jboss-as"; | ||
final String dumpServicesOp = "dumpServicesToString"; | ||
|
||
RemoteCacheManager rcm1; // connects to 'default' cache container | ||
RemoteCacheManager rcm2; // connects to 'special-cache-container' cache container | ||
MBeanServerConnectionProvider provider; | ||
|
||
@Before | ||
public void setUp() { | ||
if (rcm1 == null) { | ||
provider = new MBeanServerConnectionProvider(server1.getHotrodEndpoint().getInetAddress().getHostName(), managementPort); | ||
|
||
Configuration conf = new ConfigurationBuilder().addServer().host(server1.getHotrodEndpoint().getInetAddress().getHostName()).port(server1 | ||
.getHotrodEndpoint().getPort()).build(); | ||
Configuration conf2 = new ConfigurationBuilder().addServer() | ||
.host(server1.getHotrodEndpoint("hotrodconnector2").getInetAddress().getHostName()) | ||
.port(server1.getHotrodEndpoint("hotrodconnector2").getPort()).build(); | ||
rcm1 = new RemoteCacheManager(conf); | ||
rcm2 = new RemoteCacheManager(conf2); | ||
} | ||
} | ||
|
||
@Test | ||
public void testEndpointConfiguration() throws Exception { | ||
RemoteCache<String, String> cache1 = rcm1.getCache("default"); | ||
RemoteCache<String, String> cache2 = rcm2.getCache("default"); | ||
cache1.put("key", "value"); | ||
cache2.put("key2", "value2"); | ||
assertTrue(1 == server1.getCacheManager("default").getCache("default").getNumberOfEntries()); | ||
assertTrue(1 == server1.getCacheManager("special-cache-container").getCache("default").getNumberOfEntries()); | ||
cache1.remove("key"); | ||
cache2.remove("key2"); | ||
} | ||
|
||
@Test | ||
public void testDefaultCacheAttribute() throws Exception { | ||
RemoteCache<String, String> cache = rcm2.getCache(); | ||
cache.put("key", "value"); | ||
assertTrue(1 == server1.getCacheManager("special-cache-container").getCache("special-cache").getNumberOfEntries()); | ||
assertTrue(0 == server1.getCacheManager("special-cache-container").getCache("default").getNumberOfEntries()); | ||
cache.remove("key"); | ||
} | ||
|
||
/* | ||
* test that eviction-executor, listener-executor and replication-queue-executor attributes have been picked up by | ||
* infinispan-subsystem and jboss.infinispan.default service should depend on these executors | ||
* also test the start attribute: | ||
* 'default' cache container has default start mode (=LAZY) (mode of service - ACTIVE) | ||
* 'special-cache-container' has EAGER start mode (mode of service - ON_DEMAND) | ||
*/ | ||
@Test | ||
public void testExecutorAttributesAndStartMode() throws Exception { | ||
String services = provider.getConnection().invoke(new ObjectName(dumpServicesBean), dumpServicesOp, null, null) | ||
.toString(); | ||
boolean b1 = false, b2 = false, b3 = false; | ||
final String executorPrefix = "jboss.thread.executor."; | ||
Scanner s = new Scanner(services).useDelimiter("\n"); | ||
while (true) { | ||
try { | ||
String line = s.nextLine(); | ||
if (line.contains("Service \"jboss.infinispan.default.config\"") && line.contains("dependencies:")) { | ||
String dependencies = line.substring(line.indexOf("dependencies:")); | ||
if (dependencies.contains(executorPrefix + "test-infinispan-repl-queue") | ||
&& dependencies.contains(executorPrefix + "test-infinispan-listener") | ||
&& dependencies.contains(executorPrefix + "test-infinispan-eviction")) { | ||
b1 = true; | ||
} | ||
} | ||
if (line.contains("Service \"jboss.infinispan.special-cache-container\"") && | ||
line.contains("mode ACTIVE state UP")) { | ||
b2 = true; | ||
} | ||
if (line.contains("Service \"jboss.infinispan.default\"") && | ||
line.contains("mode ON_DEMAND state UP")) { | ||
b3 = true; | ||
} | ||
|
||
} catch (Exception e) { | ||
break; | ||
} | ||
} | ||
assertTrue(b1 && b2 && b3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
server/integration/testsuite/src/test/resources/config/infinispan/cachecontainer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<subsystem xmlns="urn:infinispan:server:core:6.0"> | ||
<cache-container name="default" default-cache="default" listener-executor="test-infinispan-listener" eviction-executor="test-infinispan-eviction" replication-queue-executor="test-infinispan-repl-queue"> | ||
<local-cache name="default" batching="false" /> | ||
</cache-container> | ||
<cache-container name="special-cache-container" start="EAGER" default-cache="special-cache"> | ||
<local-cache name="special-cache" /> | ||
<local-cache name="default" /> | ||
</cache-container> | ||
</subsystem> |
8 changes: 8 additions & 0 deletions
8
server/integration/testsuite/src/test/resources/config/parts/cachecontainer-endpoints.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<subsystem xmlns="urn:infinispan:server:endpoint:6.0"> | ||
<hotrod-connector socket-binding="hotrod" cache-container="default"> | ||
<topology-state-transfer lazy-retrieval="false" lock-timeout="1000" replication-timeout="5000" /> | ||
</hotrod-connector> | ||
<hotrod-connector name="hotrodconnector2" socket-binding="hotrod2" cache-container="special-cache-container"> | ||
<topology-state-transfer lazy-retrieval="false" lock-timeout="1000" replication-timeout="5000" /> | ||
</hotrod-connector> | ||
</subsystem> |
1 change: 1 addition & 0 deletions
1
...r/integration/testsuite/src/test/resources/config/parts/cachecontainer-hotrod-binding.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<socket-binding name="hotrod2" interface="management" port="11223"/> |
22 changes: 22 additions & 0 deletions
22
server/integration/testsuite/src/test/resources/config/parts/cachecontainer-thread-pools.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<subsystem xmlns="urn:jboss:domain:threads:1.1"> | ||
<thread-factory name="infinispan-factory" group-name="infinispan" priority="5"/> | ||
<unbounded-queue-thread-pool name="infinispan-transport"> | ||
<max-threads count="25"/> | ||
<keepalive-time time="0" unit="milliseconds"/> | ||
<thread-factory name="infinispan-factory"/> | ||
</unbounded-queue-thread-pool> | ||
|
||
<scheduled-thread-pool name="test-infinispan-repl-queue"> | ||
<max-threads count="1" /> | ||
<thread-factory name="infinispan-factory"/> | ||
</scheduled-thread-pool> | ||
<unbounded-queue-thread-pool name="test-infinispan-listener"> | ||
<max-threads count="100" /> | ||
<keepalive-time time="1000" unit="MILLISECONDS"/> | ||
<thread-factory name="infinispan-factory"/> | ||
</unbounded-queue-thread-pool> | ||
<scheduled-thread-pool name="test-infinispan-eviction"> | ||
<max-threads count="1" /> | ||
<thread-factory name="infinispan-factory"/> | ||
</scheduled-thread-pool> | ||
</subsystem> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters