Skip to content

Commit

Permalink
Update test_pretest to inject mux_simulator.json for simulated y_cabl…
Browse files Browse the repository at this point in the history
…e driver (#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 <xiwang5@microsoft.com>
  • Loading branch information
wangxin authored Aug 25, 2021
1 parent 41e652f commit 542f0c1
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tests/test_pretest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from collections import defaultdict

from jinja2 import Template
from common.helpers.assertions import pytest_require
from tests.common.helpers.assertions import pytest_require
from tests.common.dualtor.constants import UPPER_TOR, LOWER_TOR

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -141,8 +142,8 @@ def collect_dut_lossless_prio(dut):
if 'pfc_enable' not in port_qos_map[intf]:
return []

result = [int(x) for x in port_qos_map[intf]['pfc_enable'].split(',')]
return result
result = [int(x) for x in port_qos_map[intf]['pfc_enable'].split(',')]
return result

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

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

Expand Down Expand Up @@ -240,6 +241,22 @@ def test_inject_y_cable_simulator_client(duthosts, enum_dut_hostname, tbinfo):
dut.copy(content=rendered, dest='/tmp/y_cable_simulator_client.py')
dut.shell('cp /tmp/y_cable_simulator_client.py /usr/lib/python3/dist-packages/')
dut.shell('docker cp /tmp/y_cable_simulator_client.py pmon:/usr/lib/python3/dist-packages/')

# Below changes are required after these PRs are merged:
# * https://github.com/Azure/sonic-platform-common/pull/213
# * https://github.com/Azure/sonic-platform-daemons/pull/197
# For the simulated y_cable driver to work, basic configuration information of the mux simulator is required.
# When /etc/sonic/mux_simulator.json file is found on DUT, xcvrd will try to load simulated y_cable driver.
# File /etc/sonic/mux_simulator.json can co-exist with the 'y_cable_simulator_client.py' file injected above.
# Process xcvrd will determine which one to load or use.
mux_simulator_config = {
'server_ip': mux_simulator_server,
'server_port': mux_simulator_port,
'vm_set': tbinfo['group-name'],
'side': UPPER_TOR if tbinfo['duts'].index(enum_dut_hostname) == 0 else LOWER_TOR
}
dut.copy(content=json.dumps(mux_simulator_config, indent=2), dest='/etc/sonic/mux_simulator.json')

dut.shell('systemctl restart pmon')

def test_stop_pfcwd(duthosts, enum_dut_hostname, tbinfo):
Expand Down

0 comments on commit 542f0c1

Please sign in to comment.