Monday, 15 May 2017

NoSQL Unit supports Infinispan 9.0.0.Final

NoSQL Unit is a JUnit extension that helps you write NoSQL unit tests, created by Alex Soto. It brings the ideas first introduced by DBUnit to the world of NoSQL databases.

The essence of DBUnit or NoSQL Unit is that before running each test, the persistence layer is found in a known state. This makes your test repeatable, independent of other test failures or potential database corruptions.

You can use NoSQL Unit for testing embedded or remote Infinispan instances, and since version 1.0.0-rc.5, which was released a few days back, it supports the latest Infinispan 9.0.0.Final.

We have a created a little demo GitHub repository showing you how to test Infinispan using NoSQL Unit. Go and give it a go! :)

Thanks Alex bringing NoSQL Unit to my attention!

Cheers,

Galder

Posted by Galder Zamarreño on 2017-05-15
Tags: testing nosqlunit

Tuesday, 05 November 2013

Infinispan Arquillian Container 1.1.0.Alpha1 released

Dear Infinispan users, a new version of Infinispan Arquillian Container has been released into JBoss Maven Repository as maven artifacts. The previous version was announced by http://blog.infinispan.org/2012/09/infinispan-arquillian-container-100cr1.html The blog post contains information related to setup of JBoss Maven Repository, including its address as well as address of the Infinispan Arquillian Container itself.

Maybe we should now call the project Infinispan Arquillian extension rather than Infinispan Arquillian Container because, since version 5.3, Infinispan Server has been based on JBoss Application Server 7 and the submodule called infinispan-arquillian-container could be removed.

As a result, the configuration of Arquillian with respect to Infinispan Server was simplified.

Developing tests with Infinispan Server

Now there’s only one way to compose the arquillian.xml file:

The property ispnHome no longer exists. The path to the Infinispan Server is now specified via jbossHome. The serverConfig attribute then specifies the correct configuration file for the server.

In order to run tests with Infinispan Arquillian extension, one should use the following dependencies: org.jboss.as:jboss-as-arquillian-container-managed:jar:7.2.0.Final:test org.infinispan.arquillian.container:infinispan-arquillian-impl:jar:1.1.0.Alpha1:test

Now that we’ve configured the server to run in our tests, it’s time to introduce a few enhancements which will help you write tests more effectively.

RemoteInfinispanServers

You can still inject the reference to a running Infinispan Server by annotating an instance variable of type RemoteInfinispanServer with @InfinispanResource.

When there are more Infinispan servers to be injected, you can now use the following snippet instead of injecting each server independently:

  Then you can retrieve individual servers by calling .getServer(name) on the servers variable. The name must correspond to an existing container definition within arquillian.xml. The results of this call will be of type RemoteInfinispanServer.

WithRunningServer

So far users were forced to start the Infinispan Server either before the whole test suite (mode="suite") or before each class separately (mode="class"). The annotation WithRunningServer enables users to automatically start the server before a test method and stop it after the method. Example:

Note that in this case containers should be marked as mode="manual" in arquillian.xml file so that Infinispan Arquillian extension can handle lifecycle of these servers by itself.

When @WithRunningServer annotation is placed on a class, the server(s) will be started before the first method call in the test class, and stopped when JUnit @AfterClass event is triggered.

IPv6 support

Infinispan Arquillian extension can now work with Infinispan Server running on IPv6 as it can correctly connect to the server via JMX.

Testing embedded Infinispan

Running tests with plain Infinispan libraries instead of Infinispan Server has not changed since the last release. Read more about it in the previous blog post.

Thanks to Michal Linhard and Vitalii Chepeliuk who helped move the project one step further.

Cheers, Martin

Posted by Martin Genčúr on 2013-11-05
Tags: testing announcement

Wednesday, 05 September 2012

Infinispan Arquillian Container 1.0.0.CR1 released

Infinispan Arquillian Container is an extension to Arquillian that provides several ways to interact with Infinispan, either with a standalone Infinispan server or just with Infinispan libraries. This extension can also communicate with JBoss Data Grid server via JMX.

It was released as Maven artifacts in JBoss Maven Repository. It is located at http://repository.jboss.org/nexus/content/groups/public-jboss/ . More information on how to set up and use the repo can be found at https://community.jboss.org/wiki/MavenGettingStarted-Users

What does this Arquillian extension offer to you? Let me describe all aspects of this extension one by one.

Developing tests with standalone Infinispan server

