-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-43648][CONNECT][TESTS] Move interrupt all related test to a new test file to pass Maven test
#41487
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
Closed
[SPARK-43648][CONNECT][TESTS] Move interrupt all related test to a new test file to pass Maven test
#41487
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4963bd5
move to new file
LuciferYang b9e7e4a
add waring message to SparkSessionE2ESuite
LuciferYang 4822924
re format
LuciferYang ca3e6b1
rename
LuciferYang 3b885b2
Simplify comments
LuciferYang 4648813
rename and comments
LuciferYang 57e23f1
Update connector/connect/client/jvm/src/test/scala/org/apache/spark/s…
LuciferYang c71eac4
Merge branch 'apache:master' into SPARK-43648-2
LuciferYang 5ec3f93
reformat
LuciferYang 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
99 changes: 99 additions & 0 deletions
99
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/SparkSessionE2ESuite.scala
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 |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.spark.sql | ||
|
|
||
| import scala.concurrent.{ExecutionContext, ExecutionContextExecutor, Future} | ||
| import scala.concurrent.duration._ | ||
| import scala.util.{Failure, Success} | ||
|
|
||
| import org.scalatest.concurrent.Eventually._ | ||
|
|
||
| import org.apache.spark.sql.connect.client.util.RemoteSparkSession | ||
| import org.apache.spark.util.ThreadUtils | ||
|
|
||
| /** | ||
| * NOTE: Do not import classes that only exist in `spark-connect-client-jvm.jar` into the this | ||
| * class, whether explicit or implicit, as it will trigger a UDF deserialization error during | ||
| * Maven build/test. | ||
| */ | ||
| class SparkSessionE2ESuite extends RemoteSparkSession { | ||
|
|
||
| test("interrupt all - background queries, foreground interrupt") { | ||
| val session = spark | ||
| import session.implicits._ | ||
| implicit val ec: ExecutionContextExecutor = ExecutionContext.global | ||
| val q1 = Future { | ||
| spark.range(10).map(n => { Thread.sleep(30000); n }).collect() | ||
| } | ||
| val q2 = Future { | ||
| spark.range(10).map(n => { Thread.sleep(30000); n }).collect() | ||
| } | ||
| var q1Interrupted = false | ||
| var q2Interrupted = false | ||
| var error: Option[String] = None | ||
| q1.onComplete { | ||
| case Success(_) => | ||
| error = Some("q1 shouldn't have finished!") | ||
| case Failure(t) if t.getMessage.contains("cancelled") => | ||
| q1Interrupted = true | ||
| case Failure(t) => | ||
| error = Some("unexpected failure in q1: " + t.toString) | ||
| } | ||
| q2.onComplete { | ||
| case Success(_) => | ||
| error = Some("q2 shouldn't have finished!") | ||
| case Failure(t) if t.getMessage.contains("cancelled") => | ||
| q2Interrupted = true | ||
| case Failure(t) => | ||
| error = Some("unexpected failure in q2: " + t.toString) | ||
| } | ||
| // 20 seconds is < 30 seconds the queries should be running, | ||
| // because it should be interrupted sooner | ||
| eventually(timeout(20.seconds), interval(1.seconds)) { | ||
| // keep interrupting every second, until both queries get interrupted. | ||
| spark.interruptAll() | ||
| assert(error.isEmpty, s"Error not empty: $error") | ||
| assert(q1Interrupted) | ||
| assert(q2Interrupted) | ||
| } | ||
| } | ||
|
|
||
| test("interrupt all - foreground queries, background interrupt") { | ||
| val session = spark | ||
| import session.implicits._ | ||
| implicit val ec: ExecutionContextExecutor = ExecutionContext.global | ||
|
|
||
| @volatile var finished = false | ||
| val interruptor = Future { | ||
| eventually(timeout(20.seconds), interval(1.seconds)) { | ||
| spark.interruptAll() | ||
| assert(finished) | ||
| } | ||
| finished | ||
| } | ||
| val e1 = intercept[io.grpc.StatusRuntimeException] { | ||
| spark.range(10).map(n => { Thread.sleep(30.seconds.toMillis); n }).collect() | ||
| } | ||
| assert(e1.getMessage.contains("cancelled"), s"Unexpected exception: $e1") | ||
| val e2 = intercept[io.grpc.StatusRuntimeException] { | ||
| spark.range(10).map(n => { Thread.sleep(30.seconds.toMillis); n }).collect() | ||
| } | ||
| assert(e2.getMessage.contains("cancelled"), s"Unexpected exception: $e2") | ||
| finished = true | ||
| assert(ThreadUtils.awaitResult(interruptor, 10.seconds)) | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Thank you for the investigation and suggestion, @LuciferYang .
If this is supposed to be a clean room unlike
ClientE2ETestSuite. Could you add some test class description officially here? For example, something likeDo not import 'org.apache.spark.sql.connect.client.SparkResult? Or,Do not import any class from spark-connect-client-jvm.jar?Without an explicit written warning, this test suite could be broken again when someone adds a new test case. It will be a head-ache of re-analysis.
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.
Thanks @dongjoon-hyun ~
b9e7e4a add waring comments to
SparkSessionE2ESuite.At the same time, I am preparing a pr use to add Maven test of connect related modules on GitHub Action(#41253), as Maven testing often failures before. If this pr can be merged, we can start testing the client module first.
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.
Non-blocking: I wonder if we can also add something to the class name to make it more indicative that it's a "clean room" suite? Maybe something like
SparkSessionCleanRoomE2ESuiteor some variation.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.
Oh, sorry but let's not use
CleanRoomkeyword here, @vicennial . :)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.
revert