Skip to content

Commit

Permalink
Integrated tests for cold and warm reboot in rebootbackend
Browse files Browse the repository at this point in the history
  • Loading branch information
rkavitha-hcl authored and Bibhuprasad Singh committed Feb 19, 2025
1 parent 3f52aef commit a70389c
Show file tree
Hide file tree
Showing 5 changed files with 940 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/sonic-framework/rebootbackend/rebootbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "reboot_interfaces.h"
#include "select.h"
#include "status_code_util.h"
#include "warm_restart.h"

namespace rebootbackend {

Expand All @@ -29,7 +30,6 @@ RebootBE::RebootBE(DbusInterface &dbus_interface)
}

RebootBE::RebManagerStatus RebootBE::GetCurrentStatus() {
const std::lock_guard<std::mutex> lock(m_StatusMutex);
return m_CurrentStatus;
}

Expand All @@ -41,12 +41,21 @@ void RebootBE::SetCurrentStatus(RebManagerStatus newStatus) {
void RebootBE::Start() {
SWSS_LOG_ENTER();
SWSS_LOG_NOTICE("--- Starting rebootbackend ---");
swss::WarmStart::initialize("rebootbackend", "sonic-framework");
swss::WarmStart::checkWarmStart("rebootbackend", "sonic-framework",
/*incr_restore_cnt=*/false);

swss::Select s;
s.addSelectable(&m_NotificationConsumer);
s.addSelectable(&m_Done);
s.addSelectable(&m_RebootThreadFinished);

if (swss::WarmStart::isWarmStart()) {
SetCurrentStatus(RebManagerStatus::WARM_INIT_WAIT);
} else {
SWSS_LOG_NOTICE("Warm restart not enabled");
}

SWSS_LOG_NOTICE("RebootBE entering operational loop");
while (true) {
swss::Selectable *sel;
Expand Down
18 changes: 18 additions & 0 deletions src/sonic-framework/tests/mock_reboot_interfaces.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include <gmock/gmock.h>

#include "reboot_interfaces.h"
#include "selectableevent.h"
#include "system/system.pb.h"

namespace rebootbackend {

class MockDbusInterface : public DbusInterface {
public:
MOCK_METHOD(DbusInterface::DbusResponse, Reboot, (const std::string &),
(override));
MOCK_METHOD(DbusInterface::DbusResponse, RebootStatus, (const std::string &),
(override));
};

} // namespace rebootbackend
Loading

0 comments on commit a70389c

Please sign in to comment.