Running unit tests for UnpackedAvroSource result#790
Conversation
Running the test via `test-only com.twitter.scalding.avro.AvroUnpackedSourceTest` leads to `java.lang.IndexOutOfBoundsException: Index: 12, Size: 1` Includes the generated Avro classes to avoid integrating Avro into the sbt build
|
@ccsevers Can you take a look at this? Would be great to get this branch green. |
|
Will have a look in the next day or two. Still a touch jet lagged. |
|
Just a quick update, I haven't forgotten this but have been at essentially a conference all week after returning from overseas and haven't had the time to work this out. I'll get to it as soon as I can. |
|
So I think what is going on here is that the Memory tap that gets used for testing is bypassing the unpacking step that happens in the cascading.avro scheme. If I add another test for the PackedAvroScheme it passes fine. I believe I've seen this same behavior with SequenceFiles (unpacking to (k,v) tuple) I'll modify the tests to read/write as full jobs (rather than job test) and see that the behavior is correct. |
|
Yes, it is hard to test sources with the JobTest framework as it is actually mocking them. Maybe that is the whole issue here. I'm not sure of an easy fix. The memory source tap just serializes the data into the jobconf, and in this case, it will serialize the avro record. So, it won't unpack it on the other side in the test, so there will just be a single record, not a tuple. We should make this more testable, but it will require a bit of design work on how to get the same unpacking at test time. Also note here is an error: |
|
Do you think a reasonable workaround for now is to skip JobTest and just run the job and read the output? |
|
Okay I can make this green but it's a bit ugly: |
|
Thanks, I will try to use that for the time being. A cleaner unit testing solution would be great however. |
|
To test integration stuff like this look at the PlatformTest class and use El lunes, 21 de julio de 2014, Marius Soutier notifications@github.com
|
This pull requests reproduces the issue I'm experiencing with testing
AvroUnpackedSourceviaJobTest.In sbt, you can run the test via
test-only com.twitter.scalding.avro.AvroUnpackedSourceTest, resulting in ajava.lang.IndexOutOfBoundsException: Index: 12, Size: 1.I included the generated Avro classes to avoid having to integrate Avro into the sbt build.