1 #!/usr/bin/env python2.7
6 from vpp_papi.vpp_stats import VPPStats
8 from framework import VppTestCase, VppTestRunner
11 class StatsClientTestCase(VppTestCase):
12 """Test Stats Client"""
16 super(StatsClientTestCase, cls).setUpClass()
19 def tearDownClass(cls):
20 super(StatsClientTestCase, cls).tearDownClass()
22 def test_set_errors(self):
24 self.assertEqual(self.statistics.set_errors(), {})
25 self.assertEqual(self.statistics.get_counter('/err/ethernet-input/no'),
28 def test_client_fd_leak(self):
29 """Test file descriptor count - VPP-1486"""
33 initial_fds = p.num_fds()
36 stats = VPPStats(socketname=cls.stats_sock)
39 ending_fds = p.num_fds()
40 self.assertEqual(initial_fds, ending_fds,
41 "initial client side file descriptor count: %s "
43 "ending client side file descriptor count: %s" % (
44 initial_fds, ending_fds))
46 @unittest.skip("Manual only")
47 def test_mem_leak(self):
51 rv = self.vapi.papi.tap_create_v2(id=i, use_random_mac=1)
52 self.assertEqual(rv.retval, 0)
53 rv = self.vapi.papi.tap_delete_v2(sw_if_index=rv.sw_if_index)
54 self.assertEqual(rv.retval, 0)
56 before = self.statistics.get_counter('/mem/statseg/used')
58 self.vapi.cli("memory-trace on stats-segment")
61 print(self.vapi.cli("show memory stats-segment verbose"))
62 print('AFTER', before,
63 self.statistics.get_counter('/mem/statseg/used'))
66 if __name__ == '__main__':
67 unittest.main(testRunner=VppTestRunner)