skonto commented on a change in pull request #25765:
[SPARK-28937][SPARK-28936][KUBERNETES] Reduce test flakyness
URL: https://github.com/apache/spark/pull/25765#discussion_r326115168
##########
File path:
resource-managers/kubernetes/integration-tests/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/Utils.scala
##########
@@ -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)
Review comment:
Cool I was looking for something like that in the past :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]