Skip to content

Commit 1e7d321

Browse files
wangxinvmittal-msft
authored andcommitted
Update test_pretest to inject mux_simulator.json for simulated y_cable driver (sonic-net#4106)
What is the motivation for this PR? The simulated y_cable driver needs configurations of the mux simulator to work. Process xcvrd in pmon will try to load simulated y_cable driver if /etc/sonic/mux_simulator.json is found on DUT. How did you do it? This change updated the test_pretest.py script to inject /etc/sonic/mux_simulator.json to DUT. This change can co-exist with the code for injecting 'y_cable_simulator_client.py' to DUT. Process xcvrd will decide which one to load. How did you verify/test it? Use run_tests.sh to run decap/test_decap.py on dual ToR testbed without skipping pretest. Any platform specific information? Dual ToR only. Signed-off-by: Xin Wang <[email protected]>
1 parent 257308a commit 1e7d321

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

tests/test_pretest.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from collections import defaultdict
99

1010
from jinja2 import Template
11-
from common.helpers.assertions import pytest_require
11+
from tests.common.helpers.assertions import pytest_require
12+
from tests.common.dualtor.constants import UPPER_TOR, LOWER_TOR
1213

1314
logger = logging.getLogger(__name__)
1415

@@ -141,8 +142,8 @@ def collect_dut_lossless_prio(dut):
141142
if 'pfc_enable' not in port_qos_map[intf]:
142143
return []
143144

144-
result = [int(x) for x in port_qos_map[intf]['pfc_enable'].split(',')]
145-
return result
145+
result = [int(x) for x in port_qos_map[intf]['pfc_enable'].split(',')]
146+
return result
146147

147148
def collect_dut_all_prio(dut):
148149
config_facts = dut.config_facts(host=dut.hostname, source="running")['ansible_facts']
@@ -178,7 +179,7 @@ def test_collect_testbed_prio(duthosts, tbinfo):
178179
lossless_prio[dut.hostname] = collect_dut_lossless_prio(dut)
179180
lossy_prio[dut.hostname] = collect_dut_lossy_prio(dut)
180181

181-
prio_info = [all_prio, lossless_prio, lossy_prio]
182+
prio_info = [all_prio, lossless_prio, lossy_prio]
182183
file_names = [tbname + '-' + x + '.json' for x in ['all', 'lossless', 'lossy']]
183184
folder = 'priority'
184185

@@ -240,6 +241,22 @@ def test_inject_y_cable_simulator_client(duthosts, enum_dut_hostname, tbinfo):
240241
dut.copy(content=rendered, dest='/tmp/y_cable_simulator_client.py')
241242
dut.shell('cp /tmp/y_cable_simulator_client.py /usr/lib/python3/dist-packages/')
242243
dut.shell('docker cp /tmp/y_cable_simulator_client.py pmon:/usr/lib/python3/dist-packages/')
244+
245+
# Below changes are required after these PRs are merged:
246+
# * https://github.com/Azure/sonic-platform-common/pull/213
247+
# * https://github.com/Azure/sonic-platform-daemons/pull/197
248+
# For the simulated y_cable driver to work, basic configuration information of the mux simulator is required.
249+
# When /etc/sonic/mux_simulator.json file is found on DUT, xcvrd will try to load simulated y_cable driver.
250+
# File /etc/sonic/mux_simulator.json can co-exist with the 'y_cable_simulator_client.py' file injected above.
251+
# Process xcvrd will determine which one to load or use.
252+
mux_simulator_config = {
253+
'server_ip': mux_simulator_server,
254+
'server_port': mux_simulator_port,
255+
'vm_set': tbinfo['group-name'],
256+
'side': UPPER_TOR if tbinfo['duts'].index(enum_dut_hostname) == 0 else LOWER_TOR
257+
}
258+
dut.copy(content=json.dumps(mux_simulator_config, indent=2), dest='/etc/sonic/mux_simulator.json')
259+
243260
dut.shell('systemctl restart pmon')
244261

245262
def test_stop_pfcwd(duthosts, enum_dut_hostname, tbinfo):

0 commit comments

Comments
 (0)