Units test on a Titan Graph

113 views
Skip to first unread message

Beau Plath

unread,
Mar 29, 2015, 5:19:48 PM3/29/15
to aureliu...@googlegroups.com
I have recently started to experiment with Titan and have a question regarding unit tests on functionality using a graph.

Conceptually, I'd like to write multiple test classes that encompass test cases for a given concept.  Each concept relates to a portion of the graph so for testing purposes I'd like to create a single small version of the graph only supplying a limited number of vertices/edges relevant to that concept which means one small graph per test class.  

I have a small poc working where I have two junit test classes (two concepts), each loading their own version of the graph using inmemory storage (init graph before class with @BeforeClass and shutdown the graph with @AfterClass).  If I run all tests for either class by itself, all test in that class complete successfully.  However if I run all tests for both classes (build tool or via IDE) then one class completes successfully and the other class fails all cases.  No exception is thrown but with some debugging turned on I see that my search queries come back with no results which then ends up failing the test based on other assertions (remember this isn't the case if the class is run by itself).

I looked at configuration setup and thought perhaps using separate property files for each test case's graph that perhaps I could achieve a separation however it seems that inmemory has limitations that do not exist on other persistence models like Casandra (defining a namespace for each inmemory graph or using the storage.machine-id-appendix - however both result in stack traces that seem to point to a requirement of using a different persistence model).  I was hoping to avoid using any persistence and stick with inmemory since the graphs are compact and need to be initialize, populated and torn down rather fast for each test class.

Has anyone else tried something like this and if so how did you go about it?

Richard Wilburn

unread,
Apr 6, 2015, 7:51:01 PM4/6/15
to aureliu...@googlegroups.com
I have written some in JUnit against TP3 M 0.0.0.8 (Titan 0.9 from the online Maven repo). I am doing read only queries using an integration rather than unit test TDD approach which reads a graphML file using GraphMLReader. It doesn't seem to have any issues (other than when I was double iterating over gremlin query parts; it seems that isn't permitted (and is likely not good practice anyway).)

What version of Titan / Tinkerpop are you using? Perhaps you could share your stacktrace?
Reply all
Reply to author
Forward
0 new messages