Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ulysses-you committed Mar 1, 2021
1 parent 4f10d34 commit 64d0f16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package org.apache.kyuubi.engine.spark.session

import org.scalatest.concurrent.PatienceConfiguration.Timeout
import org.scalatest.time.SpanSugar._

import org.apache.kyuubi.Utils
import org.apache.kyuubi.config.KyuubiConf._
import org.apache.kyuubi.engine.spark.{SparkSQLEngine, WithSparkSQLEngine}
Expand Down Expand Up @@ -59,9 +62,10 @@ class SessionSuite extends WithSparkSQLEngine with JDBCTestUtils {
override protected def jdbcUrl: String = s"jdbc:hive2://${engine.connectionUrl}/;"

test("release session if shared level is CONNECTION") {
assert(engine.isAlive())
assert(engine.started.get)
withJdbcStatement() {_ => }
Thread.sleep(5000)
assert(!engine.isAlive())
eventually(Timeout(10.seconds)) {
assert(!engine.started.get)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ import org.apache.kyuubi.config.KyuubiConf
abstract class Serverable(name: String) extends CompositeService(name) {

private val OOMHook = new Runnable { override def run(): Unit = stop() }
private val started = new AtomicBoolean(false)
private val stopped = new AtomicBoolean(false)
private[kyuubi] val started = new AtomicBoolean(false)

private[kyuubi] val backendService: AbstractBackendService
private lazy val frontendService = new FrontendService(backendService, OOMHook)
Expand Down Expand Up @@ -61,11 +60,6 @@ abstract class Serverable(name: String) extends CompositeService(name) {
case t: Throwable =>
warn(s"Error stopping spark ${t.getMessage}", t)
}
stopped.set(true)
}
}

def isAlive(): Boolean = {
started.get() && !stopped.get()
}
}

0 comments on commit 64d0f16

Please # to comment.