Paul Vinciguerra | 5995482 | 2019-03-11 05:04:12 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python2.7 |
| 2 | |
| 3 | import unittest |
| 4 | |
| 5 | import psutil |
| 6 | from vpp_papi.vpp_stats import VPPStats |
| 7 | |
| 8 | from framework import VppTestCase, VppTestRunner |
| 9 | |
| 10 | |
| 11 | class StatsClientTestCase(VppTestCase): |
| 12 | """Test Stats Client""" |
| 13 | |
| 14 | @classmethod |
| 15 | def setUpClass(cls): |
| 16 | super(StatsClientTestCase, cls).setUpClass() |
| 17 | |
| 18 | @classmethod |
| 19 | def tearDownClass(cls): |
| 20 | super(StatsClientTestCase, cls).tearDownClass() |
| 21 | |
| 22 | def test_client_fd_leak(self): |
| 23 | """Test file descriptor count - VPP-1486""" |
| 24 | |
| 25 | cls = self.__class__ |
| 26 | p = psutil.Process() |
| 27 | initial_fds = p.num_fds() |
| 28 | |
| 29 | for _ in range(100): |
| 30 | stats = VPPStats(socketname=cls.stats_sock) |
| 31 | stats.disconnect() |
| 32 | |
| 33 | ending_fds = p.num_fds() |
| 34 | self.assertEqual(initial_fds, ending_fds, |
| 35 | "initial client side file descriptor count: %s " |
| 36 | "is not equal to " |
| 37 | "ending client side file descriptor count: %s" % ( |
| 38 | initial_fds, ending_fds)) |
| 39 | |
| 40 | if __name__ == '__main__': |
| 41 | unittest.main(testRunner=VppTestRunner) |