Skip to content

Commit a6cce68

Browse files
authored
Pre-commit errors fixed and Replaced noqa with noqa: in tests/dualtor_mgmt (#18746)
1 parent f99ae47 commit a6cce68

File tree

5 files changed

+61
-57
lines changed

5 files changed

+61
-57
lines changed

tests/dualtor_mgmt/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22

33
from tests.common.helpers.assertions import pytest_require as py_require
4-
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa F401
5-
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa F401
4+
from tests.common.fixtures.ptfhost_utils import change_mac_addresses # noqa: F401
5+
from tests.common.fixtures.ptfhost_utils import run_garp_service # noqa: F401
66

77

88
def pytest_configure(config):

tests/dualtor_mgmt/test_egress_drop_nvidia.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import ptf.packet as scapy
55
import json
66
from tests.common.helpers.assertions import pytest_assert
7-
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor # noqa F401
8-
from tests.common.dualtor.mux_simulator_control import toggle_simulator_port_to_lower_tor # noqa F401
7+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_upper_tor # noqa: F401
8+
from tests.common.dualtor.mux_simulator_control import toggle_simulator_port_to_lower_tor # noqa: F401
99
from tests.common.dualtor.dual_tor_utils import \
10-
upper_tor_host, lower_tor_host, dualtor_info, check_muxcable_status # noqa F401
11-
from tests.common.fixtures.ptfhost_utils import change_mac_addresses, run_icmp_responder, run_garp_service # noqa F401
12-
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor # noqa F401
10+
upper_tor_host, lower_tor_host, dualtor_info, check_muxcable_status # noqa: F401
11+
from tests.common.fixtures.ptfhost_utils import change_mac_addresses, run_icmp_responder, run_garp_service # noqa: F401
12+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_rand_selected_tor # noqa: F401
1313
from ptf.mask import Mask
1414
from ptf import testutils
1515
from tests.common.utilities import wait_until
@@ -31,9 +31,10 @@
3131
# These two test cases are to cover the test gap introduced by the egress drop.
3232

3333

34-
def test_egress_drop_standby_server_to_active_server(ptfhost, upper_tor_host, lower_tor_host, # noqa F811
35-
toggle_all_simulator_ports_to_upper_tor, # noqa F811
36-
toggle_simulator_port_to_lower_tor, tbinfo, ptfadapter): # noqa F811
34+
def test_egress_drop_standby_server_to_active_server(ptfhost, upper_tor_host, lower_tor_host, # noqa: F811
35+
toggle_all_simulator_ports_to_upper_tor, # noqa: F811
36+
toggle_simulator_port_to_lower_tor, # noqa: F811
37+
tbinfo, ptfadapter): # noqa: F811
3738
"""
3839
This test case covers the validation of egress drop rule in active-standby dualtor scenario when server A is active
3940
on the upper tor and standby on the lower tor, server B is standby on the upper tor and active on the lower tor, and
@@ -131,8 +132,11 @@ def _check_counters():
131132
and COUNTER_RANGE[0] <= lower_tor_active_port_tx_counter < COUNTER_RANGE[1])
132133
pytest_assert(wait_until(15, 5, 0, _check_counters), "The port counters are not as expected.")
133134

134-
def test_egress_drop_standby_server_to_standby_server(ptfhost, upper_tor_host, lower_tor_host, # noqa F811
135-
toggle_all_simulator_ports_to_upper_tor, tbinfo, ptfadapter): # noqa F811
135+
136+
def test_egress_drop_standby_server_to_standby_server(ptfhost, upper_tor_host, # noqa: F811
137+
lower_tor_host, # noqa: F811
138+
toggle_all_simulator_ports_to_upper_tor, # noqa: F811
139+
tbinfo, ptfadapter):
136140
"""
137141
This test case covers the validation of egress drop rule in active-standby dualtor scenario when server A and
138142
server B are active on the upper tor, and standby on the lower tor, and the upstream traffic is sent from
@@ -192,7 +196,7 @@ def test_egress_drop_standby_server_to_standby_server(ptfhost, upper_tor_host, l
192196
eth_src=lower_tor_host.facts['router_mac'],
193197
ip_src=lower_tor_loopback0_ip,
194198
ip_dst=upper_tor_loopback0_ip,
195-
inner_frame=pkt[IP]) # noqa F821
199+
inner_frame=pkt[IP]) # noqa: F821
196200
not_expected_tunnel_pkt = get_masked_packet(tunnel_pkt, is_tunnel_packet=True)
197201
# Send packets again
198202
ptfadapter.dataplane.flush()

tests/dualtor_mgmt/test_grpc_periodical_sync.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
import random
66
import time
77

8-
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
8+
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa: F401
99
from tests.common.dualtor.dual_tor_common import ActiveActivePortID
10-
from tests.common.dualtor.dual_tor_utils import upper_tor_host # noqa F401
11-
from tests.common.dualtor.dual_tor_utils import lower_tor_host # noqa F401
12-
from tests.common.dualtor.icmp_responder_control import pause_icmp_responder # noqa F401
10+
from tests.common.dualtor.dual_tor_utils import upper_tor_host # noqa: F401
11+
from tests.common.dualtor.dual_tor_utils import lower_tor_host # noqa: F401
12+
from tests.common.dualtor.icmp_responder_control import pause_icmp_responder # noqa: F401
1313
from tests.common.dualtor.nic_simulator_control import ForwardingState
14-
from tests.common.dualtor.nic_simulator_control import mux_status_from_nic_simulator # noqa F401
15-
from tests.common.dualtor.nic_simulator_control import toggle_active_active_simulator_ports # noqa F401
16-
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
14+
from tests.common.dualtor.nic_simulator_control import mux_status_from_nic_simulator # noqa: F401
15+
from tests.common.dualtor.nic_simulator_control import toggle_active_active_simulator_ports # noqa: F401
16+
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa: F401
1717

1818
from tests.common.helpers.assertions import pytest_assert
1919
from tests.common.utilities import wait_until
@@ -26,7 +26,7 @@
2626

2727

2828
@pytest.fixture(scope="module")
29-
def test_duthost(upper_tor_host, lower_tor_host): # noqa F811
29+
def test_duthost(upper_tor_host, lower_tor_host): # noqa: F811
3030
today = datetime.datetime.fromtimestamp(time.time())
3131
if today.day % 2 == 1:
3232
duthost = upper_tor_host
@@ -38,7 +38,7 @@ def test_duthost(upper_tor_host, lower_tor_host): # noqa F811
3838

3939

4040
@pytest.fixture(scope="module")
41-
def test_mux_ports(active_active_ports): # noqa F811
41+
def test_mux_ports(active_active_ports): # noqa: F811
4242
if not active_active_ports:
4343
pytest.skip("Skip as no 'active-active' mux ports available")
4444
test_ports = random.sample(active_active_ports, min(len(active_active_ports), TEST_COUNT))
@@ -52,8 +52,8 @@ def init_port_state(request):
5252

5353

5454
@pytest.fixture
55-
def setup_test_ports(init_port_state, mux_status_from_nic_simulator, # noqa F811
56-
pause_icmp_responder, test_mux_ports): # noqa F811
55+
def setup_test_ports(init_port_state, mux_status_from_nic_simulator, # noqa: F811
56+
pause_icmp_responder, test_mux_ports): # noqa: F811
5757

5858
def check_forwarding_state(mux_ports, upper_tor_forwarding_state, lower_tor_forwarding_state):
5959
mux_status = mux_status_from_nic_simulator(mux_ports)
@@ -89,7 +89,7 @@ def get_mux_status(duthost, mux_ports):
8989

9090

