-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-28937][SPARK-28936][KUBERNETES] Reduce test flakyness #25765
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
Closed
holdenk
wants to merge
8
commits into
apache:master
from
holdenk:SPARK-28937SPARK-28936-improve-kubernetes-integration-tests
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e9bf47f
Work on debugging the secrets test
holdenk 805fe3a
Test pass (yay)
holdenk 86f9e75
Add a listener in place of Thread.sleep for executing commands inside…
holdenk 3ccddbf
Remove printlns from my debugging
holdenk 916372c
Switch some constant uses of username/password to the object ref and …
holdenk 16ba894
cammel fix
holdenk 2ab68b5
Style fixes
holdenk de35d67
Add missing Locale import
holdenk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,9 +18,12 @@ package org.apache.spark.deploy.k8s.integrationtest | |
|
|
||
| import java.io.{Closeable, File, PrintWriter} | ||
| import java.nio.file.{Files, Path} | ||
| import java.util.concurrent.CountDownLatch | ||
|
|
||
| import scala.collection.JavaConverters._ | ||
|
|
||
| import io.fabric8.kubernetes.client.dsl.ExecListener | ||
| import okhttp3.Response | ||
| import org.apache.commons.io.output.ByteArrayOutputStream | ||
|
|
||
| import org.apache.spark.{SPARK_VERSION, SparkException} | ||
|
|
@@ -45,20 +48,49 @@ object Utils extends Logging { | |
| implicit podName: String, | ||
| kubernetesTestComponents: KubernetesTestComponents): String = { | ||
| val out = new ByteArrayOutputStream() | ||
| val watch = kubernetesTestComponents | ||
| val pod = kubernetesTestComponents | ||
| .kubernetesClient | ||
| .pods() | ||
| .withName(podName) | ||
| // Avoid timing issues by looking for open/close | ||
| class ReadyListener extends ExecListener { | ||
| val openLatch: CountDownLatch = new CountDownLatch(1) | ||
| val closeLatch: CountDownLatch = new CountDownLatch(1) | ||
|
|
||
| override def onOpen(response: Response) { | ||
| openLatch.countDown() | ||
| } | ||
|
|
||
| override def onClose(a: Int, b: String) { | ||
| closeLatch.countDown() | ||
| } | ||
|
|
||
| override def onFailure(e: Throwable, r: Response) { | ||
| } | ||
|
|
||
| def waitForInputStreamToConnect(): Unit = { | ||
| openLatch.await() | ||
| } | ||
|
|
||
| def waitForClose(): Unit = { | ||
| closeLatch.await() | ||
| } | ||
| } | ||
| val listener = new ReadyListener() | ||
| val watch = pod | ||
| .readingInput(System.in) | ||
| .writingOutput(out) | ||
| .writingError(System.err) | ||
| .withTTY() | ||
| .usingListener(listener) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool I was looking for something like that in the past :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rocking :) |
||
| .exec(cmd.toArray: _*) | ||
| // wait to get some result back | ||
| Thread.sleep(1000) | ||
| // under load sometimes the stdout isn't connected by the time we try to read from it. | ||
| listener.waitForInputStreamToConnect() | ||
| listener.waitForClose() | ||
| watch.close() | ||
| out.flush() | ||
| out.toString() | ||
| val result = out.toString() | ||
| result | ||
| } | ||
|
|
||
| def createTempFile(contents: String, hostPath: String): String = { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 part of the change related, necessary?
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.
No, although I figured cleaning up hard coded strings while I was there would be good.