Эх сурвалжийг харах

[core] Make hostname generic in tests and remove webhdfs threadness test

Romain Rigaux 12 жил өмнө
parent
commit
c3473835f1

+ 2 - 2
apps/beeswax/src/beeswax/tests.py

@@ -1618,8 +1618,8 @@ class TestDesign():
     ]
 
     statements = design.get_configuration_statements()
-    assert_true(re.match('\nADD FILE hdfs://localhost:(\d+)my_file\n', statements[0]), statements[0])
-    assert_true(re.match('\nADD FILE hdfs://localhost:(\d+)/my_path/my_file\n', statements[1]), statements[1])
+    assert_true(re.match('\nADD FILE hdfs://([^:]+):(\d+)my_file\n', statements[0]), statements[0])
+    assert_true(re.match('\nADD FILE hdfs://([^:]+):(\d+)/my_path/my_file\n', statements[1]), statements[1])
     assert_equal('\nADD FILE s3://host/my_s3_file\n', statements[2])
 
 

+ 9 - 8
desktop/libs/hadoop/src/hadoop/fs/fs_test.py

@@ -117,13 +117,15 @@ def test_hdfs_copy():
     assert_equal(0646, stat.S_IMODE(sb.mode))
 
   finally:
-    minifs.rmtree('/copy_test_src')
-    minifs.rmtree('/copy_test_dst')
+    minifs.do_as_superuser(minifs.rmtree, '/copy_test_src')
+    minifs.do_as_superuser(minifs.rmtree, '/copy_test_dst')
+
 
 @attr('requires_hadoop')
 def test_hdfs_full_copy():
   minicluster = pseudo_hdfs4.shared_cluster()
   minifs = minicluster.fs
+  minifs.setuser('test')
 
   try:
     minifs.do_as_superuser(minifs.chmod, '/', 0777)
@@ -146,22 +148,21 @@ def test_hdfs_full_copy():
     # Copy directory to file should fail.
     try:
       minifs.copy('/copy_test/src', '/copy_test/dest/file.txt', True)
-    except IOError, e:
+    except IOError:
       pass
-    except Exception, e:
+    except Exception:
       raise
 
   finally:
-    minifs.rmtree('/copy_test')
+    minifs.do_as_superuser(minifs.rmtree, '/copy_test')
 
 @attr('requires_hadoop')
 def test_hdfs_copy_from_local():
   minicluster = pseudo_hdfs4.shared_cluster()
   minifs = minicluster.fs
+  minifs.setuser('test')
 
-  olduser = minifs.setuser(minifs.superuser)
-  minifs.chmod('/', 0777)
-  minifs.setuser(olduser)
+  minifs.do_as_superuser(minifs.chmod, '/', 0777)
 
   path = os.path.join(tempfile.gettempdir(), 'copy_test_src')
   logging.info(path)

+ 0 - 16
desktop/libs/hadoop/src/hadoop/fs/test_webhdfs.py

@@ -258,22 +258,6 @@ class WebhdfsTests(unittest.TestCase):
       reload(sys)
       sys.setdefaultencoding('ascii')
 
-  def test_threadedness(self):
-    # Start a second thread to change the user, and
-    # make sure that isn't reflected.
-    fs = self.cluster.fs
-    fs.setuser("alpha")
-    class T(threading.Thread):
-      def run(self):
-        fs.setuser("beta")
-        assert_equals("beta", fs.user)
-    t = T()
-    t.start()
-    t.join()
-    assert_equals("alpha", fs.user)
-    fs.setuser("gamma")
-    assert_equals("gamma", fs.user)
-
   def test_chmod(self):
     # Create a test directory with
     # a subdirectory and a few files.