9191
def test_grpc_server_failure(init_port_state, setup_test_ports, test_duthost,
92-
toggle_active_active_simulator_ports): # noqa F811
92+
toggle_active_active_simulator_ports): # noqa: F811
9393
"""
9494
This testcase aims to verify that, if the nic_simulator arbitrarily toggles a
9595
port, SONiC could detect and recover the mux status.
@@ -135,7 +135,7 @@ def check_mux_status_recovery(duthost, mux_ports, orig_mux_status):
135135
@pytest.mark.skip_active_standby
136136
@pytest.mark.parametrize("mux_status", ["standby", "active"])
137137
def test_mux_forwarding_state_consistency(mux_status, test_mux_ports, test_duthost,
138-
toggle_active_active_simulator_ports): # noqa F811
138+
toggle_active_active_simulator_ports): # noqa: F811
139139
"""
140140
This testcase aims to verify that, if the nic_simulator forwarding state changes incorrectly,
141141
SONiC could detect and recover the mux status.

tests/dualtor_mgmt/test_ingress_drop.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
import pytest
44
import random
55

6-
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
7-
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa F401
6+
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa: F401
7+
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa: F401
88
from tests.common.dualtor.dual_tor_common import ActiveActivePortID
9-
from tests.common.dualtor.dual_tor_common import cable_type # noqa F401
9+
from tests.common.dualtor.dual_tor_common import cable_type # noqa: F401
1010
from tests.common.dualtor.dual_tor_common import CableType
11-
from tests.common.dualtor.dual_tor_utils import upper_tor_host # noqa F401
12-
from tests.common.dualtor.dual_tor_utils import lower_tor_host # noqa F401
11+
from tests.common.dualtor.dual_tor_utils import upper_tor_host # noqa: F401
12+
from tests.common.dualtor.dual_tor_utils import lower_tor_host # noqa: F401
1313
from tests.common.dualtor.dual_tor_utils import verify_upstream_traffic
14-
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_lower_tor # noqa F401
14+
from tests.common.dualtor.mux_simulator_control import toggle_all_simulator_ports_to_lower_tor # noqa: F401
1515
from tests.common.dualtor.nic_simulator_control import ForwardingState
16-
from tests.common.dualtor.nic_simulator_control import mux_status_from_nic_simulator # noqa F401
17-
from tests.common.dualtor.nic_simulator_control import stop_nic_simulator # noqa F401
18-
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa F401
16+
from tests.common.dualtor.nic_simulator_control import mux_status_from_nic_simulator # noqa: F401
17+
from tests.common.dualtor.nic_simulator_control import stop_nic_simulator # noqa: F401
18+
from tests.common.fixtures.ptfhost_utils import run_icmp_responder # noqa: F401
1919
from tests.common.helpers.assertions import pytest_assert
2020
from tests.common.utilities import wait_until
2121

@@ -27,11 +27,11 @@
2727

2828
@pytest.fixture
2929
def setup_mux(
30-
active_active_ports, cable_type, # noqa F811
31-
mux_status_from_nic_simulator, # noqa F811
32-
stop_nic_simulator, # noqa F811
33-
toggle_all_simulator_ports_to_lower_tor, # noqa F811
34-
upper_tor_host, lower_tor_host # noqa F811
30+
active_active_ports, cable_type, # noqa: F811
31+
mux_status_from_nic_simulator, # noqa: F811
32+
stop_nic_simulator, # noqa: F811
33+
toggle_all_simulator_ports_to_lower_tor, # noqa: F811
34+
upper_tor_host, lower_tor_host # noqa: F811
3535
):
3636

3737
def _check_active_active_mux_status_from_nic_simulator(upper_tor_forwarding_state, lower_tor_forwarding_state):
@@ -91,7 +91,7 @@ def _restore_mux_config_auto():
9191

9292

9393
@pytest.fixture
94-
def selected_mux_port(cable_type, active_active_ports, active_standby_ports): # noqa F811
94+
def selected_mux_port(cable_type, active_active_ports, active_standby_ports): # noqa: F811
9595
all_ports = []
9696
if cable_type == CableType.active_active:
9797
all_ports = active_active_ports
@@ -102,7 +102,7 @@ def selected_mux_port(cable_type, active_active_ports, active_standby_ports):
102102

103103

