5 from vpp_papi.vpp_stats import VPPStats
7 from framework import VppTestCase, VppTestRunner
10 class StatsClientTestCase(VppTestCase):
11 """Test Stats Client"""
15 super(StatsClientTestCase, cls).setUpClass()
18 def tearDownClass(cls):
19 super(StatsClientTestCase, cls).tearDownClass()
21 def test_set_errors(self):
23 self.assertEqual(self.statistics.set_errors(), {})
24 self.assertEqual(self.statistics.get_counter('/err/ethernet-input/no'),
27 def test_client_fd_leak(self):
28 """Test file descriptor count - VPP-1486"""
32 initial_fds = p.num_fds()
35 stats = VPPStats(socketname=cls.stats_sock)
38 ending_fds = p.num_fds()
39 self.assertEqual(initial_fds, ending_fds,
40 "initial client side file descriptor count: %s "
42 "ending client side file descriptor count: %s" % (
43 initial_fds, ending_fds))
45 @unittest.skip("Manual only")
46 def test_mem_leak(self):
50 rv = self.vapi.papi.tap_create_v2(id=i, use_random_mac=1)
51 self.assertEqual(rv.retval, 0)
52 rv = self.vapi.papi.tap_delete_v2(sw_if_index=rv.sw_if_index)
53 self.assertEqual(rv.retval, 0)
55 before = self.statistics.get_counter('/mem/statseg/used')
57 self.vapi.cli("memory-trace on stats-segment")
60 print(self.vapi.cli("show memory stats-segment verbose"))
61 print('AFTER', before,
62 self.statistics.get_counter('/mem/statseg/used'))
65 if __name__ == '__main__':
66 unittest.main(testRunner=VppTestRunner)