Merge lp:~psusi/landscape-client/correct-free-mem into lp:~landscape/landscape-client/trunk

Proposed by Phillip Susi
Status: Superseded
Proposed branch: lp:~psusi/landscape-client/correct-free-mem
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 75 lines (+10/-10)
4 files modified
landscape/lib/sysstats.py (+2/-2)
landscape/lib/tests/test_sysstats.py (+4/-4)
landscape/monitor/tests/test_memoryinfo.py (+3/-3)
landscape/sysinfo/tests/test_memory.py (+1/-1)
To merge this branch: bzr merge lp:~psusi/landscape-client/correct-free-mem
Reviewer Review Type Date Requested Status
Landscape Pending
Review via email: mp+138540@code.launchpad.net

This proposal has been superseded by a proposal from 2012-12-18.

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :
Download full text (4.9 KiB)

There are a bunch of test failures, can you take a look at those?

[FAIL]
Traceback (most recent call last):
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/tests/mocker.py", line 146, in test_method_wrapper
    result = test_method()
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/lib/tests/test_sysstats.py", line 42, in test_get_memory_info
    self.assertEqual(memstats.free_memory, 503)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 271, in assertEqual
    % (msg, pformat(first), pformat(second)))
twisted.trial.unittest.FailTest: not equal:
a = 852
b = 503

landscape.lib.tests.test_sysstats.MemoryStatsTest.test_get_memory_info
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/tests/mocker.py", line 146, in test_method_wrapper
    result = test_method()
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/monitor/tests/test_memoryinfo.py", line 154, in test_exchange_messages
    (step_size * 2, 503, 1567)]}])
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/tests/helpers.py", line 82, in assertMessages
    self.assertMessage(obtained_message, expected_message)
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/tests/helpers.py", line 76, in assertMessage
    pprint.pformat(obtained)))
twisted.trial.unittest.FailTest: Messages don't match.
Expected:
{'memory-info': [(300, 503, 1567), (600, 503, 1567)], 'type': 'memory-info'}
Obtained:
{'memory-info': [(300, 852, 1567), (600, 852, 1567)], 'type': 'memory-info'}

landscape.monitor.tests.test_memoryinfo.MemoryInfoTest.test_exchange_messages
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/tests/mocker.py", line 146, in test_method_wrapper
    result = test_method()
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/monitor/tests/test_memoryinfo.py", line 78, in test_read_sample_data
    self.assertEqual(message["memory-info"][0], (step_size, 503, 1567))
  File "/usr/lib/python2.7/dist-packages/twisted/trial/unittest.py", line 271, in assertEqual
    % (msg, pformat(first), pformat(second)))
twisted.trial.unittest.FailTest: not equal:
a = (300, 852, 1567)
b = (300, 503, 1567)

landscape.monitor.tests.test_memoryinfo.MemoryInfoTest.test_read_sample_data
===============================================================================
[FAIL]
Traceback (most recent call last):
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/tests/mocker.py", line 146, in test_method_wrapper
    result = test_method()
  File "/home/andreas/canonical/source/landscape-client/psusi/correct-free-mem/landscape/sysinfo/tests/test_memory.py", line 53, in test_run_adds_header
    ("Swap usage", "39%")])
  File...

Read more...

594. By Phillip Susi

landscape-sysinfo was reporting memory usage values that
were entirely incorrect. This was because it was calculating free
memory to be all memory not on the active list. Changed to use
free + cached + buffers, just like the free command does.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/lib/sysstats.py'
2--- landscape/lib/sysstats.py 2010-04-28 13:07:53 +0000
3+++ landscape/lib/sysstats.py 2012-12-18 20:53:23 +0000
4@@ -13,11 +13,11 @@
5 for line in open(filename):
6 if ":" in line:
7 key, value = line.split(":", 1)
8- if key in ["Active", "MemTotal", "SwapFree", "SwapTotal"]:
9+ if key in ["MemTotal", "SwapFree", "SwapTotal", "MemFree", "Buffers", "Cached"]:
10 data[key] = int(value.split()[0])
11
12 self.total_memory = data["MemTotal"] // 1024
13- self.free_memory = (data["MemTotal"] - data["Active"]) // 1024
14+ self.free_memory = (data["MemFree"] + data["Buffers"] + data["Cached"]) // 1024
15 self.total_swap = data["SwapTotal"] // 1024
16 self.free_swap = data["SwapFree"] // 1024
17
18
19=== modified file 'landscape/lib/tests/test_sysstats.py'
20--- landscape/lib/tests/test_sysstats.py 2011-07-05 05:09:11 +0000
21+++ landscape/lib/tests/test_sysstats.py 2012-12-18 20:53:23 +0000
22@@ -39,14 +39,14 @@
23 filename = self.makeFile(SAMPLE_MEMORY_INFO)
24 memstats = MemoryStats(filename)
25 self.assertEqual(memstats.total_memory, 1510)
26- self.assertEqual(memstats.free_memory, 503)
27- self.assertEqual(memstats.used_memory, 1007)
28+ self.assertEqual(memstats.free_memory, 852)
29+ self.assertEqual(memstats.used_memory, 658)
30 self.assertEqual(memstats.total_swap, 1584)
31 self.assertEqual(memstats.free_swap, 1567)
32 self.assertEqual(memstats.used_swap, 17)
33- self.assertEqual("%.2f" % memstats.free_memory_percentage, "33.31")
34+ self.assertEqual("%.2f" % memstats.free_memory_percentage, "56.42")
35 self.assertEqual("%.2f" % memstats.free_swap_percentage, "98.93")
36- self.assertEqual("%.2f" % memstats.used_memory_percentage, "66.69")
37+ self.assertEqual("%.2f" % memstats.used_memory_percentage, "43.58")
38 self.assertEqual("%.2f" % memstats.used_swap_percentage, "1.07")
39
40 def test_get_memory_info_without_swap(self):
41
42=== modified file 'landscape/monitor/tests/test_memoryinfo.py'
43--- landscape/monitor/tests/test_memoryinfo.py 2011-07-05 05:09:11 +0000
44+++ landscape/monitor/tests/test_memoryinfo.py 2012-12-18 20:53:23 +0000
45@@ -75,7 +75,7 @@
46 self.reactor.advance(step_size)
47
48 message = plugin.create_message()
49- self.assertEqual(message["memory-info"][0], (step_size, 503, 1567))
50+ self.assertEqual(message["memory-info"][0], (step_size, 852, 1567))
51
52 def test_messaging_flushes(self):
53 """
54@@ -150,8 +150,8 @@
55
56 self.assertMessages(self.mstore.get_pending_messages(),
57 [{"type": "memory-info",
58- "memory-info": [(step_size, 503, 1567),
59- (step_size * 2, 503, 1567)]}])
60+ "memory-info": [(step_size, 852, 1567),
61+ (step_size * 2, 852, 1567)]}])
62
63 def test_call_on_accepted(self):
64 plugin = MemoryInfo(source_filename=self.makeFile(self.SAMPLE_DATA),
65
66=== modified file 'landscape/sysinfo/tests/test_memory.py'
67--- landscape/sysinfo/tests/test_memory.py 2011-07-05 05:09:11 +0000
68+++ landscape/sysinfo/tests/test_memory.py 2012-12-18 20:53:23 +0000
69@@ -49,5 +49,5 @@
70 def test_run_adds_header(self):
71 self.memory.run()
72 self.assertEqual(self.sysinfo.get_headers(),
73- [("Memory usage", "34%"),
74+ [("Memory usage", "27%"),
75 ("Swap usage", "39%")])

Subscribers

People subscribed via source and target branches

to all changes: