Skip to content

Conversation

@gaborgsomogyi
Copy link
Contributor

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.

@gaborgsomogyi
Copy link
Contributor Author

cc @HeartSaVioR @vanzin

@SparkQA
Copy link

SparkQA commented Dec 14, 2018

Test build #100147 has finished for PR 23321 at commit 7026056.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@srowen srowen left a 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.

@gaborgsomogyi
Copy link
Contributor Author

retest this, please

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a 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.

@gaborgsomogyi gaborgsomogyi changed the title [SPARK-26371][SS][TESTS] Increase kafka ConfigUpdater test coverage. [SPARK-26371][SS] Increase kafka ConfigUpdater test coverage. Dec 14, 2018
@gaborgsomogyi
Copy link
Contributor Author

gaborgsomogyi commented Dec 14, 2018

@dongjoon-hyun removed. Good to know with [TESTS] not even rename is allowed. Next time I'll stick to that.

@dongjoon-hyun
Copy link
Member

Thank you for updating, @gaborgsomogyi . Yep, sometimes, it's used in the mixed situations. But, in general, [TESTS] means src/test-only PR.

assert(e.getMessage.contains("Delegation token works only with SCRAM mechanism."))
}

test("setAuthenticationConfigIfNeeded without security should not set values") {
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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 SCRAM related sasl.mechanism because the related Kafka error message is cryptic a bit.

I personally don't see more possibilities to provide convenience for users.

Copy link
Contributor

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.

@SparkQA
Copy link

SparkQA commented Dec 14, 2018

Test build #100154 has finished for PR 23321 at commit 7026056.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 14, 2018

Test build #100160 has finished for PR 23321 at commit 2a7a18e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a 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.

assert(e.getMessage.contains("Delegation token works only with SCRAM mechanism."))
}

test("setAuthenticationConfigIfNeeded without security should not set values") {
Copy link
Contributor

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.

Copy link
Member

@srowen srowen left a 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.

@SparkQA
Copy link

SparkQA commented Dec 15, 2018

Test build #100186 has finished for PR 23321 at commit 0347cb6.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Dec 17, 2018

Test build #100234 has finished for PR 23321 at commit dcacd75.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a 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.

@asfgit asfgit closed this in 5a116e6 Dec 17, 2018
@gaborgsomogyi
Copy link
Contributor Author

Thanks everybody to make this better, especially @dongjoon-hyun by taking care of the merge.

holdenk pushed a commit to holdenk/spark that referenced this pull request Jan 5, 2019
## 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]>
jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
## 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]>
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.

5 participants