104104
@pytest.mark.enable_active_active
105-
def test_ingress_drop(cable_type, ptfadapter, setup_mux, tbinfo, selected_mux_port, upper_tor_host): # noqa F811
105+
def test_ingress_drop(cable_type, ptfadapter, setup_mux, tbinfo, selected_mux_port, upper_tor_host): # noqa: F811
106106
"""
107107
Aims to verify if orchagent installs ingress drop ACL when the port comes to standby.
108108

tests/dualtor_mgmt/test_server_failure.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
from tests.common.dualtor.mux_simulator_control import toggle_simulator_port_to_upper_tor, \
66
simulator_flap_counter, simulator_server_down, \
7-
toggle_all_simulator_ports # noqa F401
7+
toggle_all_simulator_ports # noqa: F401
88
from tests.common.helpers.assertions import pytest_assert
99
from tests.common.dualtor.dual_tor_utils import show_muxcable_status # noqa: F401
10-
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa F401
11-
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa F401
12-
from tests.common.dualtor.dual_tor_common import cable_type # noqa F401
10+
from tests.common.dualtor.dual_tor_common import active_active_ports # noqa: F401
11+
from tests.common.dualtor.dual_tor_common import active_standby_ports # noqa: F401
12+
from tests.common.dualtor.dual_tor_common import cable_type # noqa: F401
1313
from tests.common.dualtor.dual_tor_common import CableType
14-
from tests.common.dualtor.dual_tor_utils import validate_active_active_dualtor_setup # noqa F401
15-
from tests.common.dualtor.dual_tor_utils import upper_tor_host # noqa F401
16-
from tests.common.dualtor.dual_tor_utils import lower_tor_host # noqa F401
17-
from tests.common.dualtor.dual_tor_utils import lower_tor_fanouthosts, fanout_lower_tor_port_control # noqa F401
18-
from tests.common.dualtor.dual_tor_utils import upper_tor_fanouthosts, fanout_upper_tor_port_control # noqa F401
19-
from tests.common.dualtor.dual_tor_utils import show_muxcable_status # noqa F401
20-
from tests.common.dualtor.nic_simulator_control import simulator_server_down_active_active # noqa F401
14+
from tests.common.dualtor.dual_tor_utils import validate_active_active_dualtor_setup # noqa: F401
15+
from tests.common.dualtor.dual_tor_utils import upper_tor_host # noqa: F401
16+
from tests.common.dualtor.dual_tor_utils import lower_tor_host # noqa: F401
17+
from tests.common.dualtor.dual_tor_utils import lower_tor_fanouthosts, fanout_lower_tor_port_control # noqa: F401
18+
from tests.common.dualtor.dual_tor_utils import upper_tor_fanouthosts, fanout_upper_tor_port_control # noqa: F401
19+
from tests.common.dualtor.dual_tor_utils import show_muxcable_status # noqa: F401, F811
20+
from tests.common.dualtor.nic_simulator_control import simulator_server_down_active_active # noqa: F401
2121
from tests.common.fixtures.ptfhost_utils import change_mac_addresses, run_garp_service, \
2222
run_icmp_responder # noqa: F401
2323
from tests.common.utilities import wait_until
@@ -34,10 +34,10 @@
3434

3535

3636
@pytest.mark.enable_active_active
37-
def test_server_down(cable_type, duthosts, tbinfo, active_active_ports, active_standby_ports, # noqa F811
38-
simulator_flap_counter, simulator_server_down, toggle_simulator_port_to_upper_tor, # noqa F811
39-
loganalyzer, validate_active_active_dualtor_setup, upper_tor_host, lower_tor_host, # noqa F811
40-
simulator_server_down_active_active): # noqa F811
37+
def test_server_down(cable_type, duthosts, tbinfo, active_active_ports, active_standby_ports, # noqa: F811
38+
simulator_flap_counter, simulator_server_down, toggle_simulator_port_to_upper_tor, # noqa: F811
39+
loganalyzer, validate_active_active_dualtor_setup, upper_tor_host, lower_tor_host, # noqa: F811
40+
simulator_server_down_active_active): # noqa: F811
4141
"""
4242
Verify that mux cable is not toggled excessively.
4343
"""

0 commit comments

Comments
 (0)