Repository: spark Updated Branches: refs/heads/branch-2.0 933d76a22 -> cd41e6a33
[SPARK-16656][SQL] Try to make CreateTableAsSelectSuite more stable ## What changes were proposed in this pull request? https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/62593/testReport/junit/org.apache.spark.sql.sources/CreateTableAsSelectSuite/create_a_table__drop_it_and_create_another_one_with_the_same_name/ shows that `create a table, drop it and create another one with the same name` failed. But other runs were good. Seems it is a flaky test. This PR tries to make this test more stable. Author: Yin Huai <yh...@databricks.com> Closes #14289 from yhuai/SPARK-16656. (cherry picked from commit 9abd99b3c318d0ec8b91124d40f3ab9e9d835dcf) Signed-off-by: Yin Huai <yh...@databricks.com> Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/cd41e6a3 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/cd41e6a3 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/cd41e6a3 Branch: refs/heads/branch-2.0 Commit: cd41e6a33ed5ebbb256400ae504f3e0676f57387 Parents: 933d76a Author: Yin Huai <yh...@databricks.com> Authored: Thu Jul 21 12:10:26 2016 -0700 Committer: Yin Huai <yh...@databricks.com> Committed: Thu Jul 21 12:10:43 2016 -0700 ---------------------------------------------------------------------- .../sql/sources/CreateTableAsSelectSuite.scala | 25 ++++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/cd41e6a3/sql/core/src/test/scala/org/apache/spark/sql/sources/CreateTableAsSelectSuite.scala ---------------------------------------------------------------------- diff --git a/sql/core/src/test/scala/org/apache/spark/sql/sources/CreateTableAsSelectSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/sources/CreateTableAsSelectSuite.scala index f9a07db..251a256 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/sources/CreateTableAsSelectSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/sources/CreateTableAsSelectSuite.scala @@ -19,7 +19,7 @@ package org.apache.spark.sql.sources import java.io.File -import org.scalatest.BeforeAndAfter +import org.scalatest.BeforeAndAfterEach import org.apache.spark.SparkException import org.apache.spark.sql.catalyst.TableIdentifier @@ -29,14 +29,16 @@ import org.apache.spark.sql.execution.datasources.BucketSpec import org.apache.spark.sql.test.SharedSQLContext import org.apache.spark.util.Utils -class CreateTableAsSelectSuite extends DataSourceTest with SharedSQLContext with BeforeAndAfter { +class CreateTableAsSelectSuite + extends DataSourceTest + with SharedSQLContext + with BeforeAndAfterEach { protected override lazy val sql = spark.sql _ private var path: File = null override def beforeAll(): Unit = { super.beforeAll() - path = Utils.createTempDir() val rdd = sparkContext.parallelize((1 to 10).map(i => s"""{"a":$i, "b":"str${i}"}""")) spark.read.json(rdd).createOrReplaceTempView("jt") } @@ -44,18 +46,21 @@ class CreateTableAsSelectSuite extends DataSourceTest with SharedSQLContext with override def afterAll(): Unit = { try { spark.catalog.dropTempView("jt") - if (path.exists()) { - Utils.deleteRecursively(path) - } + Utils.deleteRecursively(path) } finally { super.afterAll() } } - before { - if (path.exists()) { - Utils.deleteRecursively(path) - } + override def beforeEach(): Unit = { + super.beforeEach() + path = Utils.createTempDir() + path.delete() + } + + override def afterEach(): Unit = { + Utils.deleteRecursively(path) + super.afterEach() } test("CREATE TABLE USING AS SELECT") { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org