Skip to content

Commit

Permalink
Improve PortsOrch::doPortTask() (sonic-net#566)
Browse files Browse the repository at this point in the history
* Simplify PortsOrch::doPortTask
* Revert "Simplify PortsOrch::doPortTask", but keep unit test
* Fix handling m_autoneg, speed, mtu, admin_status, fec_mode before PortConfigDone
* Refine unit test with swsscommon.ProducerStateTable
  • Loading branch information
qiluo-msft authored Aug 8, 2018
1 parent b1cf199 commit 0dd1769
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,7 +1353,8 @@ void PortsOrch::doPortTask(Consumer &consumer)

if (!m_portConfigDone)
{
it = consumer.m_toSync.erase(it);
// Not yet receive PortConfigDone. Save it for future retry
it++;
continue;
}

Expand Down
60 changes: 60 additions & 0 deletions tests/test_port.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,63 @@ def test_PortNotification(dvs):
break

assert oper_status == "up"

def test_PortFec(dvs):

dvs.runcmd("ifconfig Ethernet0 10.0.0.0/31 up") == 0
dvs.runcmd("ifconfig Ethernet4 10.0.0.2/31 up") == 0

dvs.servers[0].runcmd("ip link set down dev eth0") == 0

time.sleep(1)

db = swsscommon.DBConnector(0, dvs.redis_sock, 0)
adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)

tbl = swsscommon.Table(db, "PORT_TABLE")
ptbl = swsscommon.ProducerStateTable(db, "PORT_TABLE")
atbl = swsscommon.Table(adb, "ASIC_STATE:SAI_OBJECT_TYPE_PORT")

(status, fvs) = tbl.get("Ethernet0")

assert status == True

oper_status = "unknown"

for v in fvs:
if v[0] == "oper_status":
oper_status = v[1]
break

assert oper_status == "down"

dvs.servers[0].runcmd("ip link set up dev eth0") == 0

time.sleep(1)

(status, fvs) = tbl.get("Ethernet0")

assert status == True

oper_status = "unknown"

for v in fvs:
if v[0] == "oper_status":
oper_status = v[1]
break

assert oper_status == "up"

# set fec
fvs = swsscommon.FieldValuePairs([("fec","rs"), ("speed", "1000")])
ptbl.set("Ethernet0", fvs)

time.sleep(1)

# get fec
(status, fvs) = atbl.get(dvs.asicdb.portnamemap["Ethernet0"])
assert status == True

for fv in fvs:
if fv[0] == "SAI_PORT_ATTR_FEC_MODE":
assert fv[1] == "SAI_PORT_FEC_MODE_RS"

0 comments on commit 0dd1769

Please sign in to comment.