aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject git commit: Blocking on post drain script call.
Date Thu, 31 Jul 2014 20:26:39 GMT
Repository: incubator-aurora
Updated Branches:
  refs/heads/master caf72f85a -> 3e86677ee


Blocking on post drain script call.

Bugs closed: AURORA-609

Reviewed at https://reviews.apache.org/r/24019/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/3e86677e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/3e86677e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/3e86677e

Branch: refs/heads/master
Commit: 3e86677ee44c54c8fa3f49e315c2edaed2367379
Parents: caf72f8
Author: Maxim Khutornenko <maxim@apache.org>
Authored: Thu Jul 31 13:25:28 2014 -0700
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Thu Jul 31 13:25:28 2014 -0700

----------------------------------------------------------------------
 .../python/apache/aurora/admin/admin_util.py    |  5 ++-
 src/test/python/apache/aurora/admin/BUILD       | 11 ++++++
 .../apache/aurora/admin/test_admin_util.py      | 36 ++++++++++++++++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3e86677e/src/main/python/apache/aurora/admin/admin_util.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/admin/admin_util.py b/src/main/python/apache/aurora/admin/admin_util.py
index 04eecb7..31ec2b1 100644
--- a/src/main/python/apache/aurora/admin/admin_util.py
+++ b/src/main/python/apache/aurora/admin/admin_util.py
@@ -137,11 +137,14 @@ def parse_script(filename):
   :type filename: string
   :rtype: function
   """
+  def callback(host):
+    subprocess.Popen([cmd, host]).wait()
+
   if filename:
     if not os.path.exists(filename):
       die("No such file: %s" % filename)
     cmd = os.path.abspath(filename)
-    return lambda host: subprocess.Popen([cmd, host])
+    return callback
   else:
     return None
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3e86677e/src/test/python/apache/aurora/admin/BUILD
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/admin/BUILD b/src/test/python/apache/aurora/admin/BUILD
index 20f744b..f423e63 100644
--- a/src/test/python/apache/aurora/admin/BUILD
+++ b/src/test/python/apache/aurora/admin/BUILD
@@ -15,6 +15,7 @@
 python_test_suite(name = 'all',
   dependencies = [
     pants(':host_maintenance'),
+    pants(':admin_util'),
   ],
 )
 
@@ -30,3 +31,13 @@ python_tests(name = 'host_maintenance',
     pants('src/main/thrift/org/apache/aurora/gen:py-thrift'),
   ],
 )
+
+python_tests(name = 'admin_util',
+  sources = ['test_admin_util.py'],
+  dependencies = [
+    pants('3rdparty/python:mock'),
+    pants('3rdparty/python:twitter.common.contextutil'),
+    pants('src/main/python/apache/aurora/admin:util'),
+  ],
+)
+

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/3e86677e/src/test/python/apache/aurora/admin/test_admin_util.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/admin/test_admin_util.py b/src/test/python/apache/aurora/admin/test_admin_util.py
new file mode 100644
index 0000000..f5c8c69
--- /dev/null
+++ b/src/test/python/apache/aurora/admin/test_admin_util.py
@@ -0,0 +1,36 @@
+#
+# Licensed 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.
+#
+
+import subprocess
+import unittest
+
+import mock
+from twitter.common.contextutil import temporary_file
+
+from apache.aurora.admin.admin_util import parse_script
+
+
+class TestAdminUtil(unittest.TestCase):
+
+  @mock.patch("apache.aurora.admin.admin_util.subprocess", spec=subprocess)
+  def test_parse_script(self, mock_subprocess):
+    with temporary_file() as fp:
+      mock_popen = mock.Mock()
+      mock_popen.wait.return_value = 0
+      mock_subprocess.Popen.return_value = mock_popen
+      parse_script(fp.name)('h1')
+      assert mock_popen.wait.call_count == 1
+
+  def test_parse_script_invalid_filename(self):
+    self.assertRaises(SystemExit, parse_script, "invalid filename")


Mime
View raw message