Skip to content

Commit

Permalink
[muxorch] Adding case for maintaining current state (sonic-net#2280)
Browse files Browse the repository at this point in the history
* [muxorch] Adding case for maintaining current state

What I did:
Added a case where if current and previous Mux states are the same, post a log entry that acknowleges this change and returns without doing anything.
  • Loading branch information
Ndancejic authored Dec 6, 2022
1 parent 6b6dda6 commit bd652a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 9 additions & 3 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,19 @@ void MuxCable::setState(string new_state)
new_state = muxStateValToString.at(ns);

auto it = muxStateTransition.find(make_pair(state_, ns));

if (it == muxStateTransition.end())
{
// Update HW Mux cable state anyways
mux_cb_orch_->updateMuxState(mux_name_, new_state);
SWSS_LOG_ERROR("State transition from %s to %s is not-handled ",
muxStateValToString.at(state_).c_str(), new_state.c_str());
if (strcmp(new_state.c_str(), muxStateValToString.at(state_).c_str()) == 0)
{
SWSS_LOG_NOTICE("[%s] Maintaining current MUX state", mux_name_.c_str());
}
else
{
SWSS_LOG_ERROR("State transition from %s to %s is not-handled ",
muxStateValToString.at(state_).c_str(), new_state.c_str());
}
return;
}

Expand Down
15 changes: 14 additions & 1 deletion tests/test_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ class TestMuxTunnelBase():
TC_TO_QUEUE_MAP = {str(i):str(i) for i in range(0, 8)}
DSCP_TO_TC_MAP = {str(i):str(1) for i in range(0, 64)}
TC_TO_PRIORITY_GROUP_MAP = {str(i):str(i) for i in range(0, 8)}


def check_syslog(self, dvs, marker, err_log, expected_cnt):
(exitcode, num) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \"%s\" | wc -l" % (marker, err_log)])
assert num.strip() >= str(expected_cnt)

def create_vlan_interface(self, dvs):
confdb = dvs.get_config_db()

Expand Down Expand Up @@ -309,6 +313,15 @@ def create_and_test_neighbor(self, confdb, appdb, asicdb, dvs, dvs_route):
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV4)
self.check_neigh_in_asic_db(asicdb, self.SERV2_IPV6)

marker = dvs.add_log_marker()

self.set_mux_state(appdb, "Ethernet0", "active")
self.set_mux_state(appdb, "Ethernet0", "active")
self.check_syslog(dvs, marker, "Maintaining current MUX state", 1)

self.set_mux_state(appdb, "Ethernet0", "init")
self.check_syslog(dvs, marker, "State transition from active to init is not-handled", 1)

def create_and_test_fdb(self, appdb, asicdb, dvs, dvs_route):

self.set_mux_state(appdb, "Ethernet0", "active")
Expand Down

0 comments on commit bd652a0

Please sign in to comment.