Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blog article: Howto test a batch source with the new Source framework #643

Merged
merged 19 commits into from
May 22, 2023

Conversation

echauchot
Copy link
Contributor

Last article of the series about testing the created batch source in the previous article.

R:@zentol. Feel free to delegate as you have already the previous 2 articles to review.

@echauchot
Copy link
Contributor Author

@MartijnVisser @zentol did almost all my last reviews. Would you have time to review this small article as you know the source framework ?

Copy link
Contributor

@zentol zentol left a comment

Choose a reason for hiding this comment

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

I took a quick look over it. I feel especially for the IT case it would be nice to first provide an overview over the differnet parts that make up a test "There's a test framework; We need a backend the source can read from, a test context for Flinks testing framework to interact with the backend, ..." and then drill down into the details as you already did.

Right now it's very "I have to do this and this and this" but you don't really know where you're heading.


### Testing the serializers

[example Cassandra SplitSerializer](https://github.com/apache/flink-connector-cassandra/blob/d92dc8d891098a9ca6a7de6062b4630079beaaef/flink-connector-cassandra/src/main/java/org/apache/flink/connector/cassandra/source/split/CassandraSplitSerializer.java)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
[example Cassandra SplitSerializer](https://github.com/apache/flink-connector-cassandra/blob/d92dc8d891098a9ca6a7de6062b4630079beaaef/flink-connector-cassandra/src/main/java/org/apache/flink/connector/cassandra/source/split/CassandraSplitSerializer.java)
[Example Cassandra SplitSerializer](https://github.com/apache/flink-connector-cassandra/blob/d92dc8d891098a9ca6a7de6062b4630079beaaef/flink-connector-cassandra/src/main/java/org/apache/flink/connector/cassandra/source/split/CassandraSplitSerializer.java)

Copy link
Contributor Author

@echauchot echauchot May 12, 2023

Choose a reason for hiding this comment

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

done

docs/content/posts/howto-test-batch-source.md Outdated Show resolved Hide resolved
docs/content/posts/howto-test-batch-source.md Outdated Show resolved Hide resolved
](https://github.com/apache/flink-connector-cassandra/blob/d92dc8d891098a9ca6a7de6062b4630079beaaef/flink-connector-cassandra/src/test/java/org/apache/flink/connector/cassandra/source/CassandraSourceITCase.java)

For tests that require a running backend, Flink provides a JUnit5 source test framework. To use it
we create an *ITCase named class that
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
we create an *ITCase named class that
we create an *ITCase named class that

The name only really matters if the test is added to Flink. I think we shouldn't assume that because users might have their own sources they want to test that won't be contributed to Flink.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

MiniClusterTestEnvironment flinkTestEnvironment = new MiniClusterTestEnvironment();
`

### Backend runtime environment
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe some high-level intro line what this is about could be helpful.

Something like "To test the connector we need a backend to run the connector against. Something something need to implement something to integrate this into junit5; maybe provided by library."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

docs/content/posts/howto-test-batch-source.md Outdated Show resolved Hide resolved
docs/content/posts/howto-test-batch-source.md Outdated Show resolved Hide resolved
docs/content/posts/howto-test-batch-source.md Outdated Show resolved Hide resolved
Comment on lines 152 to 153
The test context is scoped to the test case. So it is where we do things like creating test table,
creating the source or writing test data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The test context is scoped to the test case. So it is where we do things like creating test table,
creating the source or writing test data.
The test context provides Flink with means to interact with the backend, like inserting test data/tables or constructing sources/sink.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with the rephrasing but I'd like also to keep the important notion of test case scope of the TestContext (compared to test suite scope of the backend environment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

MiniClusterTestEnvironment flinkTestEnvironment = new MiniClusterTestEnvironment();
`

### Backend runtime environment
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
### Backend runtime environment
### Backend environment

It is never referenced as "backend runtime environment" in subsequent sections

Copy link
Contributor Author

@echauchot echauchot May 12, 2023

Choose a reason for hiding this comment

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

ok fair enough, in that case I'll also remove "runtime" from the "Flink runtime environment" title for coherence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@echauchot
Copy link
Contributor Author

echauchot commented May 12, 2023

I took a quick look over it. I feel especially for the IT case it would be nice to first provide an overview over the differnet parts that make up a test "There's a test framework; We need a backend the source can read from, a test context for Flinks testing framework to interact with the backend, ..." and then drill down into the details as you already did.

Right now it's very "I have to do this and this and this" but you don't really know where you're heading.

Totally agree, I'll do something similar to what I did on the source creation blog: an architecture paragraph

echauchot and others added 18 commits May 12, 2023 12:21
Co-authored-by: Chesnay Schepler <chesnay@apache.org>
Co-authored-by: Chesnay Schepler <chesnay@apache.org>
Co-authored-by: Chesnay Schepler <chesnay@apache.org>
Co-authored-by: Chesnay Schepler <chesnay@apache.org>
Co-authored-by: Chesnay Schepler <chesnay@apache.org>
Co-authored-by: Chesnay Schepler <chesnay@apache.org>
@echauchot
Copy link
Contributor Author

I took a quick look over it. I feel especially for the IT case it would be nice to first provide an overview over the differnet parts that make up a test "There's a test framework; We need a backend the source can read from, a test context for Flinks testing framework to interact with the backend, ..." and then drill down into the details as you already did.
Right now it's very "I have to do this and this and this" but you don't really know where you're heading.

Totally agree, I'll do something similar to what I did on the source creation blog: an architecture paragraph

done

@echauchot
Copy link
Contributor Author

@zentol Thanks for your review (once again). I addressed all your comments PTAL

@echauchot echauchot merged commit a510008 into apache:asf-site May 22, 2023
@echauchot echauchot deleted the blog-test-batch-source branch May 23, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants