Skip to content

Commit

Permalink
Merge branch 'sonic-net:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Azarack authored Oct 27, 2023
2 parents 0b981fb + 8aa3100 commit 99aca6a
Show file tree
Hide file tree
Showing 22 changed files with 291 additions and 112 deletions.
48 changes: 43 additions & 5 deletions ansible/library/announce_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import json
import sys
import socket

import random
from multiprocessing.pool import ThreadPool
from ansible.module_utils.basic import AnsibleModule

if sys.version_info.major == 3:
Expand Down Expand Up @@ -162,6 +163,37 @@ def change_routes(action, ptf_ip, port, routes):
)


def send_routes_for_each_set(args):
routes, port, action, ptf_ip = args
change_routes(action, ptf_ip, port, routes)


def send_routes_in_parallel(route_set):
"""
Sends the given set of routes in parallel using a thread pool.
Args:
route_set (list): A list of route sets to send.
Returns:
None
"""
# Create a pool of worker processes
pool = ThreadPool(processes=len(route_set))

# Use the ThreadPool.map function to apply the function to each set of routes
results = pool.map(send_routes_for_each_set, route_set)

# Optionally, process the results
for result in results:
# Process individual results here
pass

# Close the pool and wait for all processes to complete
pool.close()
pool.join()


# AS path from Leaf router for T0 topology
def get_leaf_uplink_as_path(spine_asn):
default_route_as_path = "6666 6667"
Expand Down Expand Up @@ -826,6 +858,7 @@ def fib_mx(topo, ptf_ip, action="announce"):


def fib_t2_lag(topo, ptf_ip, action="announce"):
route_set = []
vms = topo['topology']['VMs']
# T1 VMs per linecard(asic) - key is the dut index, and value is a list of T1 VMs
t1_vms = {}
Expand All @@ -844,14 +877,16 @@ def fib_t2_lag(topo, ptf_ip, action="announce"):
if dut_index not in t3_vms:
t3_vms[dut_index] = list()
t3_vms[dut_index].append(key)
generate_t2_routes(t1_vms, topo, ptf_ip, action="announce")
generate_t2_routes(t3_vms, topo, ptf_ip, action="announce")
route_set += generate_t2_routes(t1_vms, topo, ptf_ip, action)
route_set += generate_t2_routes(t3_vms, topo, ptf_ip, action)
send_routes_in_parallel(route_set)


def generate_t2_routes(dut_vm_dict, topo, ptf_ip, action="announce"):
common_config = topo['configuration_properties'].get('common', {})
vms = topo['topology']['VMs']
vms_config = topo['configuration']
r_set = []

podset_number = common_config.get("podset_number", PODSET_NUMBER)
tor_number = common_config.get("tor_number", TOR_NUMBER)
Expand Down Expand Up @@ -904,15 +939,18 @@ def generate_t2_routes(dut_vm_dict, topo, ptf_ip, action="announce"):
nhipv4, nhipv6, tor_subnet_size, max_tor_subnet_number, "t2",
router_type=router_type, tor_index=tor_index, set_num=set_num,
core_ra_asn=core_ra_asn)
change_routes(action, ptf_ip, port, routes_v4)
change_routes(action, ptf_ip, port6, routes_v6)
random.shuffle(routes_v4)
random.shuffle(routes_v6)
r_set.append((routes_v4, port, action, ptf_ip))
r_set.append((routes_v6, port6, action, ptf_ip))

if 'vips' in vms_config[a_vm]:
routes_vips = []
for prefix in vms_config[a_vm]["vips"]["ipv4"]["prefixes"]:
routes_vips.append(
(prefix, nhipv4, vms_config[a_vm]["vips"]["ipv4"]["asn"]))
change_routes(action, ptf_ip, port, routes_vips)
return r_set


def fib_t0_mclag(topo, ptf_ip, action="announce"):
Expand Down
65 changes: 18 additions & 47 deletions ansible/roles/test/files/ptftests/py3/copp_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,34 +238,6 @@ def printStats(self, pkt_send_count, recv_count, time_delta, tx_pps, rx_pps):
self.log('RX PPS = %d' % rx_pps)


class NoPolicyTest(ControlPlaneBaseTest):
def __init__(self):
ControlPlaneBaseTest.__init__(self)
self.needPreSend = False

def check_constraints(self, send_count, recv_count, time_delta_ms, rx_pps):
pkt_rx_limit = send_count * 0.90

self.log("")
self.log("Checking constraints (NoPolicy):")
self.log(
"rx_pps (%d) > NO_POLICER_LIMIT (%d): %s" %
(int(rx_pps), int(self.NO_POLICER_LIMIT),
str(rx_pps > self.NO_POLICER_LIMIT))
)
self.log(
"recv_count (%d) > pkt_rx_limit (%d): %s" %
(int(recv_count), int(pkt_rx_limit), str(recv_count > pkt_rx_limit))
)

if self.has_trap:
assert (rx_pps > self.NO_POLICER_LIMIT)
assert (recv_count > pkt_rx_limit)
else:
assert (rx_pps < self.NO_POLICER_LIMIT)
assert (recv_count < pkt_rx_limit)


