@@ -89,6 +89,34 @@ TEST_F(RebootStatusTest, TestGetStatus) {
89
89
EXPECT_EQ (0 , response.when ());
90
90
}
91
91
92
+ TEST_F (RebootStatusTest, TestGetWarmStatus) {
93
+ std::chrono::nanoseconds curr_ns = std::chrono::high_resolution_clock::now ().time_since_epoch ();
94
+
95
+ m_status.set_start_status (RebootMethod::WARM, " reboot because" );
96
+
97
+ RebootStatusResponse response = m_status.get_response ();
98
+ EXPECT_EQ (response.status ().status (),
99
+ RebootStatus_Status::RebootStatus_Status_STATUS_UNKNOWN);
100
+
101
+ m_status.set_completed_status (
102
+ RebootStatus_Status::RebootStatus_Status_STATUS_SUCCESS, " anything" );
103
+
104
+ response = m_status.get_response ();
105
+
106
+ // message should be empty while reboot is active
107
+ EXPECT_THAT (response.status ().message (), StrEq (" " ));
108
+
109
+ uint64_t reboot_ns = response.when ();
110
+ EXPECT_TRUE (reboot_ns > (uint64_t )curr_ns.count ());
111
+
112
+ m_status.set_inactive ();
113
+ response = m_status.get_response ();
114
+ EXPECT_THAT (response.status ().message (), StrEq (" anything" ));
115
+ EXPECT_EQ (response.status ().status (),
116
+ RebootStatus_Status::RebootStatus_Status_STATUS_SUCCESS);
117
+ EXPECT_EQ (0 , response.when ());
118
+ }
119
+
92
120
class RebootThreadTest : public ::testing::Test {
93
121
protected:
94
122
RebootThreadTest ()
@@ -263,7 +291,7 @@ TEST_F(RebootThreadTest, TestUnsupportedRebootType) {
263
291
" RebootThread: Start rx'd unsupported method" );
264
292
}
265
293
266
- TEST_F (RebootThreadTest, TestInvalidMethodfDoReboot ) {
294
+ TEST_F (RebootThreadTest, TestInvalidMethodDoReboot ) {
267
295
set_start_status (RebootMethod::POWERUP, " time to reboot" );
268
296
do_reboot ();
269
297
force_inactive ();
@@ -273,4 +301,41 @@ TEST_F(RebootThreadTest, TestInvalidMethodfDoReboot) {
273
301
IsStatus (RebootStatus_Status::RebootStatus_Status_STATUS_UNKNOWN, " " ));
274
302
}
275
303
304
+ TEST_F (RebootThreadTest, TestNoWarmIfNonRetriableFailure) {
305
+ set_start_status (RebootMethod::WARM, " time to reboot" );
306
+ set_completed_status (RebootStatus_Status::RebootStatus_Status_STATUS_FAILURE,
307
+ " failed to warm reboot" );
308
+ force_inactive ();
309
+
310
+ RebootRequest request;
311
+ request.set_method (RebootMethod::WARM);
312
+
313
+ NotificationResponse response = m_reboot_thread.Start (request);
314
+ EXPECT_EQ (response.status , swss::StatusCode::SWSS_RC_FAILED_PRECONDITION);
315
+ EXPECT_EQ (response.json_string ,
316
+ " RebootThread: last WARM reboot failed with non-retriable failure" );
317
+ }
318
+
319
+ TEST_F (RebootThreadTest, TestSigTermStartofDoReboot) {
320
+ sigterm_requested = true ;
321
+ set_start_status (RebootMethod::WARM, " time to reboot" );
322
+ do_reboot ();
323
+ force_inactive ();
324
+ RebootStatusResponse response = m_reboot_thread.GetResponse ();
325
+ EXPECT_THAT (
326
+ response,
327
+ IsStatus (RebootStatus_Status::RebootStatus_Status_STATUS_UNKNOWN, " " ));
328
+ }
329
+
330
+ TEST_F (RebootThreadTest, TestWaitForRebootPositive) {
331
+ overwrite_reboot_timeout (1 );
332
+ set_start_status (RebootMethod::WARM, " time to reboot" );
333
+ swss::Select s;
334
+ swss::SelectableEvent m_stop;
335
+ s.addSelectable (&m_stop);
336
+ RebootThread::Progress progress = wait_for_platform_reboot (s);
337
+ EXPECT_EQ (progress, RebootThread::Progress::PROCEED);
338
+ }
339
+
340
+
276
341
} // namespace rebootbackend
0 commit comments