[hibernate-dev] OGM test refactoring
Jonathan Halliday
jonathan.halliday at redhat.com
Wed Apr 15 07:41:07 EDT 2015
In the course of developing the cassandra backend for OGM I've hit an
issue with some of the backendtck tests.
These tests are in core and reused by each backend. It's possible to
exclude tests at class or method level per backend, which prevents
irrelevant tests from running for a given backend. So far, so good.
The problem I'm seeing stems from the fact that even when a test is
excluded, the annotated POJOs it uses are still parsed and passed
through schema creation, since that occurs in a setup step before the
individual tests are iterated and (not) run.
There are certain POJOs that contains mappings cassandra can't support.
Even with the corresponding test disabled, when these are passed to the
schema creator it blows up, effectively preventing the other legitimate
tests in the same class from running.
In an ideal world I'd like a class/method level annotation listing the
required POJOs to replace the getAnnotatedClasses method, allowing POJOs
to be parsed or skipped in accordance with the corresponding annotation
on the same test method.
@RequiredPOJO(Foo.class)
@Test
@SkipByGridDialect(...)
public void testFoo()
Alternatively I can (I think) subclass the test class in the backend and
override the getAnnotatedClasses method to exclude the problem POJOs,
whilst leaving the @SkipByGridDialect on the shared parent for clarity.
Or simply copy and paste the whole thing and nuke the offending
POJOs/methods in my backend's copy.
On a related note, many of the offending tests could be altered in such
a way that the resulting schema is acceptable to cassandra, which would
largely sidestep the issue but alter the test semantics. In many
instances I suspect the semantic in question is one that's not critical
to the test's intent, but I may be wrong.
Essentially cassandra uses what a relational db would call 'index
organized tables', i.e. the on-disk layout of data is a function of the
table's key. As a result, it's not possible to declare tables without a
primary key. Such mappings result from collections with bag semantics,
such as @OneToMany List<Object>, since the list may have dups. Removing
the bag semantics such as by adding an index column, avoids this issue.
But then you're testing something different...
Any preference on the approach to changing the test suite?
Jonathan.
--
Registered in England and Wales under Company Registration No. 03798903
Directors: Michael Cunningham (USA), Matt Parson
(USA), Charlie Peters (USA), Michael O'Neill(Ireland)
More information about the hibernate-dev
mailing list