Skip to content

Commit

Permalink
Added a README, and enabled a forgotten test.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmontag committed Feb 12, 2011
1 parent 74d89e6 commit da6aae9
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 7 deletions.
122 changes: 122 additions & 0 deletions README.txt
@@ -0,0 +1,122 @@
Neo4j store compatibility tests
===============================

This project aims to create a backward compatibility test suite intended for
continuous use. Its main goal is to detect problems related to store upgrades
between versions.

It does this by storing a set of test stores generated by so-called agents.
A Neo4j version will run a number of agents, generating a number of test stores
for that version. An agent is a Java class implementing StoreAgent, and it
is capable of both generating a store and, given a store, verifying that it
matches what it created.

File structure
--------------

src/
framework/ Testing framework classes
versions/ Version-specific tests
default/ Default test suite
agents/ Package for agents
META-INF/
services/
org.neo4j.compatibility.StoreAgent References agents to be used
1.2.M06 "Patch" suite, applied on default suite for compatibility of
certain versions.
1.2.M05
...

Scripts
-------

./generate.sh <version>

Generate new test stores for the specified Neo4j version.

./generate-all.sh

Generate new test stores for all Neo4j versions specified in the script.

./verify.sh <version>

Verify that the Neo4j version specified can verify all stored test store
versions.

Examples
--------

./generate.sh 1.2.M04

./generate-all.sh

./verify.sh 1.3-SNAPSHOT

New versions
------------

When a new version of Neo4j is released, the previous version needs to be
rotated into the set of versions tested against. This can be done by executing:

./generate.sh <version>

for the version that is being rotated. Also add the rotated version to the set
of versions in generate-all.sh. For example, if 1.3.M03 is being released,
just do:

./generate.sh 1.3.M02

and verify the new version:

./verify 1.3.M03

Adding new tests
----------------

The default behavior should be to add new tests to src/versions/default.
Simply give your class a unique name (that shouldn't change), and make your
class implement StoreAgent. Finally, add your class name to
src/versions/default/META-INF/services/org.neo4j.compatibility.StoreAgent. It
will then be picked up when generating and verifying test stores.

Managing code incompatibility
-----------------------------

Sometimes changes to new code break old code. In general it is good to preserve
working test code for each version of Neo4j.

If a new release breaks code in src/versions/default, simply create a
version-specific directory for the broken version and copy the broken test
cases there. Then fix the code in src/versions/default to match the latest
release.

Rotated releases can opt to not do any verification, since it is generally the
latest version that will get verified.

Code merging procedure
----------------------

When a version is to be generated or verified, first it is determined whether
a specific version directory for that version exists or not. If none is found,
then the default is used, and that is that.

If a version directory is found, existence for a file named "no-default" is
checked. If such a file exists, the default will not be used as the template.
Then the classes used will simply be the ones in that version directory.

If there is no "no-default" file, then the defaults are used as a template, and
any files that exist in the version directory replace the ones in the default
set. Note that this includes the META-INF/... file. Typically there will be two
use cases:

1. The tested version's code does not compile with the default, and therefore
requires special changes. An example is graphDb.index() vs IndexService.

2. A specific test case class (agent) should not be used for this version. This
is easily achieved by making an empty class with the same name, that
inherits from IgnoringStoreAgent. It will not be picked up as a store agent.

So to sum up:

exists( version/no-default ) ? version : default + version

4 changes: 2 additions & 2 deletions build.xml
Expand Up @@ -73,13 +73,13 @@
</condition> </condition>
</target> </target>


<target name="compile-default" depends="check-should-copy-default" if="should.copy.default"> <target name="copy-default" depends="check-should-copy-default" if="should.copy.default">
<copy todir="${src.effective.dir}"> <copy todir="${src.effective.dir}">
<fileset dir="${src.default.dir}" includes="**/*"/> <fileset dir="${src.default.dir}" includes="**/*"/>
</copy> </copy>
</target> </target>


<target name="compile-version" depends="compile-default"> <target name="compile-version" depends="copy-default">
<copy todir="${src.effective.dir}" overwrite="true"> <copy todir="${src.effective.dir}" overwrite="true">
<fileset dir="${src.version.dir}" includes="**/*"/> <fileset dir="${src.version.dir}" includes="**/*"/>
</copy> </copy>
Expand Down
@@ -1,4 +1,5 @@
agents.SimpleGraph agents.SimpleGraph
agents.SimpleIndexingGraph agents.SimpleIndexingGraph
agents.UnclosedIndexingGraph agents.UnclosedIndexingGraph
agents.FulltextIndexingGraph agents.FulltextIndexingGraph
agents.ExhaustiveGraph
8 changes: 4 additions & 4 deletions src/versions/default/agents/ExhaustiveGraph.java
Expand Up @@ -72,10 +72,10 @@ public void verify( String dbPath )
} }
assertEquals( new HashSet<Node>( Arrays.asList( personB, personC, personD ) ), actual ); assertEquals( new HashSet<Node>( Arrays.asList( personB, personC, personD ) ), actual );


assertEquals( personA, personB.getSingleRelationship( WORKS_FOR, Direction.INCOMING ) ); assertEquals( personA, personB.getSingleRelationship( WORKS_FOR, Direction.INCOMING ).getStartNode() );
assertEquals( personC, personB.getSingleRelationship( WORKS_FOR, Direction.OUTGOING ) ); assertEquals( personC, personB.getSingleRelationship( WORKS_FOR, Direction.OUTGOING ).getEndNode() );


assertEquals( personD, personC.getSingleRelationship( WORKS_FOR, Direction.OUTGOING ) ); assertEquals( personD, personC.getSingleRelationship( WORKS_FOR, Direction.OUTGOING ).getEndNode() );
assertEquals( personC, personD.getSingleRelationship( WORKS_FOR, Direction.INCOMING ) ); assertEquals( personC, personD.getSingleRelationship( WORKS_FOR, Direction.INCOMING ).getStartNode() );
} }
} }

0 comments on commit da6aae9

Please sign in to comment.