Skip to content

Commit

Permalink
Add a config reload command to create an initial config for L2 mode.
Browse files Browse the repository at this point in the history
Step 1 in L2 config wiki actually serve the purpose of remove existing
minigraph config except for those that are absolutely necessary. We
should not skip that.
  • Loading branch information
hdwhdw committed Oct 10, 2024
1 parent 2f64840 commit 47d615f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/l2/test_l2_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ def test_l2_config_and_upgrade(request, duthosts, rand_one_dut_hostname, localho
# Save original config
duthost.shell("sudo cp {} {}".format(CONFIG_DB, CONFIG_DB_BAK))
# Perform L2 configuration
mgmt_fact = duthost.get_extended_minigraph_facts()["minigraph_mgmt_interface"]
init_cfg = '''
cat <<EOF | sudo config reload /dev/stdin -y
{{
"MGMT_INTERFACE": {{
"eth0|{}/{}": {{
"gwaddr": "{}"
}}
}},
"DEVICE_METADATA": {{
"localhost": {{
"hostname": "{}"
}}
}}
}}
EOF
'''.format(mgmt_fact["addr"], mgmt_fact["prefixlen"], mgmt_fact["gwaddr"], duthost.hostname)
duthost.shell(init_cfg)
l2_cfg = "sudo sonic-cfggen --preset l2 -p -H -k {}" \
" | sudo config load /dev/stdin -y".format(hwsku)
duthost.shell(l2_cfg)
Expand All @@ -71,7 +89,7 @@ def test_l2_config_and_upgrade(request, duthosts, rand_one_dut_hostname, localho

# Step 4: Verifies no config fro minigraph is written into ConfigDB.
try:
for table in ["TELEMETRY", "RESTAPI", "DEVICE_METADATA"]:
for table in ["TELEMETRY", "RESTAPI"]:
count = int(duthost.shell('sonic-db-cli CONFIG_DB KEYS "{}|* | wc -l'.format(table))['stdout'])
pytest_assert(count == 0, "{} table is not empty!".format(table))
except Exception:
Expand Down

0 comments on commit 47d615f

Please sign in to comment.