diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c339f111465..704a6aa9aef 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -21,7 +21,7 @@ stages: - job: pool: sonictest displayName: "kvmtest-t0" - timeoutInMinutes: 330 + timeoutInMinutes: 400 steps: - template: .azure-pipelines/run-test-template.yml diff --git a/tests/bgp/test_bgp_update_timer.py b/tests/bgp/test_bgp_update_timer.py index ffc916e9313..cab541b7895 100644 --- a/tests/bgp/test_bgp_update_timer.py +++ b/tests/bgp/test_bgp_update_timer.py @@ -152,12 +152,41 @@ def match_bgp_update(packet, src_ip, dst_ip, action, route): if not (packet[IP].src == src_ip and packet[IP].dst == dst_ip): return False subnet = ipaddress.ip_network(route["prefix"].decode()) - _route = (subnet.prefixlen, str(subnet.network_address)) + + # New scapy (version 2.4.5) uses a different way to represent and dissect BGP messages. Below logic is to + # address the compatibility issue of scapy versions. + if hasattr(bgp, 'BGPNLRI_IPv4'): + _route = bgp.BGPNLRI_IPv4(prefix=str(subnet)) + else: + _route = (subnet.prefixlen, str(subnet.network_address)) bgp_fields = packet[bgp.BGPUpdate].fields if action == "announce": - return bgp_fields["tp_len"] > 0 and _route in bgp_fields["nlri"] + # New scapy (version 2.4.5) uses a different way to represent and dissect BGP messages. Below logic is to + # address the compatibility issue of scapy versions. + path_attr_valid = False + if "tp_len" in bgp_fields: + path_attr_valid = bgp_fields['tp_len'] > 0 + elif "path_attr_len" in bgp_fields: + path_attr_valid = bgp_fields["path_attr_len"] > 0 + return path_attr_valid and _route in bgp_fields["nlri"] elif action == "withdraw": - return bgp_fields["withdrawn_len"] > 0 and _route in bgp_fields["withdrawn"] + # New scapy (version 2.4.5) uses a different way to represent and dissect BGP messages. Below logic is to + # address the compatibility issue of scapy versions. + withdrawn_len_valid = False + if "withdrawn_len" in bgp_fields: + withdrawn_len_valid = bgp_fields["withdrawn_len"] > 0 + elif "withdrawn_routes_len" in bgp_fields: + withdrawn_len_valid = bgp_fields["withdrawn_routes_len"] > 0 + + # New scapy (version 2.4.5) uses a different way to represent and dissect BGP messages. Below logic is to + # address the compatibility issue of scapy versions. + withdrawn_route_valid = False + if "withdrawn" in bgp_fields: + withdrawn_route_valid = _route in bgp_fields["withdrawn"] + elif "withdrawn_routes" in bgp_fields: + withdrawn_route_valid = _route in bgp_fields["withdrawn_routes"] + + return withdrawn_len_valid and withdrawn_route_valid else: return False