Skip to content

[BEAM-2682] Deletes AvroIOTransformTest#3999

Closed
jkff wants to merge 1 commit intoapache:masterfrom
jkff:rm-avroio-transform
Closed

[BEAM-2682] Deletes AvroIOTransformTest#3999
jkff wants to merge 1 commit intoapache:masterfrom
jkff:rm-avroio-transform

Conversation

@jkff
Copy link
Copy Markdown
Contributor

@jkff jkff commented Oct 16, 2017

Instead, merges the little test coverage it provided into AvroIOTest.

This supersedes #3948 - merging these two test classes is long overdue and AvroIOTransformTest was quite bad code:

  • the parameterized tests in AvroIOTransformTest were considerably more verbose and less readable than doing the same thing without parameterization
  • it provided little additional coverage over AvroIOTest
  • it didn't use the "write pipeline, then read pipeline" recommended approach

R: @echauchot

@jkff
Copy link
Copy Markdown
Contributor Author

jkff commented Oct 17, 2017

retest this please

@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling b59a742 on jkff:rm-avroio-transform into ** on apache:master**.

@jkff
Copy link
Copy Markdown
Contributor Author

jkff commented Oct 18, 2017

Ping?

@echauchot
Copy link
Copy Markdown
Contributor

@jkff I started the review, should be done by the end of the day.

Copy link
Copy Markdown
Contributor

@echauchot echauchot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for simplifying all these tests Eugene!
I only have a couple of suggestions, a question and tiny minor changes.

@Test
@Category(NeedsRunner.class)
public void testAvroIOWriteAndReadAndParseASingleFile() throws Throwable {
public void testAvroIOWriteAndReadJavaClass() throws Throwable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for AvroIO.writeCustomType() even if it was not tested before and even if there is a test for its GenericRecord specialization?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if that makes any sense to also test AvroIO.write(AvroGeneratedUser.class) and AvroIO.read(AvroGeneratedUser.class). The only difference with the existing test is that the input class is not a user provided class but an avro generated one. As behind the scene same SpecificDatumWriter<Class> will be called, the code might not behave differently. WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, added coverage for these, thanks for pointing it out.

public void testAvroIOWriteAndReadJavaClass() throws Throwable {
List<GenericClass> values =
ImmutableList.of(new GenericClass(3, "hi"), new GenericClass(5, "bar"));
File outputFile = tmpFolder.newFile("output.avro");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you define a constant for the file name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth it. The value of this string literal doesn't matter and it can be changed without breaking the code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, since all "output.avro" in this class are not related to each other, I agree. fair enough.


@Test
@Category(NeedsRunner.class)
public void testAvroIOWriteAndReadAndParseJavaClassSingleFile() throws Throwable {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the method is very precise but still lacks some cases that it tests. IMHO I would rename to something less precise like testAvroIOWriteAndReadAllMeansJavaClass.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this one and renamed other tests to be more consistent.

AvroIO.writeGenericRecords(SCHEMA)
.to(writePipeline.newProvider(outputFile.getAbsolutePath()))
.withoutSharding());
writePipeline.run().waitUntilFinish();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there sometimes a blocking call to writePipeline.run().waitUntilFinish(); and sometimes a non blocking call to writePipeline.run() for example l975 of AvroIOTest? In l975 for example, files written by the writePipeline are read just after the non blocking call to writePipeline.run()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All waitUntilFinish() calls were unnecessary, I removed them.

Instead, merges the little test coverage it provided into AvroIOTest.
@jkff jkff force-pushed the rm-avroio-transform branch from b59a742 to 6b43f6a Compare October 19, 2017 21:17
Copy link
Copy Markdown
Contributor

@echauchot echauchot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! LGTM

@asfgit asfgit closed this in f7aa41a Oct 20, 2017
@jkff jkff deleted the rm-avroio-transform branch October 20, 2017 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants