You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@livy.apache.org by js...@apache.org on 2018/05/29 05:51:27 UTC

incubator-livy git commit: [LIVY-473][TEST] Minor refactor of integration test to remove legacy code

Repository: incubator-livy
Updated Branches:
  refs/heads/master ca4cad229 -> 8b3fcbc8d


[LIVY-473][TEST] Minor refactor of integration test to remove legacy code

Integration test has some legacy codes related to different cluster type (mini or real). Since now we already use real Spark package to do test and partially removed that code, we should refactor to remove all the unused legacy code.

Existing tests.

Author: jerryshao <ss...@hortonworks.com>

Closes #97 from jerryshao/LIVY-473.

Change-Id: I7ca6c69884f7ed11a34cde5a6e1fc9bfcd141cbb


Project: http://git-wip-us.apache.org/repos/asf/incubator-livy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-livy/commit/8b3fcbc8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-livy/tree/8b3fcbc8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-livy/diff/8b3fcbc8

Branch: refs/heads/master
Commit: 8b3fcbc8d52a6e6e1628cf139c0b0f49be797cec
Parents: ca4cad2
Author: jerryshao <ss...@hortonworks.com>
Authored: Tue May 29 13:51:20 2018 +0800
Committer: jerryshao <ss...@hortonworks.com>
Committed: Tue May 29 13:51:20 2018 +0800

----------------------------------------------------------------------
 .../apache/livy/test/framework/Cluster.scala    | 38 +----------
 .../livy/test/framework/MiniCluster.scala       | 22 +------
 .../livy/test/framework/MiniClusterUtils.scala  | 68 ++++++++++++++++++++
 3 files changed, 71 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/8b3fcbc8/integration-test/src/main/scala/org/apache/livy/test/framework/Cluster.scala
