Forum: Building VoltDB Clients

Post: Unit testing

Unit testing
kdombeck
Nov 2, 2010
I tried to write a unit test (TestNG) which dynamically starts an instance of VoltDB. But if VoltDB fails to start for any reason it calls System.exit(-1) (noticed this in ServerThread constructors) and this then kills the unit test and does not signal failure. If it threw an exception instead of System.exit() this problem would be solved or is there a different way to start up Volt for unit tests?
I was using the following code in the setup() method of my unit tests.
Server server = new ServerThread(config);
server.start();
server.waitForInitialization();
On ServerThread
jhugg
Nov 4, 2010
We use the "ServerThread" class for some of our unit testing with JUnit. We use the ability of JUnit with Ant or Eclipse to fork processes, so that if VoltDB dies, then the test is considered a failure.
We also have several classes that behave like ServerThread, but manage an outside process. See "org.voltdb.regressionsuites.LocalSingleProcessServer" or "org.voltdb.regressionsuites.LocalCluster".
I haven't used TestNG to know if there's a workaround for this like there is with JUnit, but I've gone and created a ticket for this issue: https://issues.voltdb.com/browse/ENG-872. It's not currently scheduled for a release, but you can monitor and vote on the issue there.