class PolicyTest(ControlPlaneBaseTest):
def __init__(self):
ControlPlaneBaseTest.__init__(self)
Expand Down Expand Up @@ -350,10 +322,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for DHCP
class DHCPTest(NoPolicyTest):
# SONIC config contains policer CIR=300 for DHCP
class DHCPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("DHCPTest")
Expand Down Expand Up @@ -384,10 +356,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for DHCPv6
class DHCP6Test(NoPolicyTest):
# SONIC config contains policer CIR=300 for DHCPv6
class DHCP6Test(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("DHCP6Test")
Expand Down Expand Up @@ -436,12 +408,11 @@ def contruct_packet(self, port_number):

return packet

# SONIC configuration has no policer limiting for LLDP


class LLDPTest(NoPolicyTest):
# SONIC config contains policer CIR=300 for LLDP
class LLDPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("LLDPTest")
Expand All @@ -459,10 +430,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for UDLD
class UDLDTest(NoPolicyTest):
# SONIC config contains policer CIR=300 for UDLD
class UDLDTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("UDLDTest")
Expand All @@ -485,10 +456,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for BGP
class BGPTest(NoPolicyTest):
# SONIC config contains policer CIR=6000 for BGP
class BGPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("BGPTest")
Expand All @@ -508,10 +479,10 @@ def contruct_packet(self, port_number):
return packet


# SONIC configuration has no policer limiting for LACP
class LACPTest(NoPolicyTest):
# SONIC config contains policer CIR=6000 for LACP
class LACPTest(PolicyTest):
def __init__(self):
NoPolicyTest.__init__(self)
PolicyTest.__init__(self)

def runTest(self):
self.log("LACPTest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,6 @@ r, ".* ERR syncd\d*#syncd.*SAI_API_UNSPECIFIED:sai_bulk_object_get_stats.*"

# https://msazure.visualstudio.com/One/_workitems/edit/25018599
r, ".* ERROR: Failed to parse lldp age.*"

# NTPsec always expects the statistics directory to be available, but for now, we don't need NTP stats to be logged
r, ".* ERR ntpd.*: statistics directory .* does not exist or is unwriteable, error No such file or directory"
12 changes: 9 additions & 3 deletions ansible/testbed_add_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@
gather_facts: no
pre_tasks:
- set_fact: ansible_user="{{ vm_host_user }}"
when: vm_host_user is defined
when:
- vm_host_user is defined
- vm_host_user != 'use_own_value'

- set_fact: ansible_password="{{ vm_host_password }}"
when: vm_host_password is defined
when:
- vm_host_password is defined
- vm_host_password != 'use_own_value'

- set_fact: ansible_become_password="{{ vm_host_become_password }}"
when: vm_host_become_password is defined
when:
- vm_host_become_password is defined
- vm_host_become_password != 'use_own_value'

- name: Check for a single host
fail: msg="Please use -l server_X to limit this playbook to one host"
Expand Down
12 changes: 9 additions & 3 deletions ansible/testbed_remove_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@
- vars/docker_registry.yml
pre_tasks:
- set_fact: ansible_user="{{ vm_host_user }}"
when: vm_host_user is defined
when:
- vm_host_user is defined
- vm_host_user != 'use_own_value'

- set_fact: ansible_password="{{ vm_host_password }}"
when: vm_host_password is defined
when:
- vm_host_password is defined
- vm_host_password != 'use_own_value'

- set_fact: ansible_become_password="{{ vm_host_become_password }}"
when: vm_host_become_password is defined
when:
- vm_host_become_password is defined
- vm_host_become_password != 'use_own_value'

- name: Check for a single host
fail: msg="Please use -l server_X to limit this playbook to one host"
Expand Down
12 changes: 9 additions & 3 deletions ansible/testbed_renumber_vm_topology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
- vars/docker_registry.yml
pre_tasks:
- set_fact: ansible_user="{{ vm_host_user }}"
when: vm_host_user is defined
when:
- vm_host_user is defined
- vm_host_user != 'use_own_value'

- set_fact: ansible_password="{{ vm_host_password }}"
when: vm_host_password is defined
when:
- vm_host_password is defined
- vm_host_password != 'use_own_value'

- set_fact: ansible_become_password="{{ vm_host_become_password }}"
when: vm_host_become_password is defined
when:
- vm_host_become_password is defined
- vm_host_become_password != 'use_own_value'

- name: Check for a single host
fail: msg="Please use -l server_X to limit this playbook to one host"
Expand Down
2 changes: 1 addition & 1 deletion test_reporting/junit_xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def _extract_test_summary(test_cases):
# The result field is unique per test case, either error or failure.
# xfails is the counter for all kinds of xfail results (include success/failure/error/skipped)
test_result_summary["tests"] += 1
test_result_summary["failures"] += case["result"] == "failure" or case["result"] == "error"
test_result_summary["failures"] += case["result"] == "failure"
test_result_summary["skipped"] += case["result"] == "skipped"
test_result_summary["errors"] += case["error"]
test_result_summary["time"] += float(case["time"])
Expand Down
6 changes: 4 additions & 2 deletions tests/cacl/test_cacl_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,13 @@ def generate_and_append_block_ip2me_traffic_rules(duthost, iptables_rules, ip6ta


def append_midplane_traffic_rules(duthost, iptables_rules):
result = duthost.shell('ip link show | grep -w "eth1-midplane"', module_ignore_errors=True)['stdout']
# Get the kernel intf name in the event that eth1-midplane is an altname
result = duthost.shell('ip link show eth1-midplane | awk \'NR==1{print$2}\' | cut -f1 -d"@" | cut -f1 -d":"',
module_ignore_errors=True)['stdout']
if result:
midplane_ip = duthost.shell('ip -4 -o addr show eth1-midplane | awk \'{print $4}\' | cut -d / -f1 | head -1',
module_ignore_errors=True)['stdout']
iptables_rules.append("-A INPUT -i eth1-midplane -j ACCEPT")
iptables_rules.append("-A INPUT -i {} -j ACCEPT".format(result))
iptables_rules.append("-A INPUT -s {}/32 -d {}/32 -j ACCEPT".format(midplane_ip, midplane_ip))


Expand Down
8 changes: 7 additions & 1 deletion tests/common/devices/sonic_asic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import socket
import re

from tests.common.helpers.assertions import pytest_assert
from tests.common.helpers.constants import DEFAULT_NAMESPACE, NAMESPACE_PREFIX
Expand Down Expand Up @@ -548,7 +549,12 @@ def shell(self, *module_args, **complex_args):
def port_on_asic(self, portname):
cmd = 'sudo sonic-cfggen {} -v "PORT.keys()" -d'.format(self.cli_ns_option)
ports = self.shell(cmd)["stdout_lines"][0]
if ports is not None and portname in ports:
# The variable 'ports' is a string in format below
# u"dict_keys(['Ethernet144', 'Ethernet152', 'Ethernet160', 'Ethernet280'])"
# doing a regex match for '<interface_name>'' to get the **exact** port.
# Without which a check like --> ('Ethernet16' in ports) returns true, because
# Ethernet16 matches as a substring to Ethernet160 which is present in 'ports'
if ports is not None and re.search(r"'{}'".format(portname), ports):
return True
return False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ arp/test_wr_arp.py:
xfail:
reason: "Warm reboot has a known issue on 202305 branch"
conditions:
- "hwsku in ['Arista-7050CX3-32S-C32', 'Arista-7050CX3-32S-D48C8', 'Arista-7060CX-32S-D48C8', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-Q32', 'Force10-S6100', 'Arista-7260CX3-C64', 'Arista-7260CX3-Q44', 'Arista-7260CX3-D108C8'] and release in ['202305']"
- "hwsku in ['Arista-7050CX3-32S-C32', 'Arista-7050CX3-32S-D48C8', 'Arista-7050-QX-32S', 'Arista-7050QX32S-Q32', 'Arista-7060CX-32S-D48C8', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-Q32', 'Force10-S6100', 'Arista-7260CX3-C64', 'Arista-7260CX3-Q44', 'Arista-7260CX3-D108C8'] and release in ['202305']"
- https://github.com/sonic-net/sonic-mgmt/issues/10077

#######################################
Expand Down Expand Up @@ -811,7 +811,7 @@ pfcwd/test_pfcwd_warm_reboot.py:
xfail:
reason: "Warm Reboot is not supported in dualtor and has a known issue on 202305 branch"
conditions:
- "('dualtor' in topo_name) or (hwsku in ['Arista-7050CX3-32S-C32', 'Arista-7050CX3-32S-D48C8', 'Arista-7060CX-32S-D48C8', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-Q32', 'Force10-S6100', 'Arista-7260CX3-C64', 'Arista-7260CX3-Q44', 'Arista-7260CX3-D108C8'] and release in ['202305'])"
- "('dualtor' in topo_name) or (hwsku in ['Arista-7050CX3-32S-C32', 'Arista-7050CX3-32S-D48C8', 'Arista-7050-QX-32S', 'Arista-7050QX32S-Q32', 'Arista-7060CX-32S-D48C8', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-Q32', 'Force10-S6100', 'Arista-7260CX3-C64', 'Arista-7260CX3-Q44', 'Arista-7260CX3-D108C8'] and release in ['202305'])"
- https://github.com/sonic-net/sonic-mgmt/issues/8400

#######################################
Expand Down Expand Up @@ -872,7 +872,7 @@ platform_tests/test_auto_negotiation.py:
platform_tests/test_cont_warm_reboot.py:
xfail:
reason: "warm reboot has a known issue on 202305 branch"
conditions: "hwsku in ['Arista-7050CX3-32S-C32', 'Arista-7050CX3-32S-D48C8', 'Arista-7060CX-32S-D48C8', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-Q32', 'Force10-S6100', 'Arista-7260CX3-C64', 'Arista-7260CX3-Q44', 'Arista-7260CX3-D108C8'] and release in ['202305']"
conditions: "hwsku in ['Arista-7050CX3-32S-C32', 'Arista-7050CX3-32S-D48C8', 'Arista-7050-QX-32S', 'Arista-7050QX32S-Q32', 'Arista-7060CX-32S-D48C8', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-Q32', 'Force10-S6100', 'Arista-7260CX3-C64', 'Arista-7260CX3-Q44', 'Arista-7260CX3-D108C8'] and release in ['202305']"

#######################################
##### qos #####
Expand Down
Loading

0 comments on commit 99aca6a

Please sign in to comment.