When testing, you might want to automatically start the Infinispan server before the test and stop it afterwards. This can be achieved by configuring infinispan-arquillian-container via Arquillian’s configuration file. The following is a subset of attributes that can be specified and thus passed to the Infinispan server during startup: masterThreads, workerThreads, cacheConfig, jmxPort, …​ The complete list can be found in bit.ly/R7j4d1 (all private fields).

Examples are not a part of the release, only libraries are. In order to check out examples provided with the project, one has to clone project’s repository: https://github.com/mgencur/infinispan-arquillian-container Examples are located in the respective sub-directory.

The configuration file then looks similar to the following:

Whether these two Infinispan servers are clustered or not depends on the configuration passed to them via cacheConfig (file path) attribute or their default configuration (when no config. file is passed). The configuration in arquillian.xml file just says: "Start these two instances with whatever configuration is passed to them".

Complete example: bit.ly/RkrpEE

When we tell Arquillian to work with Infinispan server, we can inject RemoteInfinispanServer object into our test. Such an object provides various information about the running Infinispan server. For example, we can retrieve a hostname and HotRod port and use these pieces of information to create a RemoteCacheManager instance. Besides that users are allowed to retrieve information available via JMX from the server like cluster size, number of entries in the cache, number of cache hits and many more.

Complete example: http://bit.ly/OaCw8q

Vital dependencies required for the test to run are:

org.infinispan.arquillian.container:infinispan-arquillian-container-managed:jar:1.0.0.CR1:test org.infinispan.arquillian.container:infinispan-arquillian-impl:jar:1.0.0.CR1:test

Not only with standalone Infinispan server can Infinispan Arquillian extension work.

Developing tests with JBoss Data Grid (JDG) server

This time, the properties in Arquillian’s configuration file are different and correspond to properties of JBoss Application Server 7. The most important property is again the path to the server (jbossHome).

Are you interested in what the test looks like? It looks completely the same as tests for standalone Infinispan server, you just have a few more attributes available. JDG server usually starts all three endpoints (HotRod, Memcached, REST) at the same time while for the Infinispan server you have to specify which end point should be started. Furthermore, Infinispan server does not have the REST endpoint available out-of-the-box.

As a result, you can call the following methods with JDG in one single test.

server1.getMemcachedEndpoint().getPort(); server1.getRESTEndpoint().getContextPath(); server1.getHotRodEndpoint().getPort();

The difference is, of course in dependencies. Instead of a handler for standalone Infinispan server, one has to use a handler for JBoss AS 7. The dependencies then look like this:

org.jboss.as:jboss-as-arquillian-container-managed:jar:7.1.2.Final:test org.infinispan.arquillian.container:infinispan-arquillian-impl:jar:1.0.0.CR1:test

Testing Infinispan libraries

Sometimes we don’t want to use a standalone server. Sometimes we want to test just Infinispan in its basic form - Java libraries. Infinispan has been under development for years and during that time, lots of tests were developed. With tests come utility methods. Infinispan Arquillian Container enables you to leverage these utility methods and call them via an instance of DatagridManager. This instance can be easily injected into a test, no matter which test framework (TestNG, JUnit) you use.

DatagridManager class can be found at http://bit.ly/Q0a7ki

Can you see the advantage? No? Let me point out some useful methods available in the manager.

List<Cache<K, V>> createClusteredCaches(int numMembersInCluster, String cacheName, ConfigurationBuilder builder)

  • creates a cluster of caches with certain name and pre-defined configuration

void waitForClusterToForm()

  • helps to wait until the cluster is up and running

Cache<A, B> cache(int index)

  • retrieves a cache from certain node according to the index

Cache<A, B> cache(int managerIndex, String cacheName)

  • retrieves a cache with that name

void killMember(int cacheIndex)

  • kills a cache with cacheIndex index

AdvancedCache advancedCache(int i)

  • retrieves an advanced cache from node i

Trancation tx(int i)

  • retrieves a transaction from node i

TransactionManager tm(int i)

  • retrieves a transaction manager from node i

…​and much more.

The following test can be found among other examples in the GIT repository.

Required dependencies:

org.infinispan:infinispan-core:jar:5.1.5.FINAL:test  -  users should replace this version with the one they want to test org.infinispan.arquillian.container:infinispan-arquillian-impl:jar:1.0.0.CR1:test

Infinispan Arquillian Container was tested with Infinispan 5.1.5.FINAL and JDG 6.0.0.GA. Nevertheless, it should work smoothly also with other not-very-distinct versions. I’ll be updating the project to work with newer versions of both Infinispan and JBoss Data Grid.  

