diff --git a/orchagent/dash/dashhaorch.cpp b/orchagent/dash/dashhaorch.cpp index f123211e7a..52643cea4d 100644 --- a/orchagent/dash/dashhaorch.cpp +++ b/orchagent/dash/dashhaorch.cpp @@ -770,7 +770,8 @@ void DashHaOrch::updateHaScopeStateForSwitchOwner(const std::string &key, const ha_state = SAI_DASH_HA_STATE_DEAD; break; case dash::types::HA_ROLE_SWITCHING_TO_ACTIVE: - return; + ha_state = SAI_DASH_HA_STATE_INITIALIZING_TO_ACTIVE; + break; default: ha_state = SAI_DASH_HA_STATE_DEAD; } diff --git a/tests/mock_tests/dashhaorch_ut.cpp b/tests/mock_tests/dashhaorch_ut.cpp index 2a2d5003ae..ae305a7b45 100644 --- a/tests/mock_tests/dashhaorch_ut.cpp +++ b/tests/mock_tests/dashhaorch_ut.cpp @@ -1255,6 +1255,25 @@ namespace dashhaorch_ut RemoveHaSet(); } + TEST_F(DashHaOrchTestSwitchOwner, SwitchOwnerSwitchingToActiveInitializesStateAndProcessesBfdSessions) + { + CreateSwitchOwnerDpuScopeHaSet(); + CreateHaScope(); + + CreateSoftwareBfdSession(); + EXPECT_EQ(m_mockBfdOrch->createSoftwareBfdSession_invoked_times, 0); + + SetHaScopeHaRole("switching_to_active"); + + auto& scope_entry = m_dashHaOrch->getHaScopeEntries().find("HA_SET_1")->second; + EXPECT_EQ(scope_entry.ha_state, SAI_DASH_HA_STATE_INITIALIZING_TO_ACTIVE); + EXPECT_EQ(to_sai(scope_entry.metadata.ha_role()), SAI_DASH_HA_ROLE_SWITCHING_TO_ACTIVE); + EXPECT_EQ(m_mockBfdOrch->createSoftwareBfdSession_invoked_times, 1); + + RemoveHaScope(); + RemoveHaSet(); + } + TEST_F(DashHaOrchTest, DpuOwnerSetRoleDoesNotUpdateState) { // DPU owner (default CreateHaSet uses "dpu" owner)