stats: fix tests with multiple workers
Type: fix Change-Id: Ic4b8478d390c7373bfb43a39ae6a70e978ae9321 Signed-off-by: Benoît Ganne <bganne@cisco.com>
This commit is contained in:

committed by
Damjan Marion

parent
064ff15150
commit
79cb1d53c1
@ -4,13 +4,11 @@ import unittest
|
|||||||
import psutil
|
import psutil
|
||||||
from vpp_papi.vpp_stats import VPPStats
|
from vpp_papi.vpp_stats import VPPStats
|
||||||
|
|
||||||
from framework import tag_fixme_vpp_workers
|
|
||||||
from framework import VppTestCase, VppTestRunner
|
from framework import VppTestCase, VppTestRunner
|
||||||
from scapy.layers.l2 import Ether
|
from scapy.layers.l2 import Ether
|
||||||
from scapy.layers.inet import IP
|
from scapy.layers.inet import IP
|
||||||
|
|
||||||
|
|
||||||
@tag_fixme_vpp_workers
|
|
||||||
class StatsClientTestCase(VppTestCase):
|
class StatsClientTestCase(VppTestCase):
|
||||||
"""Test Stats Client"""
|
"""Test Stats Client"""
|
||||||
|
|
||||||
@ -22,6 +20,16 @@ class StatsClientTestCase(VppTestCase):
|
|||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
super(StatsClientTestCase, cls).tearDownClass()
|
super(StatsClientTestCase, cls).tearDownClass()
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(StatsClientTestCase, self).setUp()
|
||||||
|
self.create_pg_interfaces([])
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
super(StatsClientTestCase, self).tearDown()
|
||||||
|
for i in self.pg_interfaces:
|
||||||
|
i.unconfig()
|
||||||
|
i.admin_down()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpConstants(cls):
|
def setUpConstants(cls):
|
||||||
cls.extra_vpp_statseg_config = "per-node-counters on"
|
cls.extra_vpp_statseg_config = "per-node-counters on"
|
||||||
@ -32,7 +40,8 @@ class StatsClientTestCase(VppTestCase):
|
|||||||
"""Test set errors"""
|
"""Test set errors"""
|
||||||
self.assertEqual(self.statistics.set_errors(), {})
|
self.assertEqual(self.statistics.set_errors(), {})
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.statistics.get_counter("/err/ethernet-input/no error"), [0]
|
self.statistics.get_counter("/err/ethernet-input/no error"),
|
||||||
|
[0] * (1 + self.vpp_worker_count),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_client_fd_leak(self):
|
def test_client_fd_leak(self):
|
||||||
@ -76,9 +85,6 @@ class StatsClientTestCase(VppTestCase):
|
|||||||
if_tx = self.statistics.get_counter("/if/tx")
|
if_tx = self.statistics.get_counter("/if/tx")
|
||||||
|
|
||||||
self.assertEqual(pg1_tx[0]["bytes"], if_tx[0][self.pg1.sw_if_index]["bytes"])
|
self.assertEqual(pg1_tx[0]["bytes"], if_tx[0][self.pg1.sw_if_index]["bytes"])
|
||||||
for i in self.pg_interfaces:
|
|
||||||
i.unconfig()
|
|
||||||
i.admin_down()
|
|
||||||
|
|
||||||
def test_symlink_add_del_interfaces(self):
|
def test_symlink_add_del_interfaces(self):
|
||||||
"""Test symlinks when adding and deleting interfaces"""
|
"""Test symlinks when adding and deleting interfaces"""
|
||||||
@ -109,20 +115,24 @@ class StatsClientTestCase(VppTestCase):
|
|||||||
rx = self.statistics.get_counter("/interfaces/pg0/rx")
|
rx = self.statistics.get_counter("/interfaces/pg0/rx")
|
||||||
|
|
||||||
# We wait for nodes symlinks to update (interfaces created/deleted).
|
# We wait for nodes symlinks to update (interfaces created/deleted).
|
||||||
# ... and packets to be sent
|
self.virtual_sleep(1)
|
||||||
self.sleep(0.1)
|
|
||||||
vectors = self.statistics.get_counter("/nodes/pg1-tx/vectors")
|
vectors = self.statistics.get_counter("/nodes/pg1-tx/vectors")
|
||||||
|
|
||||||
self.assertEqual(tx[0]["bytes"] - tx_before_sending[0]["bytes"], bytes_to_send)
|
rx_bytes = 0
|
||||||
self.assertEqual(tx[0]["packets"] - tx_before_sending[0]["packets"], 5)
|
rx_packets = 0
|
||||||
self.assertEqual(rx[0]["bytes"] - rx_before_sending[0]["bytes"], bytes_to_send)
|
tx_bytes = 0
|
||||||
self.assertEqual(rx[0]["packets"] - rx_before_sending[0]["packets"], 5)
|
tx_packets = 0
|
||||||
|
for i in range(1 + self.vpp_worker_count):
|
||||||
|
rx_bytes += rx[i]["bytes"] - rx_before_sending[i]["bytes"]
|
||||||
|
rx_packets += rx[i]["packets"] - rx_before_sending[i]["packets"]
|
||||||
|
tx_bytes += tx[i]["bytes"] - tx_before_sending[i]["bytes"]
|
||||||
|
tx_packets += tx[i]["packets"] - tx_before_sending[i]["packets"]
|
||||||
|
self.assertEqual(tx_bytes, bytes_to_send)
|
||||||
|
self.assertEqual(tx_packets, 5)
|
||||||
|
self.assertEqual(rx_bytes, bytes_to_send)
|
||||||
|
self.assertEqual(rx_packets, 5)
|
||||||
self.assertEqual(vectors[0], rx[0]["packets"])
|
self.assertEqual(vectors[0], rx[0]["packets"])
|
||||||
|
|
||||||
for i in self.pg_interfaces:
|
|
||||||
i.unconfig()
|
|
||||||
i.admin_down()
|
|
||||||
|
|
||||||
def test_index_consistency(self):
|
def test_index_consistency(self):
|
||||||
"""Test index consistency despite changes in the stats"""
|
"""Test index consistency despite changes in the stats"""
|
||||||
d = self.statistics.ls(["/if/names"])
|
d = self.statistics.ls(["/if/names"])
|
||||||
|
Reference in New Issue
Block a user