Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 36 additions & 13 deletions ansible/roles/test/files/acstests/lag_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class LacpTimingTest(BaseTest,RouterUtility):
@ param: timeout - time to expect the LACP packet.
@ param: packet_timing - time between two packets.
@ param: ether_type - Ethernet type of expected packet.
@ param: interval_count - Number of intervals to collect.
'''

def __init__(self):
Expand All @@ -95,13 +96,46 @@ def setUp(self):
'''
self.dataplane = ptf.dataplane_instance

def getMedianInterval(self, masked_exp_pkt):
intervals = []
# Verify two LACP packets.
(rcv_device, rcv_port, rcv_pkt, last_pkt_time) = self.dataplane.poll(port_number=self.exp_iface, timeout=self.timeout, exp_pkt=masked_exp_pkt)
last_pkt_time = round(float(last_pkt_time), 2)

for i in range(0, self.interval_count):
(rcv_device, rcv_port, rcv_pkt, curr_pkt_time) = self.dataplane.poll(port_number=self.exp_iface, timeout=self.timeout, exp_pkt=masked_exp_pkt)

# Check the packet received.
self.assertTrue(rcv_pkt != None, "Failed to receive LACP packet\n")

# Get current packet timing
curr_pkt_time = round(float(curr_pkt_time), 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if the round op is really needed or not, but anyway.


interval = curr_pkt_time - last_pkt_time
intervals += [ interval ]

last_pkt_time = curr_pkt_time

# Get the median
intervals.sort()
current_pkt_timing = intervals[self.interval_count / 2]
return current_pkt_timing


def runTest(self):

# Get test parameters
self.exp_iface = self.test_params['exp_iface']
self.timeout = self.test_params['timeout']
self.packet_timing = self.test_params['packet_timing']
self.ether_type = self.test_params['ether_type']
self.interval_count = int(self.test_params['interval_count'])
if self.interval_count < 1:
self.interval_count = 3

# Make sure the interval count is odd, so that we only look at one median interval
if self.interval_count % 2 == 0:
self.interval_count += 1

# Generate a packet.
exp_pkt = simple_eth_packet(eth_type=self.ether_type)
Expand All @@ -116,17 +150,6 @@ def runTest(self):
# Flush packets in dataplane
self.dataplane.flush()

# Verify two LACP packets.
(rcv_device, rcv_port, rcv_pkt, first_pkt_time) = self.dataplane.poll(port_number=self.exp_iface, timeout=self.timeout, exp_pkt=masked_exp_pkt)
(rcv_device, rcv_port, rcv_pkt, last_pkt_time) = self.dataplane.poll(port_number=self.exp_iface, timeout=self.timeout, exp_pkt=masked_exp_pkt)

# Check the packet received.
self.assertTrue(rcv_pkt != None, "Failed to receive LACP packet\n")

# Get current packet timing
first_pkt_time = round(float(first_pkt_time), 2)
last_pkt_time = round(float(last_pkt_time), 2)
current_pkt_timing = last_pkt_time - first_pkt_time

# Check that packet timing matches the expected value.
self.assertTrue(abs(current_pkt_timing - float(self.packet_timing)) < 0.1, "Bad packet timing: %.2f seconds while expected timing is %d seconds from %s" % (current_pkt_timing, self.packet_timing, self.exp_iface))
current_pkt_timing = self.getMedianInterval(masked_exp_pkt)
self.assertTrue(abs(current_pkt_timing - float(self.packet_timing)) < 0.1, "Bad packet timing: %.2f seconds while expected timing is %d seconds from port %s out of %d intervals" % (current_pkt_timing, self.packet_timing, self.exp_iface, self.interval_count))
4 changes: 4 additions & 0 deletions ansible/roles/test/tasks/lag_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
include_vars: vars/topo_t0.yml
when: testbed_type == 't0'

- name: Include testbed topology configuration (to get LAG IP and PTF docker interfaces, that are behind LAG VMs).
include_vars: vars/topo_t0-116.yml
when: testbed_type == 't0-116'

- set_fact:
dut_mac: "{{ ansible_Ethernet0['macaddress'] }}"

Expand Down
14 changes: 12 additions & 2 deletions ansible/roles/test/tasks/lag_lacp_timing_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# @ params: iface_behind_lag_member_0 - PTF docker iface, that receives all the packets that VM LAG member does.
# @ params: iface_behind_lag_member_1 - PTF docker iface, that receives all the packets that VM LAG member does.
# @ params: vm_name - VM hostname that will be printed before running test.
# @ params: interval_count - specifying how many packet internvals to test.
# When internval count is n, n+1 packets will be
# received to get n internvals, the test will
# then check the median internval.
#
# Originally in lagall.yml, and lag_2.yml should cover it
#--------------------------------------------------------
Expand All @@ -16,17 +20,23 @@
packet_timing: "{{ lacp_timer }}"
packet_timeout: 35

- set_fact:
interval_count: 3
when: interval_count is not defined

- debug: msg="Finding median of {{ interval_count }} packet intervals"

- name: Check LACP timing on eth{{ iface_behind_lag_member[0] }} (interface behind {{ vm_name }}).
include: lag_run_ptf.yml
vars:
lag_ptf_test_name: LacpTimingTest
params: "exp_iface={{ iface_behind_lag_member[0] }}; timeout={{ packet_timeout }}; packet_timing={{ packet_timing }}; ether_type={{ lacp_ether_type }}"
params: "exp_iface={{ iface_behind_lag_member[0] }}; timeout={{ packet_timeout }}; packet_timing={{ packet_timing }}; ether_type={{ lacp_ether_type }}; interval_count={{ interval_count }}"
change_dir: /tmp

- name: Check LACP timing on eth{{ iface_behind_lag_member[1] }} (interface behind {{ vm_name }}).
include: lag_run_ptf.yml
vars:
lag_ptf_test_name: LacpTimingTest
params: "exp_iface={{ iface_behind_lag_member[1] }}; timeout={{ packet_timeout }}; packet_timing={{ packet_timing }}; ether_type={{ lacp_ether_type }}"
params: "exp_iface={{ iface_behind_lag_member[1] }}; timeout={{ packet_timeout }}; packet_timing={{ packet_timing }}; ether_type={{ lacp_ether_type }}; interval_count={{ interval_count }}"
change_dir: /tmp
when: iface_behind_lag_member[1] is defined
2 changes: 2 additions & 0 deletions ansible/roles/test/tasks/single_lag_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
vars:
vm_name: "{{ peer_device }}"
lacp_timer: 1
interval_count: 3

# make sure portchannel peer rate is set to slow
- name: make sure all lag members on VM are set to slow
Expand All @@ -98,3 +99,4 @@
vars:
vm_name: "{{ peer_device }}"
lacp_timer: 30
interval_count: 3