mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject git commit: NOJIRA added tmp dir management to MahoutSuite, fixed build problem related to leaving test generated files between builds
Date Wed, 13 Aug 2014 15:28:37 GMT
Repository: mahout
Updated Branches:
  refs/heads/master ee6359f62 -> b447f3fd0


NOJIRA added tmp dir management to MahoutSuite, fixed build problem related to leaving test
generated files between builds


Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/b447f3fd
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/b447f3fd
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/b447f3fd

Branch: refs/heads/master
Commit: b447f3fd07eafa36440dc4347e8514a15501e3c2
Parents: ee6359f
Author: pferrel <pat@occamsmachete.com>
Authored: Wed Aug 13 08:27:48 2014 -0700
Committer: pferrel <pat@occamsmachete.com>
Committed: Wed Aug 13 08:27:48 2014 -0700

----------------------------------------------------------------------
 .../mahout/math/drm/DrmLikeSuiteBase.scala      |  2 +-
 .../org/apache/mahout/test/MahoutSuite.scala    | 45 +++++++++++++++++++-
 .../drivers/ItemSimilarityDriverSuite.scala     | 33 +++++---------
 3 files changed, 54 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mahout/blob/b447f3fd/math-scala/src/test/scala/org/apache/mahout/math/drm/DrmLikeSuiteBase.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/drm/DrmLikeSuiteBase.scala b/math-scala/src/test/scala/org/apache/mahout/math/drm/DrmLikeSuiteBase.scala
index eaca53f..80fb285 100644
--- a/math-scala/src/test/scala/org/apache/mahout/math/drm/DrmLikeSuiteBase.scala
+++ b/math-scala/src/test/scala/org/apache/mahout/math/drm/DrmLikeSuiteBase.scala
@@ -30,7 +30,7 @@ trait DrmLikeSuiteBase extends DistributedMahoutSuite with Matchers {
 
   test("DRM DFS i/o (local)") {
 
-    val uploadPath = "UploadedDRM"
+    val uploadPath = TmpDir + "UploadedDRM"
 
     val inCoreA = dense((1, 2, 3), (3, 4, 5))
     val drmA = drmParallelize(inCoreA)

http://git-wip-us.apache.org/repos/asf/mahout/blob/b447f3fd/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala b/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
index 968a9ab..d3b8a38 100644
--- a/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
+++ b/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
@@ -1,13 +1,54 @@
+/*
+ * 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.mahout.test
 
-import org.scalatest.{Matchers, BeforeAndAfterEach, Suite}
+import java.io.File
+import org.scalatest._
 import org.apache.mahout.common.RandomUtils
 
 trait MahoutSuite extends BeforeAndAfterEach with LoggerConfiguration with Matchers {
-  this:Suite =>
+  this: Suite =>
+
+  final val TmpDir = "tmp/"
 
   override protected def beforeEach() {
     super.beforeEach()
     RandomUtils.useTestSeed()
   }
+
+  override protected def beforeAll(configMap: ConfigMap) {
+    super.beforeAll(configMap)
+
+    // just in case there is an existing tmp dir clean it before every suite
+    deleteDirectory(new File(TmpDir))
+  }
+
+  override protected def afterEach() {
+
+    // clean the tmp dir after every test
+    deleteDirectory(new File(TmpDir))
+
+    super.afterEach()
+  }
+
+  /** Delete directory no symlink checking and exceptions are not caught */
+  private def deleteDirectory(path: File): Unit = {
+    if (path.isDirectory)
+      for (files <- path.listFiles) deleteDirectory(files)
+    path.delete
+  }
 }

http://git-wip-us.apache.org/repos/asf/mahout/blob/b447f3fd/spark/src/test/scala/org/apache/mahout/drivers/ItemSimilarityDriverSuite.scala
----------------------------------------------------------------------
diff --git a/spark/src/test/scala/org/apache/mahout/drivers/ItemSimilarityDriverSuite.scala
b/spark/src/test/scala/org/apache/mahout/drivers/ItemSimilarityDriverSuite.scala
index cfabfdb..4bf1662 100644
--- a/spark/src/test/scala/org/apache/mahout/drivers/ItemSimilarityDriverSuite.scala
+++ b/spark/src/test/scala/org/apache/mahout/drivers/ItemSimilarityDriverSuite.scala
@@ -37,11 +37,11 @@ class ItemSimilarityDriverSuite extends FunSuite with DistributedSparkSuite
 {
 
 /*
   final val matrixLLRCoocAtAControl = dense(
-      (0.0,                1.7260924347106847, 0.0,                     0.0,            
   0.0),
-      (1.7260924347106847, 0.0,                0.0,                     0.0,            
   0.0),
-      (0.0,                0.0,                0.0,                     1.7260924347106847,
0.0),
-      (0.0,                0.0,                1.7260924347106847,      0.0,            
   0.0),
-      (0.0,                0.0,                0.0,                     0.0,            
   0.0))
+    (0.0,                0.6331745808516107, 0.0,                     0.0,              
 0.0),
+    (0.6331745808516107, 0.0,                0.0,                     0.0,              
 0.0),
+    (0.0,                0.0,                0.0,                     0.6331745808516107,
0.0),
+    (0.0,                0.0,                0.6331745808516107,      0.0,              
 0.0),
+    (0.0,                0.0,                0.0,                     0.0,              
 0.0))
 
   final val matrixLLRCoocBtAControl = dense(
       (1.7260924347106847, 1.7260924347106847, 1.7260924347106847, 1.7260924347106847, 0.0),
@@ -81,7 +81,8 @@ class ItemSimilarityDriverSuite extends FunSuite with DistributedSparkSuite
 {
       "galaxy\tnexus:1.7260924347106847 iphone:1.7260924347106847 ipad:1.7260924347106847
galaxy:1.7260924347106847",
       "surface\tsurface:4.498681156950466 nexus:0.6795961471815897"))
 
-  final val TmpDir = "tmp/" // all IO going to whatever the default HDFS config is pointing
to
+  // now in MahoutSuite
+  // final val TmpDir = "tmp/" // all IO going to whatever the default HDFS config is pointing
to
 
   /*
     //Clustered Spark and HDFS, not a good everyday build test
@@ -112,8 +113,7 @@ class ItemSimilarityDriverSuite extends FunSuite with DistributedSparkSuite
 {
     ))
   */
 
-  // TODO: failing, temporarily disabled
-  test("ItemSimilarityDriver, non-full-spec CSV") {
+  test ("ItemSimilarityDriver, non-full-spec CSV"){
 
     val InFile = TmpDir + "in-file.csv/" //using part files, not single file
     val OutPath = TmpDir + "indicator-matrices/"
@@ -720,20 +720,7 @@ removed ==> u3	0	      0	      1	          0
 
   override protected def beforeAll(configMap: ConfigMap) {
     super.beforeAll(configMap)
-
-    // just in case there is one left over
-    val fs = FileSystem.get(new Configuration())
-    fs.delete(new Path(TmpDir), true) // delete recursively
-
-    ItemSimilarityDriver.useContext(mahoutCtx) // for testing use the test context
+    ItemSimilarityDriver.useContext(mahoutCtx)
   }
-
-  override protected def afterEach() {
-
-    val fs = FileSystem.get(new Configuration())
-    fs.delete(new Path(TmpDir), true) // delete recursively
-
-    super.afterEach()
-  }
-
+  
 }


Mime
View raw message