Skip to content

Commit

Permalink
Merge branch 'sonic-net:202205' into 202205
Browse files Browse the repository at this point in the history
  • Loading branch information
vadymhlushko-mlnx authored Aug 21, 2023
2 parents 64de182 + 3e2974d commit a8d677f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
16 changes: 13 additions & 3 deletions orchagent/muxorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "routeorch.h"
#include "fdborch.h"
#include "qosorch.h"
#include "warm_restart.h"

/* Global variables */
extern Directory<Orch*> gDirectory;
Expand Down Expand Up @@ -416,9 +417,18 @@ MuxCable::MuxCable(string name, IpPrefix& srv_ip4, IpPrefix& srv_ip6, IpAddress
state_machine_handlers_.insert(handler_pair(MUX_STATE_INIT_STANDBY, &MuxCable::stateStandby));
state_machine_handlers_.insert(handler_pair(MUX_STATE_ACTIVE_STANDBY, &MuxCable::stateStandby));

/* Set initial state to "standby" */
stateStandby();
state_ = MuxState::MUX_STATE_STANDBY;
if (WarmStart::isWarmStart()) {
/* Warmboot case, Set initial state to "init"
* State will be updated to previous value upon APP DB sync
*/
state_ = MuxState::MUX_STATE_INIT;
}
else
{
/* Set initial state to "standby" */
stateStandby();
state_ = MuxState::MUX_STATE_STANDBY;
}
}

bool MuxCable::stateInitActive()
Expand Down
37 changes: 37 additions & 0 deletions tests/test_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,43 @@ def test_soc_ip(self, dvs, dvs_route, setup_vlan, setup_mux_cable, testlog):

self.create_and_test_soc(appdb, asicdb, dvs, dvs_route)

def test_warm_boot_mux_state(
self, dvs, dvs_route, setup_vlan, setup_mux_cable, setup_tunnel,
remove_peer_switch, neighbor_cleanup, testlog
):
"""
test mux initialization during warm boot.
"""
appdb = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)
apdb = dvs.get_app_db()

self.set_mux_state(appdb, "Ethernet0", "active")
self.set_mux_state(appdb, "Ethernet4", "active")
self.set_mux_state(appdb, "Ethernet8", "standby")

# Execute the warm reboot
dvs.runcmd("config warm_restart enable swss")
dvs.stop_swss()
dvs.start_swss()

time.sleep(5)

fvs = apdb.get_entry(self.APP_MUX_CABLE, "Ethernet0")
for key in fvs:
if key == "state":
assert fvs[key] == "active", "Ethernet0 Mux state is not active after warm boot, state: {}".format(fvs[key])

fvs = apdb.get_entry(self.APP_MUX_CABLE, "Ethernet4")
for key in fvs:
if key == "state":
assert fvs[key] == "active", "Ethernet4 Mux state is not active after warm boot, state: {}".format(fvs[key])

fvs = apdb.get_entry(self.APP_MUX_CABLE, "Ethernet8")
for key in fvs:
if key == "state":
assert fvs[key] == "standby", "Ethernet8 Mux state is not standby after warm boot, state: {}".format(fvs[key])


# Add Dummy always-pass test at end as workaroud
# for issue when Flaky fail on final test it invokes module tear-down before retrying
def test_nonflaky_dummy():
Expand Down

0 comments on commit a8d677f

Please sign in to comment.