Skip to content

Conversation

@dongjoon-hyun
Copy link
Member

@dongjoon-hyun dongjoon-hyun commented Dec 10, 2023

What changes were proposed in this pull request?

This PR aims to improve the unit test coverage for RegisterWorker message handling.

  • Add handleRegisterWorker helper method which is testable easily.
  • Add new unit tests for three conditional branches.

Why are the changes needed?

It's easily to test and improve. We can add more tests in this way in the future.

Does this PR introduce any user-facing change?

No. This is a refactoring on the main code and only additions to the test methods.

How was this patch tested?

Pass the CIs.

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

No.

@github-actions github-actions bot added the CORE label Dec 10, 2023
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-46353][CORE] Refactor to improve RegisterWorker unit test [SPARK-46353][CORE] Refactor to improve RegisterWorker unit test coverage Dec 10, 2023
Copy link
Member Author

Choose a reason for hiding this comment

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

The following is a copy&paste of the existing code.

@dongjoon-hyun
Copy link
Member Author

cc @viirya

@dongjoon-hyun
Copy link
Member Author

Thank you so much, @viirya !

@dongjoon-hyun dongjoon-hyun marked this pull request as draft December 11, 2023 05:10
@dongjoon-hyun dongjoon-hyun marked this pull request as ready for review December 12, 2023 07:29
@dongjoon-hyun
Copy link
Member Author

dongjoon-hyun commented Dec 12, 2023

Hi, @viirya . Could you review once more? The following is the change from the original refactoring PR which you approved.

- handleRegisterWorker(registerWorker)
+ handleRegisterWorker(id, workerHost, workerPort, workerRef, cores, memory, workerWebUiUrl,
+        masterAddress, resources)

logInfo(f"Recovery complete in ${timeTakenNs / 1000000000d}%.3fs - resuming operations!")
}

private[master] def handleRegisterWorker(
Copy link
Member

Choose a reason for hiding this comment

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

You mean this method's parameters change?

Copy link
Member

Choose a reason for hiding this comment

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

But its code is still the same right? (copied from existing code)

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Dec 12, 2023

Choose a reason for hiding this comment

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

Yes, the code is the same. I change the parameter of handleRegisterWorker method from a single RegisterWorker class to field parameters to avoid side-effects.

@dongjoon-hyun
Copy link
Member Author

Thank you so much, @viirya . I'll dig more this area with more test cases.

@dongjoon-hyun dongjoon-hyun deleted the SPARK-46353 branch December 12, 2023 17:58
szehon-ho pushed a commit to szehon-ho/spark that referenced this pull request Feb 7, 2024
…verage

This PR aims to improve the unit test coverage for `RegisterWorker` message handling.

- Add `handleRegisterWorker` helper method which is testable easily.
- Add new unit tests for three conditional branches.

It's easily to test and improve. We can add more tests in this way in the future.

No. This is a refactoring on the main code and only additions to the test methods.

Pass the CIs.

No.

Closes apache#44284 from dongjoon-hyun/SPARK-46353.

Authored-by: Dongjoon Hyun <dhyun@apple.com>
Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants