sysmon: Make a copy of dict before modifying it.
I was wondering why the age metric does not exist yet. Now I know.
And knowing is half the battle.
BUG=None
TEST=None
Change-Id: I9d75ad204c970bc5d314acf724d89f55fc1a2607
Reviewed-on: https://chromium-review.googlesource.com/707678
Commit-Ready: Allen Li <ayatane@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/scripts/sysmon/puppet_metrics_unittest.py b/scripts/sysmon/puppet_metrics_unittest.py
index 8556527..648f3c7 100644
--- a/scripts/sysmon/puppet_metrics_unittest.py
+++ b/scripts/sysmon/puppet_metrics_unittest.py
@@ -128,8 +128,9 @@
def test_collect(self):
with open(self.tempfile, 'w') as f:
f.write(_SUMMARY)
- with mock.patch.object(puppet_metrics, 'LAST_RUN_FILE', self.tempfile):
- puppet_metrics.collect_puppet_summary()
+ with mock.patch('time.time', return_value=1500000000):
+ with mock.patch.object(puppet_metrics, 'LAST_RUN_FILE', self.tempfile):
+ puppet_metrics.collect_puppet_summary()
setter = self.store.set
calls = [
@@ -187,6 +188,8 @@
0.001235189, enforce_ge=mock.ANY),
mock.call('puppet/times', ('filebucket',), None,
0.000341392, enforce_ge=mock.ANY),
+ mock.call('puppet/age', (), None,
+ 20329.0, enforce_ge=mock.ANY),
]
setter.assert_has_calls(calls)
self.assertEqual(len(setter.mock_calls), len(calls))