aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject aurora git commit: Callback should only be called on drained hosts.
Date Mon, 09 Nov 2015 23:38:17 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 24f377673 -> 06d8666f0


Callback should only be called on drained hosts.

Bugs closed: AURORA-1537

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


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

Branch: refs/heads/master
Commit: 06d8666f0e2c5f7e10a1bdcfa4beaab05c10ab34
Parents: 24f3776
Author: David Robinson <drobinson@twopensource.com>
Authored: Mon Nov 9 15:37:53 2015 -0800
Committer: Maxim Khutornenko <maxim@apache.org>
Committed: Mon Nov 9 15:37:53 2015 -0800

----------------------------------------------------------------------
 src/main/python/apache/aurora/admin/host_maintenance.py |  6 +++---
 .../python/apache/aurora/admin/test_host_maintenance.py | 12 ++++++++----
 2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/06d8666f/src/main/python/apache/aurora/admin/host_maintenance.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/admin/host_maintenance.py b/src/main/python/apache/aurora/admin/host_maintenance.py
index cfb13de..677f870 100644
--- a/src/main/python/apache/aurora/admin/host_maintenance.py
+++ b/src/main/python/apache/aurora/admin/host_maintenance.py
@@ -161,11 +161,11 @@ class HostMaintenance(object):
     """Perform a given operation on a list of hosts that are ready for maintenance.
 
     :param drained_hosts: Hosts that have been drained (via _drain_hosts)
-    :type drained_hosts: gen.apache.aurora.ttypes.Hosts
+    :type drained_hosts: list of strings
     :param callback: Function to call one hostname at a time
     :type callback: function
     """
-    for hostname in drained_hosts.hostNames:
+    for hostname in drained_hosts:
       callback(hostname)
 
   def perform_maintenance(self, hostnames, grouping_function=DEFAULT_GROUPING,
@@ -215,7 +215,7 @@ class HostMaintenance(object):
       not_drained_hostnames |= self._drain_hosts(hosts)
 
       if callback:
-        self._operate_on_hosts(hosts, callback)
+        self._operate_on_hosts(hosts.hostNames - not_drained_hostnames, callback)
 
     if not_drained_hostnames:
       output = '\n'.join(list(not_drained_hostnames))

http://git-wip-us.apache.org/repos/asf/aurora/blob/06d8666f/src/test/python/apache/aurora/admin/test_host_maintenance.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/admin/test_host_maintenance.py b/src/test/python/apache/aurora/admin/test_host_maintenance.py
index 6264d0c..868dd18 100644
--- a/src/test/python/apache/aurora/admin/test_host_maintenance.py
+++ b/src/test/python/apache/aurora/admin/test_host_maintenance.py
@@ -175,9 +175,8 @@ class TestHostMaintenance(unittest.TestCase):
 
   def test_operate_on_hosts(self):
     mock_callback = mock.Mock()
-    test_hosts = Hosts(TEST_HOSTNAMES)
     maintenance = HostMaintenance(DEFAULT_CLUSTER, 'quiet')
-    maintenance._operate_on_hosts(test_hosts, mock_callback)
+    maintenance._operate_on_hosts(TEST_HOSTNAMES, mock_callback)
     assert mock_callback.call_count == 3
 
   @mock.patch("apache.aurora.admin.host_maintenance.HostMaintenance._drain_hosts",
@@ -193,6 +192,11 @@ class TestHostMaintenance(unittest.TestCase):
     mock_callback = mock.Mock()
     mock_check_sla.return_value = set()
     mock_start_maintenance.return_value = TEST_HOSTNAMES
+    drain_hosts_results = [set() for _ in TEST_HOSTNAMES]
+    drain_hosts_results[0] = set([TEST_HOSTNAMES[0]])
+    def drain_hosts_result(*args):
+      return drain_hosts_results.pop(0)
+    mock_drain_hosts.side_effect = drain_hosts_result
     maintenance = HostMaintenance(DEFAULT_CLUSTER, 'quiet')
     maintenance.perform_maintenance(TEST_HOSTNAMES, callback=mock_callback)
     mock_start_maintenance.assert_called_once_with(TEST_HOSTNAMES)
@@ -201,8 +205,8 @@ class TestHostMaintenance(unittest.TestCase):
     assert mock_drain_hosts.call_args_list == [
         mock.call(Hosts(set([hostname]))) for hostname in TEST_HOSTNAMES]
     assert mock_operate_on_hosts.call_count == 3
-    assert mock_operate_on_hosts.call_args_list == [
-        mock.call(Hosts(set([hostname])), mock_callback) for hostname in TEST_HOSTNAMES]
+    assert mock_operate_on_hosts.call_args_list == [mock.call(set(), mock_callback)] + [
+        mock.call(set([hostname]), mock_callback) for hostname in TEST_HOSTNAMES[1:]]
 
   @mock.patch("apache.aurora.admin.host_maintenance.HostMaintenance._drain_hosts",
               spec=HostMaintenance._drain_hosts)


Mime
View raw message