port_stats Test Suite
Port Statistics testing suite.
This test suite tests the functionality of querying the statistics of a port and verifies that the values provided in the statistics accurately reflect the traffic that has been handled on the port. This is shown by sending a packet of a fixed size to the SUT and verifying that the number of Rx packets has increased by 1, the number of Rx bytes has increased by the specified size, the number of Tx packets has also increased by 1 (since we expect the packet to be forwarded), and the number of Tx bytes has also increased by the same fixed amount.
- class TestPortStats
Bases:
TestSuite
DPDK Port statistics testing suite.
Support for port statistics is tested by sending a packet of a fixed size denoted by total_packet_len and verifying the that Tx/Rx packets of the Tx/Rx ports updated by exactly 1 and the Tx/Rx bytes of the Tx/Rx ports updated by exactly total_packet_len. This is done by finding the total amount of packets that were sent/received which did not originate from this test suite and taking the sum of the lengths of each of these “noise” packets and subtracting it from the total values in the port statistics so that all that is left are relevant values.
- recv_port: ClassVar[int] = 0
Port where traffic will be received on the SUT.
- send_port: ClassVar[int] = 1
Port where traffic will be sent from on the SUT.
- ip_header_len: ClassVar[int] = 20
- ether_header_len: ClassVar[int] = 14
- total_packet_len: ClassVar[int] = 100
Length of the packet being sent including the IP and frame headers.
- property send_pkt: scapy.packet.Packet
Packet to send during testing.
- extract_noise_information(verbose_out: list[framework.remote_session.testpmd_shell.TestPmdVerbosePacket]) Tuple[int, int, int, int]
Extract information about packets that were not sent by the framework in verbose_out.
Extract the number of sent/received packets that did not originate from this test suite as well as the sum of the lengths of said “noise” packets. Note that received packets are only examined on the port with the ID self.recv_port since these are the receive stats that will be analyzed in this suite. Sent packets are also only examined on the port with the ID self.send_port.
Packets are considered to be “noise” when they don’t match the expected structure of the packets that are being sent by this test suite. Specifically, the source and destination mac addresses as well as the software packet type are checked on packets received by testpmd to ensure they match the proper addresses of the TG and SUT nodes. Packets that are sent by testpmd however only check the source mac address and the software packet type. This is because MAC forwarding mode adjusts both addresses, but only the source will belong to the TG or SUT node.
- Parameters:
verbose_out (list[framework.remote_session.testpmd_shell.TestPmdVerbosePacket]) – Parsed testpmd verbose output to collect the noise information from.
- Returns:
A tuple containing the total size of received noise in bytes, the number of received noise packets, size of all noise packets sent by testpmd in bytes, and the number of noise packets sent by testpmd.
- Return type:
Tuple[int, int, int, int]
- test_stats_updates() None
Send a packet with a fixed length and verify port stats updated properly.
Send a packet with a total length of self.total_packet_len and verify that the rx port only received one packet and the number of rx_bytes increased by exactly self.total_packet_len. Also verify that the tx port only sent one packet and that the tx_bytes of the port increase by exactly self.total_packet_len.
Noise on the wire is ignored by extracting the total number of noise packets and the sum of the lengths of those packets and subtracting them from the totals that are provided by the testpmd command show port info all.
- Steps:
Start testpmd in MAC forwarding mode and set verbose mode to 3 (Rx and Tx). Start packet forwarding and then clear all port statistics. Send a packet, then stop packet forwarding and collect the port stats.
- Verify:
Parse verbose info from stopping packet forwarding and verify values in port stats.
- required_capabilities: ClassVar[set[Capability]] = {NicCapability.PHYSICAL_FUNCTION}
The capabilities the test case or suite requires in order to be executed.