www.cendio.com
Bug 6167 - "number of users" value in load status is off by two
: "number of users" value in load status is off by two
Status: CLOSED FIXED
: ThinLinc
VSM Agent
: trunk
: PC Unknown
: P2 Normal
: 4.8.0
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2017-02-09 17:59 by
Modified: 2017-03-20 17:09 (History)
Acceptance Criteria:


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From cendio 2017-02-09 17:59:01
Perhaps easiest described as two test cases:

>    @mock.patch("thinlinc.vsm.loadinfokeeper.subprocess_n_log")
>    def test_number_of_users_with_no_processes_in_ps_output(self, proc):
>        # Given
>        l = loadinfokeeper.LoadInfoKeeper(mock.MagicMock(name="parent"))
>        proc.side_effect = [(0, "  UID\n", "")]
>
>        # When
>        l.fetch_dynamic_loadinfo()
>
>        # Then
>        self.assertEqual(l.loadinfo['num_users'], 0)
>
>
>    @mock.patch("thinlinc.vsm.loadinfokeeper.subprocess_n_log")
>    def test_number_of_users_with_single_process_in_ps_output(self, proc):
>        # Given
>        l = loadinfokeeper.LoadInfoKeeper(mock.MagicMock(name="parent"))
>        proc.side_effect = [(0, "  UID\n1\n", "")]
>
>        # When
>        l.fetch_dynamic_loadinfo()
>
>        # Then
>        self.assertEqual(l.loadinfo['num_users'], 1)

Current results:

> ======================================================================
> FAIL: test_number_of_users_with_no_processes_in_ps_output (__main__.LoadInfoKeeperTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
>     return func(*args, **keywargs)
>   File "test_loadinfokeeper.py", line 66, in test_number_of_users_with_no_processes_in_ps_output
>     self.assertEqual(l.loadinfo['num_users'], 0)
> AssertionError: 2 != 0
>
> ======================================================================
> FAIL: test_number_of_users_with_single_process_in_ps_output (__main__.LoadInfoKeeperTest)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/site-packages/mock/mock.py", line 1305, in patched
>     return func(*args, **keywargs)
>   File "test_loadinfokeeper.py", line 80, in test_number_of_users_with_single_process_in_ps_output
>     self.assertEqual(l.loadinfo['num_users'], 1)
> AssertionError: 3 != 1
------- Comment #3 From cendio 2017-02-27 16:16:39 -------
Looks to be working very well. I verified that the problem existed on a 4.7.0
server and that it is fixed now with build 5383.

The new code is robust and I couldn't find any ways to break things.