hadoop-zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Rosenstrauch <dar...@darose.net>
Subject Re: Testing zookeeper outside the source distribution?
Date Mon, 18 Oct 2010 15:53:10 GMT
On 10/18/2010 08:17 AM, Anthony Urso wrote:
> Anyone have any pointers on how to test against ZK outside of the
> source distribution? All the fun classes (e.g. ClientBase) do not make
> it into the ZK release jar.
>
> Right now I am manually running a ZK node for the unit tests to
> connect to prior to running my test, but I would rather have something
> that ant could reliably
> automate starting and stopping for CI.
>
> Thanks,
> Anthony

The way I learned about unit testing is that a unit test should be 
"isolated", that is:  not need to depend on any external resource - most 
notably network resources, such as a database, a web server, or 
ZooKeeper.  (It's still OK to have a test that tests again a network 
resource, but that's really an integration test, not a unit test.)

Consequently, the way I write my code for ZooKeeper is against a more 
generic interface that provides operations for open, close, getData, and 
setData.  When unit testing, I substitute in a "dummy" implementation 
that just stores data in memory (i.e., a HashMap); when running live 
code I use an implementation that talks to ZooKeeper.

HTH,

DR

Mime
View raw message