----------------------------------------------------------------------
diff --git a/integration-test/src/main/scala/org/apache/livy/test/framework/Cluster.scala b/integration-test/src/main/scala/org/apache/livy/test/framework/Cluster.scala
index 26b08a9..907a6bf 100644
--- a/integration-test/src/main/scala/org/apache/livy/test/framework/Cluster.scala
+++ b/integration-test/src/main/scala/org/apache/livy/test/framework/Cluster.scala
@@ -75,8 +75,6 @@ trait Cluster {
 }
 
 object Cluster extends Logging {
-  private val CLUSTER_TYPE = "cluster.type"
-
   private lazy val config = {
     sys.props.get("cluster.spec")
       .filter { path => path.nonEmpty && path != "default" }
@@ -92,16 +90,13 @@ object Cluster extends Logging {
         }
         p.asScala.toMap
       }
-      .getOrElse(Map(CLUSTER_TYPE -> "mini"))
+      .getOrElse(Map.empty)
   }
 
   private lazy val cluster = {
     var _cluster: Cluster = null
     try {
-      _cluster = config.get(CLUSTER_TYPE) match {
-        case Some("mini") => new MiniCluster(config)
-        case t => throw new Exception(s"Unknown or unset cluster.type $t")
-      }
+      _cluster = new MiniCluster(config)
       Runtime.getRuntime.addShutdownHook(new Thread {
         override def run(): Unit = {
           info("Shutting down cluster pool.")
@@ -126,32 +121,3 @@ object Cluster extends Logging {
 
   def isRunningOnTravis: Boolean = sys.env.contains("TRAVIS")
 }
-
-trait ClusterUtils {
-
-  protected def saveProperties(props: Map[String, String], dest: File): Unit = {
-    val jprops = new Properties()
-    props.foreach { case (k, v) => jprops.put(k, v) }
-
-    val tempFile = new File(dest.getAbsolutePath() + ".tmp")
-    val out = new OutputStreamWriter(new FileOutputStream(tempFile), UTF_8)
-    try {
-      jprops.store(out, "Configuration")
-    } finally {
-      out.close()
-    }
-    tempFile.renameTo(dest)
-  }
-
-  protected def loadProperties(file: File): Map[String, String] = {
-    val in = new InputStreamReader(new FileInputStream(file), UTF_8)
-    val props = new Properties()
-    try {
-      props.load(in)
-    } finally {
-      in.close()
-    }
-    props.asScala.toMap
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/8b3fcbc8/integration-test/src/main/scala/org/apache/livy/test/framework/MiniCluster.scala
----------------------------------------------------------------------
diff --git a/integration-test/src/main/scala/org/apache/livy/test/framework/MiniCluster.scala b/integration-test/src/main/scala/org/apache/livy/test/framework/MiniCluster.scala
index 3cfc772..c4d4eb5 100644
--- a/integration-test/src/main/scala/org/apache/livy/test/framework/MiniCluster.scala
+++ b/integration-test/src/main/scala/org/apache/livy/test/framework/MiniCluster.scala
@@ -18,8 +18,6 @@
 package org.apache.livy.test.framework
 
 import java.io._
-import java.nio.charset.Charset
-import java.nio.file.{Files, Paths}
 import javax.servlet.http.HttpServletResponse
 
 import scala.concurrent.duration._
@@ -52,24 +50,6 @@ private class MiniClusterConfig(val config: Map[String, String]) {
 
 }
 
-sealed trait MiniClusterUtils extends ClusterUtils {
-
-  protected def saveConfig(conf: Configuration, dest: File): Unit = {
-    val redacted = new Configuration(conf)
-    // This setting references a test class that is not available when using a real Spark
-    // installation, so remove it from client configs.
-    redacted.unset("net.topology.node.switch.mapping.impl")
-
-    val out = new FileOutputStream(dest)
-    try {
-      redacted.writeXml(out)
-    } finally {
-      out.close()
-    }
-  }
-
-}
-
 sealed abstract class MiniClusterBase extends MiniClusterUtils with Logging {
 
   def main(args: Array[String]): Unit = {
@@ -117,7 +97,7 @@ object MiniYarnMain extends MiniClusterBase {
 
   override protected def start(config: MiniClusterConfig, configPath: String): Unit = {
     val baseConfig = new YarnConfiguration()
-    var yarnCluster = new MiniYARNCluster(getClass().getName(), config.nmCount,
+    val yarnCluster = new MiniYARNCluster(getClass().getName(), config.nmCount,
       config.localDirCount, config.logDirCount)
     yarnCluster.init(baseConfig)
 

http://git-wip-us.apache.org/repos/asf/incubator-livy/blob/8b3fcbc8/integration-test/src/main/scala/org/apache/livy/test/framework/MiniClusterUtils.scala
----------------------------------------------------------------------
diff --git a/integration-test/src/main/scala/org/apache/livy/test/framework/MiniClusterUtils.scala b/integration-test/src/main/scala/org/apache/livy/test/framework/MiniClusterUtils.scala
new file mode 100644
index 0000000..b31d88e
--- /dev/null
+++ b/integration-test/src/main/scala/org/apache/livy/test/framework/MiniClusterUtils.scala
@@ -0,0 +1,68 @@
+/*
+ * 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.livy.test.framework
+
+import java.io._
+import java.nio.charset.StandardCharsets.UTF_8
+import java.util.Properties
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.conf.Configuration
+
+trait MiniClusterUtils {
+
+  protected def saveProperties(props: Map[String, String], dest: File): Unit = {
+    val jprops = new Properties()
+    props.foreach { case (k, v) => jprops.put(k, v) }
+
+    val tempFile = new File(dest.getAbsolutePath() + ".tmp")
+    val out = new OutputStreamWriter(new FileOutputStream(tempFile), UTF_8)
+    try {
+      jprops.store(out, "Configuration")
+    } finally {
+      out.close()
+    }
+    tempFile.renameTo(dest)
+  }
+
+  protected def loadProperties(file: File): Map[String, String] = {
+    val in = new InputStreamReader(new FileInputStream(file), UTF_8)
+    val props = new Properties()
+    try {
+      props.load(in)
+    } finally {
+      in.close()
+    }
+    props.asScala.toMap
+  }
+
+  protected def saveConfig(conf: Configuration, dest: File): Unit = {
+    val redacted = new Configuration(conf)
+    // This setting references a test class that is not available when using a real Spark
+    // installation, so remove it from client configs.
+    redacted.unset("net.topology.node.switch.mapping.impl")
+
+    val out = new FileOutputStream(dest)
+    try {
+      redacted.writeXml(out)
+    } finally {
+      out.close()
+    }
+  }
+}