How to test a Reducer containing a Mutation

169 views Asked by At

I'm attempting to use MRUnit, but none of the examples I've seen quite match what I'm trying to do.

My reducer outputs a key and mutation, but I can't seem to compare the mutation with what's expected. It shows the objects as being the same, but with an address of 0 and the following error:

junit.framework.AssertionFailedError: expected: <org.apache.accumulo.core.data.Mutation@0> but was <org.apache.accumulo.core.data.Mutation@0>

I'm using the reduceDriver.run() method, and attempting assertEquals on my expected mutation object with the actual. Is there anything I'm missing?

Thanks for any input.

3

There are 3 answers

0
tequalsme On

Mutation has an appropriate equals() method, at least it does in the 1.4.x line. However, that method calls a private serialize() method that modifies the data about to be checked.

I've gotten around this in the past by wrapping the Mutation in a new Mutation, which calls serialize under the hood:

 assertEquals(expectedMutation, new Mutation(actualMutation));
0
ohshazbot On

Mutation does not have an appropriate equals() implementation. you're best bet is to probably compare the results of getUpdates() and getRow(). They return a List and byte[] respectively and those are easily comparable.

0
David Medinets On

You can extend Mutation and pass the new class to mrunit. Just override equals in the new class.