Skip to content

Conversation

@cnauroth
Copy link
Contributor

@cnauroth cnauroth commented Jan 9, 2025

What changes were proposed in this pull request?

ExecutorKubernetesCredentialsFeatureStepSuite tests that Spark sets the correct service account on executor pods for various configuration combinations. This patch corrects some invalid test assertions and refactors to reduce redundancy across the different test cases.

Why are the changes needed?

ExecutorKubernetesCredentialsFeatureStepSuite attempts to check that the Spark code sets the correct service account on the executor pod. However, the current assertions are actually no-ops that check if a variable is equal to itself, which is always true. The test would pass even if the product code had a bug.

Does this PR introduce any user-facing change?

No, this is a change in tests only.

How was this patch tested?

  1. Intentionally introduce a bug in ExecutorKubernetesCredentialsFeatureStep by hard-coding a bogus service account (not included in this pull request).
  2. build/mvn -o -Pkubernetes -Pscala-2.12 -pl resource-managers/kubernetes/core -Dsuites='org.apache.spark.deploy.k8s.features.ExecutorKubernetesCredentialsFeatureStepSuite' test
  3. The test succeeds, even though there is a bug.
  4. Apply this patch.
  5. Rerun the test, and it fails, as it should.
  6. Revert the bug, rerun the test, and it succeeds.

Was this patch authored or co-authored using generative AI tooling?

No.

…Kubernetes service account

### What changes were proposed in this pull request?

`ExecutorKubernetesCredentialsFeatureStepSuite` tests that Spark sets the correct service account on executor pods for various configuration combinations. This patch corrects some invalid test assertions and refactors to reduce redundancy across the different test cases.

### Why are the changes needed?

`ExecutorKubernetesCredentialsFeatureStepSuite` attempts to check that the Spark code sets the correct service account on the executor pod. However, the current assertions are actually no-ops that check if a variable is equal to itself, which is always true. The test would pass even if the product code had a bug.

### Does this PR introduce _any_ user-facing change?

No, this is a change in tests only.

### How was this patch tested?

1. Intentionally introduce a bug in `ExecutorKubernetesCredentialsFeatureStep` by hard-coding a bogus service account (not included in this pull request).
1. `build/mvn -o -Pkubernetes -Pscala-2.12 -pl resource-managers/kubernetes/core -Dsuites='org.apache.spark.deploy.k8s.features.ExecutorKubernetesCredentialsFeatureStepSuite' test`
1. The test succeeds, even though there is a bug.
1. Apply this patch.
1. Rerun the test, and it fails, as it should.
1. Revert the bug, rerun the test, and it succeeds.

### Was this patch authored or co-authored using generative AI tooling?

No.
@dongjoon-hyun
Copy link
Member

Thank you for making a PR, @cnauroth !

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-50776][KUBERNETES][TESTS] Invalid test assertions on executor Kubernetes service account [SPARK-50776][K8S][TESTS] Invalid test assertions on executor Kubernetes service account Jan 10, 2025
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-50776][K8S][TESTS] Invalid test assertions on executor Kubernetes service account [SPARK-50776][K8S][TESTS] Fix test assertions on executor service account Jan 10, 2025
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.

+1, LGTM.

@dongjoon-hyun
Copy link
Member

Oh, the CI seems to succeed even though the Scala linter fails.

Screenshot 2025-01-10 at 07 14 31

@dongjoon-hyun
Copy link
Member

Let me check and do the follow-up.

@dongjoon-hyun
Copy link
Member

dongjoon-hyun commented Jan 10, 2025

It turns out that the Apache Spark's lint-scala script has a long standing bug (Since 3.4.0). So, I made a PR to fix it.

@cnauroth
Copy link
Contributor Author

Thank you, @dongjoon-hyun !

dongjoon-hyun added a commit that referenced this pull request Jan 10, 2025
### What changes were proposed in this pull request?

This PR aims to fix `lint-scala` script not to ignore `scalastyle` errors.

### Why are the changes needed?

This bug was introduced via the following PR at Apache Spark 3.4.0.
- #38258

After the above PR, `lint-scala` ignores `scalastyle` error and only considers the exit code of `scalafmt` like the following CI result.
- #49428 (comment)

![Screenshot 2025-01-10 at 07 14 31](https://github.com/user-attachments/assets/bdaa3be3-5daf-401b-a46f-7c02b7610158)

### Does this PR introduce _any_ user-facing change?

No, this is a dev-only tool change.

### How was this patch tested?

Manual review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #49443 from dongjoon-hyun/SPARK-50784.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
dongjoon-hyun added a commit that referenced this pull request Jan 10, 2025
### What changes were proposed in this pull request?

This PR aims to fix `lint-scala` script not to ignore `scalastyle` errors.

### Why are the changes needed?

This bug was introduced via the following PR at Apache Spark 3.4.0.
- #38258

After the above PR, `lint-scala` ignores `scalastyle` error and only considers the exit code of `scalafmt` like the following CI result.
- #49428 (comment)

![Screenshot 2025-01-10 at 07 14 31](https://github.com/user-attachments/assets/bdaa3be3-5daf-401b-a46f-7c02b7610158)

### Does this PR introduce _any_ user-facing change?

No, this is a dev-only tool change.

### How was this patch tested?

Manual review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #49443 from dongjoon-hyun/SPARK-50784.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
(cherry picked from commit 9d4b7a5)
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants