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
77 changes: 57 additions & 20 deletions ansible/roles/test/files/ptftests/vxlan-decap.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,36 @@ def setUp(self):
def tearDown(self):
return

def runTest(self):
print
def warmup(self):
print "Warming up"
err = ''
trace = ''
ret = 0
try:
for test in self.tests:
if self.vxlan_enabled:
self.Vxlan(test, True)
self.RegularLAGtoVLAN(test, True)
self.RegularVLANtoLAG(test, True)

except Exception as e:
err = str(e)
trace = traceback.format_exc()
ret = -1
if ret != 0:
print "The warmup failed"
print
print "Error: %s" % err
print
print trace
else:
print "Warmup successful\n"
sys.stdout.flush()
if ret != 0:
raise AssertionError("Warmup failed")

def work_test(self):
print "Testing"
err = ''
trace = ''
ret = 0
Expand Down Expand Up @@ -194,28 +222,37 @@ def runTest(self):
if ret != 0:
raise AssertionError(err)

def Vxlan(self, test):
for n in self.net_ports:
for a in test['acc_ports']:

def runTest(self):
print
# Warm-up first
self.warmup()
# test itself
self.work_test()


def Vxlan(self, test, wu = False):
for i, n in enumerate(self.net_ports):
for j, a in enumerate(test['acc_ports']):
res, out = self.checkVxlan(a, n, test)
if not res:
return False, out
if not res and not wu:
return False, out + " | net_port_rel=%d acc_port_rel=%d" % (i, j)
return True, ""

def RegularLAGtoVLAN(self, test):
for n in self.net_ports:
for a in test['acc_ports']:
def RegularLAGtoVLAN(self, test, wu = False):
for i, n in enumerate(self.net_ports):
for j, a in enumerate(test['acc_ports']):
res, out = self.checkRegularRegularLAGtoVLAN(a, n, test)
if not res:
return False, out
if not res and not wu:
return False, out + " | net_port_rel=%d acc_port_rel=%d" % (i, j)
return True, ""

def RegularVLANtoLAG(self, test):
for dst, ports in self.pc_info:
for a in test['acc_ports']:
def RegularVLANtoLAG(self, test, wu = False):
for i, (dst, ports) in enumerate(self.pc_info):
for j, a in enumerate(test['acc_ports']):
res, out = self.checkRegularRegularVLANtoLAG(a, ports, dst, test)
if not res:
return False, out
if not res and not wu:
return False, out + " | pc_info_rel=%d acc_port_rel=%d" % (i, j)
return True, ""

def checkRegularRegularVLANtoLAG(self, acc_port, pc_ports, dst_ip, test):
Expand All @@ -242,7 +279,7 @@ def checkRegularRegularVLANtoLAG(self, acc_port, pc_ports, dst_ip, test):

for i in xrange(self.nr):
testutils.send_packet(self, acc_port, packet)
nr_rcvd = testutils.count_matched_packets_all_ports(self, exp_packet, pc_ports, timeout=0.2)
nr_rcvd = testutils.count_matched_packets_all_ports(self, exp_packet, pc_ports, timeout=0.5)
rv = nr_rcvd == self.nr
out = ""
if not rv:
Expand Down Expand Up @@ -274,7 +311,7 @@ def checkRegularRegularLAGtoVLAN(self, acc_port, net_port, test):

for i in xrange(self.nr):
testutils.send_packet(self, net_port, packet)
nr_rcvd = testutils.count_matched_packets(self, exp_packet, acc_port, timeout=0.2)
nr_rcvd = testutils.count_matched_packets(self, exp_packet, acc_port, timeout=0.5)
rv = nr_rcvd == self.nr
out = ""
if not rv:
Expand Down Expand Up @@ -311,7 +348,7 @@ def checkVxlan(self, acc_port, net_port, test):
)
for i in xrange(self.nr):
testutils.send_packet(self, net_port, packet)
nr_rcvd = testutils.count_matched_packets(self, inpacket, acc_port, timeout=0.2)
nr_rcvd = testutils.count_matched_packets(self, inpacket, acc_port, timeout=0.5)
rv = nr_rcvd == self.nr
out = ""
if not rv:
Expand Down
10 changes: 5 additions & 5 deletions ansible/roles/test/tasks/vxlan-decap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
- name: Configure vxlan decap tunnel
shell: sonic-cfggen -j /tmp/vxlan_db.tunnel.json --write-to-db

- name: Configure vxlan decap tunnel map for {{ item }}
- name: Configure vxlan decap tunnel maps
shell: sonic-cfggen -j /tmp/vxlan_db.maps.{{ item }}.json --write-to-db
with_items: minigraph_vlans

Expand All @@ -82,9 +82,9 @@
- config_file='/tmp/vxlan_decap.json'
- count=1

- name: Remove vxlan tunnel map configuration for {{ item }}
- name: Remove vxlan tunnel maps configuration
shell: docker exec -i database redis-cli -n 4 -c DEL "VXLAN_TUNNEL_MAP|tunnelVxlan|map{{ item }}"
with_items: minigraph_vlans
with_items: "{{ minigraph_vlans }}"

- name: Remove vxlan tunnel configuration
shell: docker exec -i database redis-cli -n 4 -c DEL "VXLAN_TUNNEL|tunnelVxlan"
Expand All @@ -104,9 +104,9 @@


- always:
- name: Remove vxlan tunnel map configuration for {{ item }}
- name: Remove vxlan tunnel maps configuration
shell: docker exec -i database redis-cli -n 4 -c DEL "VXLAN_TUNNEL_MAP|tunnelVxlan|map{{ item }}"
with_items: minigraph_vlans
with_items: "{{ minigraph_vlans }}"

- name: Remove vxlan tunnel configuration
shell: docker exec -i database redis-cli -n 4 -c DEL "VXLAN_TUNNEL|tunnelVxlan"
Expand Down