Skip to content

Commit

Permalink
added multi-asic handling in sonic-cfggen
Browse files Browse the repository at this point in the history
  • Loading branch information
agadia-cisco authored Nov 14, 2024
1 parent 0c934e3 commit b918a0f
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions tests/gnmi/test_gnmi_configdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ def get_interface_status(duthost, field, interface='Ethernet0'):
return output["stdout"]


def get_sonic_cfggen_output(duthost, namespace=None):
'''
Fetch and return the sonic-cfggen output
'''
cmd = "sonic-cfggen -d --print-data"
if namespace:
cmd = f"sonic-cfggen -n {namespace} -d --print-data"
output = duthost.shell(cmd)
assert (not output['rc']), "No output"
return (json.loads(output["stdout"]))


def test_gnmi_configdb_incremental_01(duthosts, rand_one_dut_hostname, ptfhost):
'''
Verify GNMI native write, incremental config for configDB
Expand Down Expand Up @@ -224,12 +236,19 @@ def test_gnmi_configdb_full_01(duthosts, rand_one_dut_hostname, ptfhost):
Toggle interface admin status
'''
duthost = duthosts[rand_one_dut_hostname]
output = duthost.shell("sonic-cfggen -d --print-data")
assert (not output['rc']), "No output"
dic = json.loads(output["stdout"])
assert "PORT" in dic, "Failed to read running config"
interface = get_first_interface(duthost)
assert interface is not None, "Invalid interface"

# Get ASIC namespace and check interface
if duthost.sonichost.is_multi_asic:
for asic in duthost.frontend_asics:
dic = get_sonic_cfggen_output(duthost, asic.namespace)
if interface in dic["PORT"]:
break
else:
dic = get_sonic_cfggen_output(duthost)

assert "PORT" in dic, "Failed to read running config"
assert interface in dic["PORT"], "Failed to get interface %s" % interface
assert "admin_status" in dic["PORT"][interface], "Failed to get interface %s" % interface

Expand Down

0 comments on commit b918a0f

Please sign in to comment.