www.cendio.com

Bug 6167

Summary: "number of users" value in load status is off by two
Product: ThinLinc Reporter: Karl Mikaelsson <derfian@cendio.se>
Component: VSM AgentAssignee: Henrik Andersson <hean01@cendio.se>
Status: CLOSED FIXED QA Contact: Bugzilla mail exporter <bugzilla-qa@cendio.se>
Severity: Normal    
Priority: P2 CC: astrand@cendio.se, hean01@cendio.se, samuel@cendio.se
Version: trunkKeywords: relnotes, samuel_tester
Target Milestone: 4.8.0   
Hardware: PC   
OS: Unknown   
Acceptance Criteria:

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.