blob: a0504fc45ab9e090c62f006ad16a8a805374d21b [file] [log] [blame]
Paul Vinciguerra59954822019-03-11 05:04:12 -07001#!/usr/bin/env python2.7
2
3import unittest
4
5import psutil
6from vpp_papi.vpp_stats import VPPStats
7
8from framework import VppTestCase, VppTestRunner
9
10
11class 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
Ole Troan233e4682019-05-16 15:01:34 +020022 def test_set_errors(self):
23 """Test set errors"""
24 self.assertEqual(self.statistics.set_errors(), {})
25 self.assertEqual(self.statistics.get_counter('/err/ethernet-input/no'),
26 [0])
27
Paul Vinciguerra59954822019-03-11 05:04:12 -070028 def test_client_fd_leak(self):
29 """Test file descriptor count - VPP-1486"""
30
31 cls = self.__class__
32 p = psutil.Process()
33 initial_fds = p.num_fds()
34
35 for _ in range(100):
36 stats = VPPStats(socketname=cls.stats_sock)
37 stats.disconnect()
38
39 ending_fds = p.num_fds()
40 self.assertEqual(initial_fds, ending_fds,
41 "initial client side file descriptor count: %s "
42 "is not equal to "
43 "ending client side file descriptor count: %s" % (
44 initial_fds, ending_fds))
45
46if __name__ == '__main__':
47 unittest.main(testRunner=VppTestRunner)