Posted by Martin Genčúr on 2012-09-05
Tags: testing data grids

Thursday, 18 June 2009

Executing TestNG tests relying on @Parameters from Eclipse

If you wanna run TestNG tests relying on @Parameters like the one below from Eclipse, you need to pass some value for the 'basedir' parameter, otherwise Eclipse will complain:

@Test(groups = "unit", enabled = true, testName = "loaders.bdbje.BdbjeCacheStoreIntegrationTest")
public class BdbjeCacheStoreIntegrationTest extends BaseCacheStoreTest {

  private String tmpDirectory;

  @BeforeTest
  @Parameters({"basedir"})
  protected void setUpTempDir(String basedir) {
     tmpDirectory = basedir + TestingUtil.TEST_PATH + File.separator + getClass().getSimpleName();
  }
...

Having looked around on the web, it’s not clear how to do this and some people even seem to claim that it’s not doable. However, having looked at how Maven deals with this, you simply have to pass the parameter as system property and it will work. So, if you wanna run BdbjeCacheStoreIntegrationTest from Eclipse, simply pass a system property like this:

-Dbasedir=/home/galder/tmp

Otherwise, Eclipse will moan with a message like this:

org.testng.TestNGException:
Parameter 'basedir' is required by @Configuration on method setUpTempDir
Posted by Galder Zamarreño on 2009-06-18
Tags: ide testing

News

Tags

JUGs alpha as7 asymmetric clusters asynchronous beta c++ cdi chat clustering community conference configuration console data grids data-as-a-service database devoxx distributed executors docker event functional grouping and aggregation hotrod infinispan java 8 jboss cache jcache jclouds jcp jdg jpa judcon kubernetes listeners meetup minor release off-heap openshift performance presentations product protostream radargun radegast recruit release release 8.2 9.0 final release candidate remote query replication queue rest query security spring streams transactions vert.x workshop 8.1.0 API DSL Hibernate-Search Ickle Infinispan Query JP-QL JSON JUGs JavaOne LGPL License NoSQL Open Source Protobuf SCM administration affinity algorithms alpha amazon anchored keys annotations announcement archetype archetypes as5 as7 asl2 asynchronous atomic maps atomic objects availability aws beer benchmark benchmarks berkeleydb beta beta release blogger book breizh camp buddy replication bugfix c# c++ c3p0 cache benchmark framework cache store cache stores cachestore cassandra cdi cep certification cli cloud storage clustered cache configuration clustered counters clustered locks codemotion codename colocation command line interface community comparison compose concurrency conference conferences configuration console counter cpp-client cpu creative cross site replication csharp custom commands daas data container data entry data grids data structures data-as-a-service deadlock detection demo deployment dev-preview development devnation devoxx distributed executors distributed queries distribution docker documentation domain mode dotnet-client dzone refcard ec2 ehcache embedded query equivalence event eviction example externalizers failover faq final fine grained flags flink full-text functional future garbage collection geecon getAll gigaspaces git github gke google graalvm greach conf gsoc hackergarten hadoop hbase health hibernate hibernate ogm hibernate search hot rod hotrod hql http/2 ide index indexing india infinispan infinispan 8 infoq internationalization interoperability interview introduction iteration javascript jboss as 5 jboss asylum jboss cache jbossworld jbug jcache jclouds jcp jdbc jdg jgroups jopr jpa js-client jsr 107 jsr 347 jta judcon kafka kubernetes lambda language learning leveldb license listeners loader local mode lock striping locking logging lucene mac management map reduce marshalling maven memcached memory migration minikube minishift minor release modules mongodb monitoring multi-tenancy nashorn native near caching netty node.js nodejs nosqlunit off-heap openshift operator oracle osgi overhead paas paid support partition handling partitioning performance persistence podcast presentations protostream public speaking push api putAll python quarkus query quick start radargun radegast react reactive red hat redis rehashing releaase release release candidate remote remote events remote query replication rest rest query roadmap rocksdb ruby s3 scattered cache scripting second level cache provider security segmented server shell site snowcamp spark split brain spring spring boot spring-session stable standards state transfer statistics storage store store by reference store by value streams substratevm synchronization syntax highlighting testing tomcat transactions tutorial uneven load user groups user guide vagrant versioning vert.x video videos virtual nodes vote voxxed voxxed days milano wallpaper websocket websockets wildfly workshop xsd xsite yarn zulip

back to top