-
Notifications
You must be signed in to change notification settings - Fork 28.8k
[SPARK-53622][CORE][TEST] Improve UninterruptibleThreadSuite
#52373
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
base: master
Are you sure you want to change the base?
Conversation
@cloud-fan @Ngone51 Please take a look |
UninterruptibleThreadSuite
} | ||
|
||
test("stress test") { | ||
for (i <- 0 until 20) { |
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.
Is this the major change tries to improve the test coverage? Since it's executed in sequence, the stress of interruptions to a single UninterruptibleThread
doesn't seem to be inscreased to me.
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 change does not target to increase concurrency of the stress test. It targets to reproduce SPARK-53394
} | ||
|
||
/* Await latch and return true if it's interrupted */ | ||
private def await(latch: CountDownLatch, timeout: Long = 10, |
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.
What's the major difference after using this await()
?
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.
We can equally use sleep()
and await()
to test for InterruptedException
as they both throw an exception in case thread is interrupted. The difference is that sleep()
does not return while await()
will exit once the main thread calls interrupt()
and count down the latch.
timeUnit: TimeUnit = TimeUnit.SECONDS): Boolean = { | ||
try { | ||
if (!latch.await(timeout, timeUnit)) { | ||
log.error("timeout while waiting for the latch") |
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's test, and this log seems not useful as we fail right after it with the same error message.
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.
When await
is used not in the main test thread, fail()
does not cause thread to fail, it terminates the thread with TestFailedException
(that is logged to stderr). And when this happens test fails as other conditions are not met. The log.error()
logs to unit-tests.log
, so there is no duplication of the error message. Note that in this case, the code is similar to:
log.error("message")
throw new Exception("message")
What changes were proposed in this pull request?
Implement several code improvement in
UninterruptibleThreadSuite
:InterruptedException
assert
error message ("false did not equal true" => "hasInterruptedException was false")await
instead ofsleep
Why are the changes needed?
improve test coverage of
UninterruptibleThread
and help with test failure troubleshootingDoes this PR introduce any user-facing change?
No
How was this patch tested?
Run modified test
Was this patch authored or co-authored using generative AI tooling?
No