-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26371][SS] Increase kafka ConfigUpdater test coverage. #23321
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
Conversation
|
Test build #100147 has finished for PR 23321 at commit
|
srowen
left a comment
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 know the details of the tests here but code looks good and more test coverage is good.
|
retest this, please |
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.
@gaborgsomogyi . Let's not use [TESTS] when you touch src/main. Also, this PR is a kind of refactoring PR which moves ConfigUpdater to KafkaConfigUpdater, isn't it.
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdater.scala
Show resolved
Hide resolved
|
@dongjoon-hyun removed. Good to know with |
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
|
Thank you for updating, @gaborgsomogyi . Yep, sometimes, it's used in the mixed situations. But, in general, |
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
| assert(e.getMessage.contains("Delegation token works only with SCRAM mechanism.")) | ||
| } | ||
|
|
||
| test("setAuthenticationConfigIfNeeded without security should not set values") { |
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.
Just a question. So, setAuthenticationConfigIfNeeded is currently no-op in this case intentionally. Is it better to raise an IllegalArgumentException with some directional error message about requirements?
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.
It seems better to me too to let setAuthenticationConfigIfNeeded only works properly with security config. (need to remove IfNeeded then) It would fail fast and gives us the chance to provide proper guide, maybe missing configuration for authentication.
But no strong opinion since this looks like providing convenience vs being strict to help end users to find possible missing point, and both look reasonable.
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.
This was the original implementation which was asked to change like this on other PRs (and I agree with it).
The reasoning behind was to keep fluent API and not having something like this(which is hardly testable):
val updater = KafkaConfigUpdater("executor", specifiedKafkaParams)
.set(...)
.set(...)
if (!globalSecurity && tokenAvailable)
updater.setAuthenticationConfig(...)
else if (somethingNew)
updater.set(...)
updater.build()
There is no flag like kafka.securityEnabled and Kafka can't tell it either.
Is it better to raise an IllegalArgumentException with some directional error message about requirements?
Security parameters shouldn't always set, for example:
- If unsecure
- If user provided JVM global JAAS configuration (this provide total freedom to users)
It would fail fast and gives us the chance to provide proper guide
- No security => nothing to check and do
- With global JAAS => it's not possible to parse JAAS config and suggest changes
- With DT => The user warned in advance to provide
SCRAMrelatedsasl.mechanismbecause the related Kafka error message is cryptic a bit.
I personally don't see more possibilities to provide convenience for users.
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 meant the case end users intend to set security so call setAuthenticationConfig* in KafkaConfigUpdater but they missed setting up security config. I guess error message will be provided in Kafka side but it might be cryptic so seeking the possibility to provide better message.
No strong opinion and either is fine because end users can be indicated in any way. Just for clarifying my opinion.
|
Test build #100154 has finished for PR 23321 at commit
|
|
Test build #100160 has finished for PR 23321 at commit
|
HeartSaVioR
left a comment
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 good overall. Left some comments but actually these are covered by @dongjoon-hyun review, and looks like nits.
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
| assert(e.getMessage.contains("Delegation token works only with SCRAM mechanism.")) | ||
| } | ||
|
|
||
| test("setAuthenticationConfigIfNeeded without security should not set values") { |
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.
It seems better to me too to let setAuthenticationConfigIfNeeded only works properly with security config. (need to remove IfNeeded then) It would fail fast and gives us the chance to provide proper guide, maybe missing configuration for authentication.
But no strong opinion since this looks like providing convenience vs being strict to help end users to find possible missing point, and both look reasonable.
srowen
left a comment
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.
This seems OK to me as-is.
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdater.scala
Show resolved
Hide resolved
|
Test build #100186 has finished for PR 23321 at commit
|
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdater.scala
Show resolved
Hide resolved
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
...al/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdaterSuite.scala
Outdated
Show resolved
Hide resolved
…ommon logic there
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaConfigUpdater.scala
Show resolved
Hide resolved
|
Test build #100234 has finished for PR 23321 at commit
|
dongjoon-hyun
left a comment
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.
Thank you, @gaborgsomogyi , @srowen , and @HeartSaVioR .
+1, LGTM. Merged to master.
|
Thanks everybody to make this better, especially @dongjoon-hyun by taking care of the merge. |
## What changes were proposed in this pull request? As Kafka delegation token added logic into ConfigUpdater it would be good to test it. This PR contains the following changes: * ConfigUpdater extracted to a separate file and renamed to KafkaConfigUpdater * mockito-core dependency added to kafka-0-10-sql * Unit tests added ## How was this patch tested? Existing + new unit tests + on cluster. Closes apache#23321 from gaborgsomogyi/SPARK-26371. Authored-by: Gabor Somogyi <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
## What changes were proposed in this pull request? As Kafka delegation token added logic into ConfigUpdater it would be good to test it. This PR contains the following changes: * ConfigUpdater extracted to a separate file and renamed to KafkaConfigUpdater * mockito-core dependency added to kafka-0-10-sql * Unit tests added ## How was this patch tested? Existing + new unit tests + on cluster. Closes apache#23321 from gaborgsomogyi/SPARK-26371. Authored-by: Gabor Somogyi <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
What changes were proposed in this pull request?
As Kafka delegation token added logic into ConfigUpdater it would be good to test it.
This PR contains the following changes:
How was this patch tested?
Existing + new unit tests + on cluster.