Skip to content

Commit a70389c

Browse files
rkavitha-hclBibhuprasad Singh
authored and
Bibhuprasad Singh
committed
Integrated tests for cold and warm reboot in rebootbackend
1 parent 3f52aef commit a70389c

File tree

5 files changed

+940
-1
lines changed

5 files changed

+940
-1
lines changed

src/sonic-framework/rebootbackend/rebootbe.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "reboot_interfaces.h"
1515
#include "select.h"
1616
#include "status_code_util.h"
17+
#include "warm_restart.h"
1718

1819
namespace rebootbackend {
1920

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

3132
RebootBE::RebManagerStatus RebootBE::GetCurrentStatus() {
32-
const std::lock_guard<std::mutex> lock(m_StatusMutex);
3333
return m_CurrentStatus;
3434
}
3535

@@ -41,12 +41,21 @@ void RebootBE::SetCurrentStatus(RebManagerStatus newStatus) {
4141
void RebootBE::Start() {
4242
SWSS_LOG_ENTER();
4343
SWSS_LOG_NOTICE("--- Starting rebootbackend ---");
44+
swss::WarmStart::initialize("rebootbackend", "sonic-framework");
45+
swss::WarmStart::checkWarmStart("rebootbackend", "sonic-framework",
46+
/*incr_restore_cnt=*/false);
4447

4548
swss::Select s;
4649
s.addSelectable(&m_NotificationConsumer);
4750
s.addSelectable(&m_Done);
4851
s.addSelectable(&m_RebootThreadFinished);
4952

53+
if (swss::WarmStart::isWarmStart()) {
54+
SetCurrentStatus(RebManagerStatus::WARM_INIT_WAIT);
55+
} else {
56+
SWSS_LOG_NOTICE("Warm restart not enabled");
57+
}
58+
5059
SWSS_LOG_NOTICE("RebootBE entering operational loop");
5160
while (true) {
5261
swss::Selectable *sel;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
#include <gmock/gmock.h>
3+
4+
#include "reboot_interfaces.h"
5+
#include "selectableevent.h"
6+
#include "system/system.pb.h"
7+
8+
namespace rebootbackend {
9+
10+
class MockDbusInterface : public DbusInterface {
11+
public:
12+
MOCK_METHOD(DbusInterface::DbusResponse, Reboot, (const std::string &),
13+
(override));
14+
MOCK_METHOD(DbusInterface::DbusResponse, RebootStatus, (const std::string &),
15+
(override));
16+
};
17+
18+
} // namespace rebootbackend

0 commit comments

Comments
 (0)