-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix test issue for test_ipv6_bgp_scale.py #22676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| from copy import deepcopy | ||
| from threading import Thread, Event | ||
| from tests.common.helpers.assertions import pytest_assert | ||
| import ptf | ||
| import ptf.packet as scapy | ||
| from ptf.testutils import simple_icmpv6_packet | ||
| from ptf.mask import Mask | ||
|
|
@@ -52,6 +53,7 @@ | |
| _icmp_type_generator = itertools.cycle(range(ICMP_TYPE_MIN, ICMP_TYPE_MAX + 1)) | ||
| test_results = {} | ||
| current_test = "" | ||
| global_icmp_type = ICMP_TYPE_MIN | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", autouse=True) | ||
|
|
@@ -279,10 +281,19 @@ def validate_dut_routes(duthost, tbinfo, expected_routes): | |
| return identical | ||
|
|
||
|
|
||
| def _get_backplane_ports(): | ||
| """Identify backplane ports from PTF port_map config so they can be excluded from rx counters.""" | ||
| return {k for k, v in ptf.config.get('port_map', {}).items() if v == 'backplane'} | ||
|
|
||
|
|
||
| def calculate_downtime(ptf_dp, end_time, start_time, masked_exp_pkt): | ||
| logger.warning("Waiting %d seconds for mask counters to be updated", MASK_COUNTER_WAIT_TIME) | ||
| time.sleep(MASK_COUNTER_WAIT_TIME) | ||
| rx_total = sum(list(ptf_dp.mask_rx_cnt[masked_exp_pkt].values())[:-1]) # Exclude the backplane | ||
| backplane_ports = _get_backplane_ports() | ||
| rx_total = sum( | ||
| cnt for port_key, cnt in ptf_dp.mask_rx_cnt[masked_exp_pkt].items() | ||
| if port_key not in backplane_ports | ||
| ) | ||
| tx_total = sum(ptf_dp.mask_tx_cnt[masked_exp_pkt].values()) | ||
| if tx_total == 0: | ||
| logger.warning("No packets are sent") | ||
|
|
@@ -318,7 +329,7 @@ def calculate_downtime(ptf_dp, end_time, start_time, masked_exp_pkt): | |
|
|
||
| def validate_rx_tx_counters(ptf_dp, end_time, start_time, masked_exp_pkt, downtime_threshold=10): | ||
| downtime = calculate_downtime(ptf_dp, end_time, start_time, masked_exp_pkt) | ||
| return downtime < downtime_threshold | ||
| return downtime < downtime_threshold, downtime | ||
|
|
||
|
|
||
| def flush_counters(ptf_dp, masked_exp_pkt): | ||
|
|
@@ -614,7 +625,7 @@ def flapper(duthost, ptfadapter, bgp_peers_info, transient_setup, flapping_count | |
| prefixes, | ||
| duthost.facts['router_mac'], | ||
| pdp.get_mac(pdp.port_to_device(injection_port), injection_port), | ||
| icmp_type | ||
| global_icmp_type | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @weiguo-nvidia , any particular reason why we use the global_icmp_type here? It does not seem to change as the test progresses, whereas the icmp_type variable uses a cycle within a safe range and will distinguish packets across tests.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a conflict resolution/rebase regression, Will update this if no particular reason to use global_icmp_type |
||
| ) | ||
| # Downtime ratio is calculated by dividing the number of flapping neighbors by 5, from test data | ||
| downtime_ratio = len(flapping_connections) / 5 | ||
|
|
@@ -642,11 +653,16 @@ def flapper(duthost, ptfadapter, bgp_peers_info, transient_setup, flapping_count | |
| terminated.set() | ||
| traffic_thread.join() | ||
| end_time = datetime.datetime.now() | ||
| acceptable_downtime = validate_rx_tx_counters(pdp, end_time, start_time, exp_mask, downtime_threshold) | ||
| acceptable_downtime, actual_downtime = validate_rx_tx_counters( | ||
| pdp, end_time, start_time, exp_mask, downtime_threshold | ||
| ) | ||
| if not acceptable_downtime: | ||
| if action == 'shutdown': | ||
| _restore(duthost, connection_type, flapping_connections, all_flap) | ||
| pytest.fail(f"Dataplane downtime is too high, threshold is {downtime_threshold} seconds") | ||
| pytest.fail( | ||
| f"Dataplane downtime is too high: actual {actual_downtime:.4f} seconds, " | ||
| f"threshold is {downtime_threshold} seconds" | ||
| ) | ||
| if not result.get("converged"): | ||
| pytest.fail("BGP routes are not stable in long time") | ||
| finally: | ||
|
|
@@ -778,14 +794,17 @@ def test_nexthop_group_member_scale( | |
| terminated.set() | ||
| traffic_thread.join() | ||
| end_time = datetime.datetime.now() | ||
| acceptable_downtime = validate_rx_tx_counters(pdp, end_time, start_time, exp_mask, | ||
| _get_max_time('dataplane_downtime', 1)) | ||
| acceptable_downtime, actual_downtime = validate_rx_tx_counters( | ||
| pdp, end_time, start_time, exp_mask, _get_max_time('dataplane_downtime', 1) | ||
| ) | ||
| if not acceptable_downtime: | ||
| for ptfhost in ptfhosts: | ||
| ptf_ip = ptfhost.mgmt_ip | ||
| announce_routes(localhost, tbinfo, ptf_ip, servers_dut_interfaces.get(ptf_ip, '')) | ||
| pytest.fail(f"Dataplane downtime is too high, threshold is " | ||
| f"{_get_max_time('dataplane_downtime', 1)} seconds") | ||
| pytest.fail( | ||
| f"Dataplane downtime is too high: actual {actual_downtime:.4f} seconds, " | ||
| f"threshold is {_get_max_time('dataplane_downtime', 1)} seconds" | ||
| ) | ||
| if not result.get("converged"): | ||
| pytest.fail("BGP routes are not stable in long time") | ||
| finally: | ||
|
|
@@ -825,10 +844,14 @@ def test_nexthop_group_member_scale( | |
| terminated.set() | ||
| traffic_thread.join() | ||
| end_time = datetime.datetime.now() | ||
| acceptable_downtime = validate_rx_tx_counters(pdp, end_time, start_time, exp_mask, | ||
| _get_max_time('dataplane_downtime', 1)) | ||
| acceptable_downtime, actual_downtime = validate_rx_tx_counters( | ||
| pdp, end_time, start_time, exp_mask, _get_max_time('dataplane_downtime', 1) | ||
| ) | ||
| if not acceptable_downtime: | ||
| pytest.fail(f"Dataplane downtime is too high, threshold is {_get_max_time('dataplane_downtime', 1)} seconds") | ||
| pytest.fail( | ||
| f"Dataplane downtime is too high: actual {actual_downtime:.4f} seconds, " | ||
| f"threshold is {_get_max_time('dataplane_downtime', 1)} seconds" | ||
| ) | ||
| if not result.get("converged"): | ||
| pytest.fail("BGP routes are not stable in long time") | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.