From bd652a0406724445e5b7d3a2ec96b0482a2d2c99 Mon Sep 17 00:00:00 2001 From: Nikola Dancejic <26731235+Ndancejic@users.noreply.github.com> Date: Mon, 5 Dec 2022 16:55:53 -0800 Subject: [PATCH] [muxorch] Adding case for maintaining current state (#2280) * [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. --- orchagent/muxorch.cpp | 12 +++++++++--- tests/test_mux.py | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/orchagent/muxorch.cpp b/orchagent/muxorch.cpp index 449778794e40..623fd6342dc0 100644 --- a/orchagent/muxorch.cpp +++ b/orchagent/muxorch.cpp @@ -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; } diff --git a/tests/test_mux.py b/tests/test_mux.py index dc739b82a651..e8bae7fd1bd7 100644 --- a/tests/test_mux.py +++ b/tests/test_mux.py @@ -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() @@ -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")