-
Notifications
You must be signed in to change notification settings - Fork 85
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
[FLINK-35424] Elasticsearch connector 8 supports SSL context #104
Conversation
9de11c2
to
7821b30
Compare
@reta and @snuyanzin Could you take a look? Also I'm not sure how to fix the pre-check failure:
Thanks! |
I think slight change to |
Sure, I will do that within next few days, thank you @liuml07 ! |
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** Utility class for Elasticsearch8 tests. */ | ||
public class Elasticsearch8TestUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this class vs using existing ElasticsearchSinkBaseITCase
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, it's not required. ElasticsearchSinkBaseITCase
creates a static ES container while the new test Elasticsearch8AsyncSinkSecureITCase
needs to create the secure ES container. The new one does not really inherit this base class, but simply refer to those static fields. I think it's a bit clearer to extract those common fields and methods so secure vs. non-secure tests are completely independent.
I don't have strong preference on this and can move it back to the ElasticsearchSinkBaseITCase
class if we feel it's better to keep them in the base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong preference on this and can move it back to the ElasticsearchSinkBaseITCase class if we feel it's better to keep them in the base class.
It looks more straightforward to me to be fair (with ElasticsearchSinkBaseITCase), the container creation could be parameterized if needed, thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed the parameterized tests will reuse the code at the max level and still keep separate cases/parameters independent. I thought of this idea previously but realized the ES_CONTAINER
field is static (to amortize cost of container setup) and annotated @Container
for managed lifecycle.
When parameterized, there will be multiple if-else checks depending on the parameter in the base class and child test classes, mainly for ES client and sink builder. This is not a problem per se, and just needs a bit more refactoring.
I'll move the fields / static methods back to the base class for now, and take another look at parameterized tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@reta I'm working on the parameterized tests, which is purely a test code refactoring:
- Make base test class parameterized with
secure
parameter. As JUnit 5 has limited support for parameterized tests with inheritance, I used theParameterizedTestExtension
introduced in Flink, see this doc - Manage the test container lifecycle instead of using the managed annotation
@Testcontainers
and@Container
- Create and use common methods in the base class that concrete test classes can be mostly parameter-agnostic
If you prefer we wait for that change, I can push to this branch after I have a working version. If you agree, I can also create a new PR of the testing code refactoring for future proof (new tests will be easily covered by secure clusters).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer we wait for that change, I can push to this branch after I have a working version. If you agree, I can also create a new PR of the testing code refactoring for future proof (new tests will be easily covered by secure clusters).
I would agree with you that parameterized tests would very likely make things cleaner (we do have some level of duplication now). If you could pull it off, would be great, I sadly cannot merge, only review, so we still have time till committer comes in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, @reta ! Thanks for the review and helpful comments.
Let's see if @snuyanzin has bandwidth to take a look while I'm trying to refactor the tests separately.
* | ||
* @return this builder | ||
*/ | ||
public Elasticsearch8AsyncSinkBuilder<InputT> allowInsecure() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks like a straightforward backport of ES6/7 impl, thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I refactored this ES 8 a bit in #100 to assist this.
https://issues.apache.org/jira/browse/FLINK-35424
Main changes in this PR:
testcontainers
for secure Elasticsearch 8