You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/11/25 18:47:59 UTC

ambari git commit: AMBARI-6064. Server unittests should remove temporary files (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk 4d614988c -> 20591d2e2


AMBARI-6064. Server unittests should remove temporary files (aonishuk)


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

Branch: refs/heads/trunk
Commit: 20591d2e244763ca86e426ee60e829b2b80411de
Parents: 4d61498
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue Nov 25 19:47:54 2014 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Tue Nov 25 19:47:54 2014 +0200

----------------------------------------------------------------------
 ambari-server/src/test/python/unitTests.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/20591d2e/ambari-server/src/test/python/unitTests.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/unitTests.py b/ambari-server/src/test/python/unitTests.py
index 85591cf..a4fd2d2 100644
--- a/ambari-server/src/test/python/unitTests.py
+++ b/ambari-server/src/test/python/unitTests.py
@@ -22,6 +22,8 @@ import os
 import sys
 from random import shuffle
 import fnmatch
+import tempfile
+import shutil
 
 #excluded directories with non-test staff from stack and service scanning,
 #also we can add service or stack to skip here
@@ -31,6 +33,10 @@ SERVICE_EXCLUDE = ["configs"]
 TEST_MASK = '[Tt]est*.py'
 CUSTOM_TEST_MASK = '_[Tt]est*.py'
 
+oldtmpdirpath = tempfile.gettempdir()
+newtmpdirpath = os.path.join(oldtmpdirpath, "ambari-test")
+tempfile.tempdir = newtmpdirpath
+
 def get_parent_path(base, directory_name):
   """
   Returns absolute path for directory_name, if directory_name present in base.
@@ -114,6 +120,7 @@ def stack_test_executor(base_folder, service, stack, custom_tests, executor_resu
   executor_result.put(0) if textRunner.wasSuccessful() else executor_result.put(1)
 
 def main():
+  if not os.path.exists(newtmpdirpath): os.makedirs(newtmpdirpath)
   custom_tests = False
   if len(sys.argv) > 1:
     if sys.argv[1] == "true":
@@ -222,6 +229,10 @@ def main():
   sys.stderr.write("Total errors:{0}\n".format(len(test_errors)))
   sys.stderr.write("Total failures:{0}\n".format(len(test_failures)))
 
+  shutil.rmtree(newtmpdirpath)
+  tempfile.tempdir = oldtmpdirpath
+  tempfile.oldtmpdirpath = None
+
   if tests_status:
     sys.stderr.write("OK\n")
     exit_code = 0