You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2016/08/29 18:21:58 UTC

aurora git commit: Catch IOError.

Repository: aurora
Updated Branches:
  refs/heads/master 56906a796 -> 5c95395ad


Catch IOError.

Bugs closed: AURORA-1752

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


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

Branch: refs/heads/master
Commit: 5c95395ade47aa9932c2ebade49b7ac553428012
Parents: 56906a7
Author: David Robinson <dr...@twopensource.com>
Authored: Mon Aug 29 11:21:46 2016 -0700
Committer: Maxim Khutornenko <ma...@apache.org>
Committed: Mon Aug 29 11:21:46 2016 -0700

----------------------------------------------------------------------
 .../monitoring/process_collector_psutil.py      |  2 +-
 .../monitoring/test_process_collector_psutil.py | 30 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/5c95395a/src/main/python/apache/thermos/monitoring/process_collector_psutil.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/thermos/monitoring/process_collector_psutil.py b/src/main/python/apache/thermos/monitoring/process_collector_psutil.py
index bb7c902..4a1b159 100644
--- a/src/main/python/apache/thermos/monitoring/process_collector_psutil.py
+++ b/src/main/python/apache/thermos/monitoring/process_collector_psutil.py
@@ -71,7 +71,7 @@ class ProcessTreeCollector(object):
       )
       new_samples[self._pid] = parent_sample
 
-    except PsutilError as e:
+    except (IOError, PsutilError) as e:
       log.warning('Error during process sampling: %s' % e)
       self._sample = ProcessSample.empty()
       self._rate = 0.0

http://git-wip-us.apache.org/repos/asf/aurora/blob/5c95395a/src/test/python/apache/thermos/monitoring/test_process_collector_psutil.py
----------------------------------------------------------------------
diff --git a/src/test/python/apache/thermos/monitoring/test_process_collector_psutil.py b/src/test/python/apache/thermos/monitoring/test_process_collector_psutil.py
new file mode 100644
index 0000000..93ff878
--- /dev/null
+++ b/src/test/python/apache/thermos/monitoring/test_process_collector_psutil.py
@@ -0,0 +1,30 @@
+#
+# 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 mock
+import psutil
+
+from apache.thermos.monitoring.process import ProcessSample
+from apache.thermos.monitoring.process_collector_psutil import ProcessTreeCollector
+
+
+@mock.patch('psutil.process_iter', autospec=True, spec_set=True)
+def test_process_tree_collector(mock_process_iter):
+  collector = ProcessTreeCollector(None)
+  mock_process_iter.side_effect = psutil.Error
+  collector.sample()
+  assert collector.value == ProcessSample.empty()
+  mock_process_iter.side_effect = IOError
+  collector.sample()
+  assert collector.value == ProcessSample.empty()