Jim,

I've found that sharing a minicluster instance via a lazily-initialized
static singleton is simple and effective within tests.  The reason I lean
toward this over the maven plugin is because it works both when executing
tests as part of a maven build and when executing tests from an IDE.  Also,
iterator and other server side code is easy to test with this approach.
Most unit testing frameworks do not provide lifecycle hooks for
initializing before all tests and tearing down after all tests, so the
options are limited for tearing down the minicluster.  Shutdown hooks are
probably the best option.

Here is a basic example that is integrated with JUnit 5 parameter resolvers.
https://github.com/jwonders/ax-accumulo/tree/master/src/test/java/com/jwsphere/accumulo/async

It would be straightforward to extend this to use the maven plugin in the
context of a maven build by choosing a provider implementation based on a
system property as Keith has suggested.  I haven't tried this myself so I'm
not sure exactly how to deal with modules that build server-side code.  The
jar should be available when the minicluster is started by the maven plugin
but I don't know the details of when maven resolves the plugin dependencies
to a file.

Of course, sharing a minicluster means you have to be careful to make tests
independent.  In my experience, it has been worthwhile.



On Fri, Dec 13, 2019 at 1:49 PM Keith Turner <ke...@deenlo.com> wrote:

> One more point about Fluo.  ITBase relies on maven setting a property.
> That is done by the following link.
>
>
> https://github.com/apache/fluo/blob/549d645addb330f4ae2e074447428cb86b5a9a3f/pom.xml#L333
>
> On Fri, Dec 13, 2019 at 10:30 AM Jim Hughes <jhug...@ccri.com> wrote:
> >
> > Hi all,
> >
> > I work on GeoMesa and for the Accumulo 1.x line, we have been using the
> > MockAccumulo infrastructure for our unit/integration tests which run in
> > a Maven build.  In Accumulo 2.x, since MockAccumulo is gone, we're
> > looking at using the MiniAccumulo cluster infrastructure.
> >
> > Are there best practices or examples of how to best use and reuse such a
> > cluster between unit tests?
> >
> > I see two broad options:  First, using Maven's integration test
> > framework to start a cluster 'outside' of a unit test.  Second, we've
> > build a test runner for HBase which starts a cluster and then runs the
> > various tests.  This second approach has some small downsides, and
> > that's why I'm asking if the you all have any great ideas!
> >
> > Cheers,
> >
> > Jim
> >
>

Reply via email to