Skip to content

Commit 7a1a999

Browse files
authored
Merge pull request sonic-net#6 from mssonicbld/sonicbld/202506-merge
```<br>* 2094f30 - (HEAD -> 202506) Merge branch '202505' of https://github.com/sonic-net/sonic-host-services into 202506 (2025-08-09) [Sonic Automation] * 80b73bb - (origin/202505) [Smartswitch] Fix the values being set for reboot_status call during smartswitch DPU reboot (sonic-net#300) (2025-08-09) [mssonicbld]<br>```
2 parents 598cf31 + 2094f30 commit 7a1a999

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

host_modules/reboot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def populate_reboot_status_flag(self, active = False, when = 0, reason = "", met
6161
self.reboot_status_flag["reason"] = reason
6262
self.reboot_status_flag["count"] = self.reboot_count
6363
self.reboot_status_flag["method"] = method
64-
self.reboot_status_flag["status"] = status
64+
self.reboot_status_flag["status"] = status.value
6565
self.lock.release()
6666
return
6767

tests/host_modules/reboot_test.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,23 @@ def setup_class(cls):
5656
def test_populate_reboot_status_flag(self):
5757
with mock.patch("time.time", return_value=1617811205.25):
5858
self.reboot_module.populate_reboot_status_flag()
59-
assert self.reboot_module.reboot_status_flag["active"] == False
60-
assert self.reboot_module.reboot_status_flag["when"] == 0
61-
assert self.reboot_module.reboot_status_flag["reason"] == ""
62-
assert self.reboot_module.reboot_status_flag["count"] == 0
63-
assert self.reboot_module.reboot_status_flag["method"] == ""
64-
assert self.reboot_module.reboot_status_flag["status"] == RebootStatus.STATUS_UNKNOWN
59+
return_value, get_reboot_status_flag_data = self.reboot_module.get_reboot_status()
60+
assert return_value == 0
61+
get_reboot_status_flag_data = json.loads(get_reboot_status_flag_data)
62+
assert get_reboot_status_flag_data["active"] == False
63+
assert get_reboot_status_flag_data["when"] == 0
64+
assert get_reboot_status_flag_data["reason"] == ""
65+
assert get_reboot_status_flag_data["count"] == 0
66+
assert get_reboot_status_flag_data["method"] == ""
67+
assert get_reboot_status_flag_data["status"] == RebootStatus.STATUS_UNKNOWN.value
68+
69+
def test_populate_reboot_status_flag_with_status(self):
70+
with mock.patch("time.time", return_value=1617811205.25):
71+
self.reboot_module.populate_reboot_status_flag(status=RebootStatus.STATUS_SUCCESS)
72+
return_value, get_reboot_status_flag_data = self.reboot_module.get_reboot_status()
73+
assert return_value == 0
74+
get_reboot_status_flag_data = json.loads(get_reboot_status_flag_data)
75+
assert get_reboot_status_flag_data["status"] == RebootStatus.STATUS_SUCCESS.value
6576

6677
def test_validate_reboot_request_success_cold_boot_enum_method(self):
6778
reboot_request = {"method": REBOOT_METHOD_COLD_BOOT_ENUM, "reason": "test reboot request reason"}
@@ -344,26 +355,26 @@ def test_issue_reboot_fail_issue_reboot_thread(self):
344355

345356
def test_get_reboot_status_active(self):
346357
MSG="testing reboot response"
347-
self.reboot_module.populate_reboot_status_flag(True, TIME, MSG, REBOOT_METHOD_COLD_BOOT_ENUM, RebootStatus.STATUS_SUCCESS.name)
358+
self.reboot_module.populate_reboot_status_flag(True, TIME, MSG, REBOOT_METHOD_COLD_BOOT_ENUM, RebootStatus.STATUS_SUCCESS)
348359
result = self.reboot_module.get_reboot_status()
349360
assert result[0] == 0
350361
response_data = json.loads(result[1])
351362
assert response_data["active"] == True
352363
assert response_data["when"] == TIME
353364
assert response_data["reason"] == MSG
354365
assert response_data["method"] == REBOOT_METHOD_COLD_BOOT_ENUM
355-
assert response_data["status"] == RebootStatus.STATUS_SUCCESS.name
366+
assert response_data["status"] == RebootStatus.STATUS_SUCCESS.value
356367

357368
def test_get_reboot_status_inactive(self):
358-
self.reboot_module.populate_reboot_status_flag(False, 0, "", REBOOT_METHOD_COLD_BOOT_ENUM, RebootStatus.STATUS_SUCCESS.name)
369+
self.reboot_module.populate_reboot_status_flag(False, 0, "", REBOOT_METHOD_COLD_BOOT_ENUM, RebootStatus.STATUS_SUCCESS)
359370
result = self.reboot_module.get_reboot_status()
360371
assert result[0] == 0
361372
response_data = json.loads(result[1])
362373
assert response_data["active"] == False
363374
assert response_data["when"] == 0
364375
assert response_data["reason"] == ""
365376
assert response_data["method"] == REBOOT_METHOD_COLD_BOOT_ENUM
366-
assert response_data["status"] == RebootStatus.STATUS_SUCCESS.name
377+
assert response_data["status"] == RebootStatus.STATUS_SUCCESS.value
367378

368379
# assert result[1] == TEST_INACTIVE_RESPONSE_DATA
369380

0 commit comments

Comments
 (0)