1
votes

I am using Neo4J to store test results from some nightly automated testing. I have nodes that represent tests that can be run (:Test), nodes that represent runs of a set of tests (:Run). Each (:Run) has relationships to the existing (:Test) nodes to indicate a "PASS" or "FAIL", i.e.:

http://console.neo4j.org/?id=9hj4w4

I was hoping to be able to construct a cypher query that could look at two (:Run) nodes and return the differences between them -- specifically determine the (:Test) nodes that are different between them, and indicate the relationship (PASS/FAIL) for those differences.

I know it can be done outside of Neo4J, but I was hoping to find a solution that does as much of the work as possible within Neo4J.

2
Your example data doesn't have any instances where there are tests that have different outcomes. Is this intended?Nicole White
Oops - you're right. Not intended. For a variety of reasons, I kept having to recreate my example and it seems the last version had too many cut & pastes. I had intended for at least one of the results to be different.Clark L

2 Answers

0
votes

Let's say you're interested in test differences between Run1 and Run2. You can do:

MATCH (a:Run)-[x]->(t:Test)<-[y]-(b:Run)
WHERE a.name = "Run1" AND b.name = "Run2" AND TYPE(x) <> TYPE(y)
RETURN a.name, TYPE(x), t.name, TYPE(y), b.name
ORDER BY t.name;

Unfortunately your example data doesn't have any instances (between any two runs) where there are different outcomes for the same test. I've made a new example dataset so that we actually get results: http://console.neo4j.org/?id=wlx859

0
votes

try this on for size.
basically match the path for each test and optionally to the same test from another run, then compare the types of relationships ( pass vs fail in this case ) and output the tests that differ.

here is a link to the console borrowed the data from Nicole

MATCH p1 =(a1:Run { name:'Run2' })-[r1]->(t1:Test)
OPTIONAL MATCH p2=(a2:Run { name:'Run1' })-[r2]-(t1)
WITH type(head(relationships(p1))) AS lbl1,type(head(relationships(p2))) AS lbl2, t1
WHERE lbl2 IS NULL OR  lbl1 <> lbl2
RETURN 'Test result mismatched on test: ' + t1.name

one note though. the results differ when you ask the revers of run1 vs run2 and run2 vs run1 ) in the case where the latter has more tests