Skip to content

BMC host power state events watcher - #37

Merged
judyjoseph merged 3 commits into
sonic-net:masterfrom
nexthop-ai:chinmoy.hostChangeProperty.eventSubscription
Oct 8, 2026
Merged

judyjoseph merged 3 commits into
sonic-net:masterfrom
nexthop-ai:chinmoy.hostChangeProperty.eventSubscription

Conversation

@chinmoy-nexthop

Copy link
Copy Markdown
Contributor

[sonic-dbus-bridge] Mirror bmcctld host power state and emit Redfish host power events

Why I did it

Redfish ComputerSystem PowerState was set by sonic-dbus-bridge from the
request path (TransitioningToRunning on request, Running/Off after
publishing) regardless of what the platform actually did. bmcctld owns
the Switch-Host power sequence and publishes the authoritative state to
STATE_DB HOST_STATE|switch-host and the per-command outcome to
RACK_MANAGER_COMMAND|CMD_, but the bridge ignored both. Reset
requests also accepted every ResetType even though only four map to a
bmcctld command, and host power transitions were never delivered to
Redfish event subscribers.

How I did it

sonic-dbus-bridge

  • Add host_state_mapping.hpp with the device_power_state / device_status
    to xyz.openbmc_project.State.Host.HostState table and the ResetType to
    RACK_MANAGER_COMMAND mapping (POWER_ON, POWER_OFF, GRACEFUL_SHUT,
    POWER_CYCLE).
  • Subscribe to HOST_STATE|switch-host and RACK_MANAGER_COMMAND|* and
    apply the mapped HostState to host0. Request paths no longer write
    CurrentHostState themselves.
  • Honour bmcctld command results. Log DONE at NOTICE and FAILED at ERR,
    release the action slot on a terminal status or after COMMAND_TIMEOUT.
  • Add PSUBSCRIBE support in RedisStateSubscriber for glob keys so dynamic
    RACK_MANAGER_COMMAND|CMD_ keys are covered.
  • Serve xyz.openbmc_project.State.Chassis from the same connection so
    ForceOff and Chassis PowerState resolve. Extend the D-Bus policy and
    meson.build accordingly.

bmcweb (patches/0008)

  • Add rmc-events host_state_monitor which watches CurrentHostState on
    xyz.openbmc_project.State.Host and emits ResourceEvent
    ResourcePoweringOn / ResourcePoweredOn / ResourcePoweringOff /
    ResourcePoweredOff with OriginOfCondition /redfish/v1/Systems/system.
  • Restrict ComputerSystem.Reset to On, ForceOff, GracefulShutdown and
    PowerCycle. Other ResetType values return ActionParameterNotSupported.

Tests and docs

  • Add tests/unit-tests/host_state_mapping_test.cpp

How to verify it

  1. make unit-test
    host_state_mapping_test covers every row of the state table and the
    ResetType mapping. All 45 gtest cases pass.
  2. make build-bridge and make build-bmcweb
    Both build cleanly with patch 0008 applied.
  3. Deploy with bmcctld running and check that
    busctl --system list | grep xyz.openbmc_project.State.Chassis
    shows the new bus name.
  4. GET /redfish/v1/Systems/system
    Actions.#ComputerSystem.Reset.ResetType@Redfish.AllowableValues lists
    only On, ForceOff, GracefulShutdown, PowerCycle.
    PowerState tracks HOST_STATE|switch-host device_power_state.
  5. POST /redfish/v1/Systems/system/Actions/ComputerSystem.Reset with
    ResetType=ForceRestart returns 400 Base.ActionParameterNotSupported.
  6. POST with ResetType=GracefulShutdown creates
    RACK_MANAGER_COMMAND|CMD_ with command=GRACEFUL_SHUT. The bridge
    log shows the DONE/FAILED status and PowerState follows
    HOST_STATE|switch-host through PoweringOff to Off.
  7. With a subscription on /redfish/v1/EventService/Subscriptions
    (RegistryPrefixes ResourceEvent), the listener receives
    ResourcePoweringOff and ResourcePoweredOff with OriginOfCondition
    /redfish/v1/Systems/system.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

nh-grecs Bot pushed a commit to nexthop-ai/sonic-redfish that referenced this pull request Oct 3, 2026
rebuild-source: sonic-net/pull/37 @ nexthop-ai/sonic-redfish b73cd41 [case: upstream:open]
nh-grecs Bot pushed a commit to nexthop-ai/sonic-redfish that referenced this pull request Oct 5, 2026
rebuild-source: sonic-net/pull/37 @ nexthop-ai/sonic-redfish b73cd41 [case: upstream:open]
@chinmoy-nexthop
chinmoy-nexthop force-pushed the chinmoy.hostChangeProperty.eventSubscription branch from b73cd41 to 4f2802f Compare October 5, 2026 10:11
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@chinmoy-nexthop
chinmoy-nexthop force-pushed the chinmoy.hostChangeProperty.eventSubscription branch from 4f2802f to b24fd83 Compare October 5, 2026 10:42
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

…host power events

Why I did it

Redfish ComputerSystem PowerState was set by sonic-dbus-bridge from the
request path (TransitioningToRunning on request, Running/Off after
publishing) regardless of what the platform actually did. bmcctld owns
the Switch-Host power sequence and publishes the authoritative state to
STATE_DB HOST_STATE|switch-host and the per-command outcome to
RACK_MANAGER_COMMAND|CMD_<id>, but the bridge ignored both. Reset
requests also accepted every ResetType even though only four map to a
bmcctld command, and host power transitions were never delivered to
Redfish event subscribers.

How I did it

sonic-dbus-bridge
- Add host_state_mapping.hpp with the device_power_state / device_status
  to xyz.openbmc_project.State.Host.HostState table and the ResetType to
  RACK_MANAGER_COMMAND mapping (POWER_ON, POWER_OFF, GRACEFUL_SHUT,
  POWER_CYCLE).
- Subscribe to HOST_STATE|switch-host and RACK_MANAGER_COMMAND|* and
  apply the mapped HostState to host0. Request paths no longer write
  CurrentHostState themselves.
- Honour bmcctld command results. Log DONE at NOTICE and FAILED at ERR,
  release the action slot on a terminal status or after COMMAND_TIMEOUT.
- Add PSUBSCRIBE support in RedisStateSubscriber for glob keys so dynamic
  RACK_MANAGER_COMMAND|CMD_<id> keys are covered.
- Serve xyz.openbmc_project.State.Chassis from the same connection so
  ForceOff and Chassis PowerState resolve. Extend the D-Bus policy and
  meson.build accordingly.

bmcweb (patches/0008)
- Add rmc-events host_state_monitor which watches CurrentHostState on
  xyz.openbmc_project.State.Host and emits ResourceEvent
  ResourcePoweringOn / ResourcePoweredOn / ResourcePoweringOff /
  ResourcePoweredOff with OriginOfCondition /redfish/v1/Systems/system.
- Restrict ComputerSystem.Reset to On, ForceOff, GracefulShutdown and
  PowerCycle. Other ResetType values return ActionParameterNotSupported.

Tests and docs
- Add tests/unit-tests/host_state_mapping_test.cpp (18 tests).
- Document the state and ResetType tables and the event flow in README
  section 11.7.

How to verify it

1. make unit-test
   host_state_mapping_test covers every row of the state table and the
   ResetType mapping. All 45 gtest cases pass.
2. make build-bridge and make build-bmcweb
   Both build cleanly with patch 0008 applied.
3. Deploy with bmcctld running and check that
   busctl --system list | grep xyz.openbmc_project.State.Chassis
   shows the new bus name.
4. GET /redfish/v1/Systems/system
   Actions.#ComputerSystem.Reset.ResetType@Redfish.AllowableValues lists
   only On, ForceOff, GracefulShutdown, PowerCycle.
   PowerState tracks HOST_STATE|switch-host device_power_state.
5. POST /redfish/v1/Systems/system/Actions/ComputerSystem.Reset with
   ResetType=ForceRestart returns 400 Base.ActionParameterNotSupported.
6. POST with ResetType=GracefulShutdown creates
   RACK_MANAGER_COMMAND|CMD_<id> with command=GRACEFUL_SHUT. The bridge
   log shows the DONE/FAILED status and PowerState follows
   HOST_STATE|switch-host through PoweringOff to Off.
7. With a subscription on /redfish/v1/EventService/Subscriptions
   (RegistryPrefixes ResourceEvent), the listener receives
   ResourcePoweringOff and ResourcePoweredOff with OriginOfCondition
   /redfish/v1/Systems/system.

Signed-off-by: Chinmoy Dey <chinmoy@nexthop.ai>
   The leak detector monitor sent OriginOfCondition under
  /redfish/v1/Chassis/BMC. bmcweb serves the bridge's chassis object as
  /redfish/v1/Chassis/chassis, so subscribers received a URI this BMC

Signed-off-by: Chinmoy Dey <chinmoy@nexthop.ai>
@chinmoy-nexthop
chinmoy-nexthop force-pushed the chinmoy.hostChangeProperty.eventSubscription branch from b24fd83 to 1c5c7bc Compare October 5, 2026 17:05
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@judyjoseph
judyjoseph requested review from judyjoseph and a balanced review from Copilot October 5, 2026 18:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

ResetActionInfo still advertises reset types that the updated POST path rejects.

Review effort: Balanced
Findings: 3 Medium severity

Open (3)
What changed in this PR

Adds authoritative Switch-Host power-state synchronization from bmcctld to Redfish, including command lifecycle handling and power events.

Changes:

  • Mirrors Redis host state onto Host/Chassis D-Bus interfaces.
  • Emits Redfish power events and restricts reset handling.
  • Adds mappings, tests, API checks, and documentation.
File Description
tests/​unit-tests/​host_state_mapping_test.cpp Tests state and reset mappings.
tests/​redfish-api/​cases/​systems.json Adds ComputerSystem API checks.
tests/​redfish-api/​cases/​leak_event_flow.json Validates canonical leak-event origin.
sonic-dbus-bridge/​src/​update_engine.cpp Forwards host and command updates.
sonic-dbus-bridge/​src/​state_manager.cpp Manages authoritative state and commands.
sonic-dbus-bridge/​src/​redis_state_subscriber.cpp Adds pattern subscriptions.
sonic-dbus-bridge/​src/​redis_adapter.cpp Reads host and command records.
sonic-dbus-bridge/​src/​bridge_app.cpp Wires state services and subscriptions.
sonic-dbus-bridge/​meson.build Configures the Chassis service name.
sonic-dbus-bridge/​include/​update_engine.hpp Connects the state manager.
sonic-dbus-bridge/​include/​types.hpp Defines host and command records.
sonic-dbus-bridge/​include/​state_manager.hpp Declares expanded state management.
sonic-dbus-bridge/​include/​redis_adapter.hpp Exposes new Redis reads.
sonic-dbus-bridge/​include/​host_state_mapping.hpp Defines mapping contracts.
sonic-dbus-bridge/​include/​bridge_app.hpp Shares state-manager ownership.
sonic-dbus-bridge/​dbus/​xyz.openbmc_project.State.Host.conf Permits Host and Chassis services.
rmc-events/​src/​leak_detector_monitor.cpp Corrects leak origin URI.
rmc-events/​src/​host_state_monitor.cpp Emits host power events.
rmc-events/​include/​host_state_monitor.hpp Declares the host-state monitor.
README.md Documents mappings and event behavior.
patches/​series Enables patch 0008.
patches/​0008-Switch-Host-power-events-and-supported-ResetTypes.patch Integrates events and reset restrictions into bmcweb.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread rmc-events/src/host_state_monitor.cpp
Comment thread tests/redfish-api/cases/systems.json
nh-grecs Bot pushed a commit to nexthop-ai/sonic-redfish that referenced this pull request Oct 7, 2026
rebuild-source: sonic-net/pull/37 @ nexthop-ai/sonic-redfish 1c5c7bc [case: upstream:open]
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@chinmoy-nexthop
chinmoy-nexthop force-pushed the chinmoy.hostChangeProperty.eventSubscription branch from 033bfdc to 8166c40 Compare October 7, 2026 15:36
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).


inline constexpr std::array<DevicePowerStateRule, 8> DEVICE_POWER_STATE_RULES = {{
{"POWERING_ON", true, HOST_STATE_TRANSITIONING_TO_RUNNING},
{"POWERING_OFF", true, HOST_STATE_TRANSITIONING_TO_OFF},

@judyjoseph judyjoseph Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a get of /redfish/v1/Systems/System will it give power state ? and does that include the transition state as well ? What does DMTF tell -- should we map to DMTF enums when sending response back ?

Also what are the various redfish URIs we support with this change

@chinmoy-nexthop chinmoy-nexthop Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • GET /redfish/v1/Systems/system returns PowerState
  • yes its includes transaction state as per DMTF

API

GET /redfish/v1/Systems
GeT /redfish/v1/Systems/system
GET /redfish/v1/UpdateService/FirmwareInventory

GET /redfish/v1/Systems/system/ResetActionInfo
POSt /redfish/v1/Systems/system/Actions/ComputerSystem.Reset

POST /redfish/v1/Managers/bmc/Oem/SONiC/RackManager/Actions/SONiC.SubmitAlert -> redfish_alert_data obj
POST /redfish/v1/Managers/bmc/Oem/SONiC/RackManager/Actions/SONiC. SubmitTelemetry -> Alarms object

/redfish/v1/Chassis/chassis/ThermalSubsystem/LeakDetection
/redfish/v1/Chassis/chassis/ThermalSubsystem/LeakDetection/LeakDetectors
/redfish/v1/Chassis/chassis/ThermalSubsystem/LeakDetection/LeakDetectors/{id}

GET /redfish/v1/EventService
POST /redfish/v1/EventService/Subscriptions
GET /redfish/v1/EventService/Subscriptions/{id}
DELETE /redfish/v1/EventService/Subscriptions/{id}

@judyjoseph

Copy link
Copy Markdown
Contributor

Are we mapping xyz.openbmc_project.State.Host.HostState to power state ( PowerON, PowerOFF, GracefulShutdown ) etc or is it mapped to power status ( online/offline ) ?

@judyjoseph judyjoseph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM have a few questions ..

@chinmoy-nexthop

Copy link
Copy Markdown
Contributor Author

Are we mapping xyz.openbmc_project.State.Host.HostState to power state ( PowerON, PowerOFF, GracefulShutdown ) etc or is it mapped to power status ( online/offline ) ?

  • Yes hostState is mapped to the redfish PowerState not online/offline

ResetActionInfo no longer lists Nmi and ForceOn, matching what
ComputerSystem.Reset accepts. Add integration cases for ResetActionInfo
and for ResourcePoweredOff/On/PoweringOff events driven through
HOST_STATE|switch-host, and teach the case path extractor to resolve

Signed-off-by: Chinmoy Dey <chinmoy@nexthop.ai>
@chinmoy-nexthop
chinmoy-nexthop force-pushed the chinmoy.hostChangeProperty.eventSubscription branch from 8166c40 to 3564cdd Compare October 8, 2026 10:10
@mssonicbld

Copy link
Copy Markdown

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@chinmoy-nexthop

Copy link
Copy Markdown
Contributor Author

LGTM have a few questions ..

Than you for the review @judyjoseph .

@judyjoseph
judyjoseph merged commit 20cdada into sonic-net:master Oct 8, 2026
5 checks passed
rraghav-cisco pushed a commit to rraghav-cisco/sonic-mgmt that referenced this pull request Oct 19, 2026
…om, concurrency, etc) (sonic-net#28036)

Note: all tests below pass on a BMC image built from
sonic-net/sonic-redfish#37

```
[INFRA] 2026-10-06 14:04:18: run_all_tests():
TESTS RUN RESULTS:BEG
+------------------------------------------------------+--------------------------------------+--------+----------+-------+
| Test                                                 | Description                          | Result | Duration | Error |
+------------------------------------------------------+--------------------------------------+--------+----------+-------+
| tests/redfish/test_redfish_cert_auth.py              | skipped 0 errors 0 failed 0 total 5  | PASS   | 480.41   |       |
| tests/redfish/test_redfish_computer_reset.py         | skipped 0 errors 0 failed 0 total 5  | PASS   | 581.12   |       |
| tests/redfish/test_redfish_concurrency.py            | skipped 0 errors 0 failed 0 total 3  | PASS   | 419.96   |       |
| tests/redfish/test_redfish_event_subscription.py     | skipped 0 errors 0 failed 0 total 16 | PASS   | 1225.86  |       |
| tests/redfish/test_redfish_firmware_inventory.py     | skipped 0 errors 0 failed 0 total 4  | PASS   | 419.83   |       |
| tests/redfish/test_redfish_pmon_interaction.py       | skipped 0 errors 0 failed 0 total 4  | PASS   | 561.1    |       |
| tests/redfish/test_redfish_rack_manager_alert.py     | skipped 0 errors 0 failed 0 total 10 | PASS   | 945.99   |       |
| tests/redfish/test_redfish_rack_manager_telemetry.py | skipped 0 errors 0 failed 0 total 16 | PASS   | 1379.09  |       |
| tests/redfish/test_redfish_restart_recovery.py       | skipped 0 errors 0 failed 0 total 2  | PASS   | 399.86   |       |
| tests/redfish/test_redfish_service_root.py           | skipped 0 errors 0 failed 0 total 2  | PASS   | 319.06   |       |
+------------------------------------------------------+--------------------------------------+--------+----------+-------+
TESTS RUN RESULTS:END

2026-10-06 14:04:18,395 nhtest.libs.sonic_mgmt.container_docker [INFO] [MainThread] Restored original ansible config files
2026-10-06 14:04:19,062 nhtest.libs.sonic_mgmt.container_docker [INFO] [MainThread] Removed container: 743266f57fb275418861f84814c4ce150e0037e4625a63a5e6b4736bcd0be1ec
```
> Event subscription (16)

1. test_event_service_advertised: GET EventService shows ServiceEnabled,
the Subscriptions link, and the Base and OpenBMC registry prefixes.
2. test_subscription_lifecycle: POST creates a subscription with a
Location, GET echoes Destination and Context with bmcweb's defaults, the
collection lists it, DELETE removes it and a later GET is 404.
3. test_subscription_rejects_bad_requests, 7 cases: a missing,
malformed, or credential-bearing Destination, an unsupported Protocol,
an unknown RegistryPrefix, MessageIds combined with prefixes, and an
unknown retry policy are each refused with a Redfish error and no
subscription.
4. test_leak_event_delivered: a Critical leak written to STATE_DB
arrives at the subscriber as LeakDetectedCritical with OriginOfCondition
pointing at the detector under Chassis/chassis, and clearing it arrives
as LeakDetectedNormal with a higher event Id.
5. test_leak_warning_event_delivered: a MINOR leak arrives as
LeakDetectedWarning with Severity Warning.
6. test_resource_type_filter: an unfiltered subscriber and one filtered
on ResourceTypes LeakDetector both receive the leak, while Task and Base
filtered subscribers receive nothing.
7. test_subscription_persists_across_bmcweb_restart: after a bmcweb
restart the subscription is still listed with the same Destination and
Context and still receives a leak event.
8. test_leak_detector_resource_tracks_state: the detector is listed in
the LeakDetectors collection under Chassis/chassis, and GET on it shows
DetectorState and Health following OK, Critical, OK with the STATE_DB
row.
9. test_host_power_events_delivered: as HOST_STATE moves through
POWERING_OFF, POWERED_OFF, POWERING_ON, POWERED_ON, a subscriber
filtered on ResourceTypes ComputerSystem receives ResourcePoweringOff,
ResourcePoweredOff, ResourcePoweringOn, and ResourcePoweredOn in order
with increasing Ids, each with OriginOfCondition
/redfish/v1/Systems/system, while a LeakDetector-only subscriber
receives none.
10. test_host_power_off_event_drives_power_on_request: HOST_STATE
reports POWERED_OFF, the subscriber receives ResourcePoweredOff and
answers with ComputerSystem.Reset ResetType On, which becomes one
RACK_MANAGER_COMMAND row that bmcctld completes DONE with SUCCESS, and
once HOST_STATE reads POWERED_ON again the subscriber receives
ResourcePoweredOn.

> Rack manager telemetry (16)

1. test_manager_advertises_telemetry_action: Managers/bmc advertises the
SONiC RackManager SubmitTelemetry action and its target.
2. test_submit_telemetry_persists_to_state_db: a valid telemetry POST
writes the RACK_MANAGER_DATA rows with value, unit, severity, and
timestamp.
3. test_submit_telemetry_updates_existing_record: a later sample
overwrites the earlier row so a cleared alert becomes visible.
4. test_submit_telemetry_payload_shapes, 7 cases: alternate envelope
names, inherited wrapper severity, missing severity defaulting to
Normal, mixed-case severity, unknown fields dropped, multiple envelopes
merged, and unrecognised-only payloads persisting nothing.
5. test_submit_telemetry_rejects_bad_requests, 5 cases: malformed JSON,
a missing alarms envelope, an unknown manager id, an oversized body, and
GET on the action are refused with the right error and write nothing.
6. test_submit_telemetry_bridge_unavailable: with the bridge stopped a
telemetry POST is refused rather than silently dropped, and service
recovers once it is back.

> Concurrency (3)

1. test_reset_concurrent_with_inventory_poll: five ResetType On requests
while four threads poll Chassis, Managers, and FirmwareInventory, every
poll answered 200 with stable membership, one command row per reset,
RequestedHostTransition set, HOST_STATE back to POWERED_ON, no process
restarted.
2. test_duplicate_subscription_create_and_delete: eight identical
subscription POSTs at once each get 201 with a unique id, concurrent
DELETEs all answer 2xx or 404, and the collection ends empty.
3. test_interleaved_create_delete_churn: four workers each run five
create, read, delete cycles with no lost or cross-deleted subscription.

> Pmon interaction (4)

1. test_reset_command_consumed_by_bmcctld: one Reset produces one
RACK_MANAGER_COMMAND row that bmcctld drives to DONE with result
SUCCESS, the row is retained, and HOST_STATE stays POWERED_ON.
2. test_power_state_consistent_across_layers: HOST_STATE
device_power_state and device_status agree with CHASSIS_MODULE_TABLE
oper_status.
3. test_critical_alert_blocks_power_on_command: after a Critical
SubmitAlert the next POWER_ON fails with CRITICAL_LEAK_PRESENT, and
after clearing it the next POWER_ON completes with SUCCESS.
4. test_bmcctld_restart_resyncs_host_state: a bmcctld restart
re-publishes HOST_STATE with a newer timestamp, creates no command rows,
and a subsequent Reset is still consumed.

> Rack manager alert (10)

1. test_submit_alert_persists_to_state_db: a flat-form alert returns 204
and writes the RACK_MANAGER_ALERT rows with severity and timestamp.
2. test_submit_alert_wrapped_form_inherits_severity: the ShutdownAlert
wrapped form resolves to the same records, with sensors inheriting the
wrapper severity.
3. test_submit_alert_clear_overwrites_critical: a later Normal alert
overwrites an earlier Critical in place.
4. test_submit_alert_minor_only: a single Minor measurement alert writes
only that sensor's record.
5. test_submit_alert_rejects_bad_requests, 6 cases: malformed JSON, a
missing or wrong-case envelope, an unknown manager id, an oversized
body, and GET on the action are refused and write nothing.

> Restart recovery (2)

1. test_bridge_restart_rediscovered_by_running_bmcweb: restarting
sonic-dbus-bridge under a running bmcweb restores the same ObjectMapper
tree and Redfish inventory, including leak detectors, without bmcweb
restarting.
2. test_redfish_container_restart: restarting the redfish container
keeps mTLS in force, restores the inventory, and preserves a
subscription created before the restart.


### How to verify?

> sonic management test for resdifish with --topology
**bmc-shared-mgmt**




### Type of change

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [x] New Test case
    - [x] Skipped for non-supported platforms
- [ ] Test case improvement


### Back port request
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511
- [ ] 202512
- [ ] 202605

Tracking issue/work item for backport/cherry-pick request (GitHub issue
or Microsoft ADO):
Failure type:

### Tested branch
- [x] master
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511
- [ ] 202512
- [ ] 202605
- [ ] N/A


### Approach
#### What is the motivation for this PR?



#### How did you verify/test it?

Ran the module on a SONiC BMC DUT on master.

#### Any platform specific information?

Needs a SONiC BMC image with the redfish container (bmcweb).

#### Supported testbed topology if it's a new test case?

bmc

### Documentation

N/A

---------

Signed-off-by: Chinmoy Dey <chinmoy@nexthop.ai>
mssonicbld added a commit to Azure/sonic-mgmt.msft that referenced this pull request Oct 21, 2026
…y,alert, recovery, pom, concurrency, etc) (#1492)

Note: all tests below pass on a BMC image built from sonic-net/sonic-redfish#37

```
[INFRA] 2026-10-06 14:04:18: run_all_tests():
TESTS RUN RESULTS:BEG
+------------------------------------------------------+--------------------------------------+--------+----------+-------+
| Test | Description | Result | Duration | Error |
+------------------------------------------------------+--------------------------------------+--------+----------+-------+
| tests/redfish/test_redfish_cert_auth.py | skipped 0 errors 0 failed 0 total 5 | PASS | 480.41 | |
| tests/redfish/test_redfish_computer_reset.py | skipped 0 errors 0 failed 0 total 5 | PASS | 581.12 | |
| tests/redfish/test_redfish_concurrency.py | skipped 0 errors 0 failed 0 total 3 | PASS | 419.96 | |
| tests/redfish/test_redfish_event_subscription.py | skipped 0 errors 0 failed 0 total 16 | PASS | 1225.86 | |
| tests/redfish/test_redfish_firmware_inventory.py | skipped 0 errors 0 failed 0 total 4 | PASS | 419.83 | |
| tests/redfish/test_redfish_pmon_interaction.py | skipped 0 errors 0 failed 0 total 4 | PASS | 561.1 | |
| tests/redfish/test_redfish_rack_manager_alert.py | skipped 0 errors 0 failed 0 total 10 | PASS | 945.99 | |
| tests/redfish/test_redfish_rack_manager_telemetry.py | skipped 0 errors 0 failed 0 total 16 | PASS | 1379.09 | |
| tests/redfish/test_redfish_restart_recovery.py | skipped 0 errors 0 failed 0 total 2 | PASS | 399.86 | |
| tests/redfish/test_redfish_service_root.py | skipped 0 errors 0 failed 0 total 2 | PASS | 319.06 | |
+------------------------------------------------------+--------------------------------------+--------+----------+-------+
TESTS RUN RESULTS:END

2026-10-06 14:04:18,395 nhtest.libs.sonic_mgmt.container_docker [INFO] [MainThread] Restored original ansible config files
2026-10-06 14:04:19,062 nhtest.libs.sonic_mgmt.container_docker [INFO] [MainThread] Removed container: 743266f57fb275418861f84814c4ce150e0037e4625a63a5e6b4736bcd0be1ec
```
> Event subscription (16)

1. test_event_service_advertised: GET EventService shows ServiceEnabled, the Subscriptions link, and the Base and OpenBMC registry prefixes.
2. test_subscription_lifecycle: POST creates a subscription with a Location, GET echoes Destination and Context with bmcweb's defaults, the collection lists it, DELETE removes it and a later GET is 404.
3. test_subscription_rejects_bad_requests, 7 cases: a missing, malformed, or credential-bearing Destination, an unsupported Protocol, an unknown RegistryPrefix, MessageIds combined with prefixes, and an unknown retry policy are each refused with a Redfish error and no subscription.
4. test_leak_event_delivered: a Critical leak written to STATE_DB arrives at the subscriber as LeakDetectedCritical with OriginOfCondition pointing at the detector under Chassis/chassis, and clearing it arrives as LeakDetectedNormal with a higher event Id.
5. test_leak_warning_event_delivered: a MINOR leak arrives as LeakDetectedWarning with Severity Warning.
6. test_resource_type_filter: an unfiltered subscriber and one filtered on ResourceTypes LeakDetector both receive the leak, while Task and Base filtered subscribers receive nothing.
7. test_subscription_persists_across_bmcweb_restart: after a bmcweb restart the subscription is still listed with the same Destination and Context and still receives a leak event.
8. test_leak_detector_resource_tracks_state: the detector is listed in the LeakDetectors collection under Chassis/chassis, and GET on it shows DetectorState and Health following OK, Critical, OK with the STATE_DB row.
9. test_host_power_events_delivered: as HOST_STATE moves through POWERING_OFF, POWERED_OFF, POWERING_ON, POWERED_ON, a subscriber filtered on ResourceTypes ComputerSystem receives ResourcePoweringOff, ResourcePoweredOff, ResourcePoweringOn, and ResourcePoweredOn in order with increasing Ids, each with OriginOfCondition /redfish/v1/Systems/system, while a LeakDetector-only subscriber receives none.
10. test_host_power_off_event_drives_power_on_request: HOST_STATE reports POWERED_OFF, the subscriber receives ResourcePoweredOff and answers with ComputerSystem.Reset ResetType On, which becomes one RACK_MANAGER_COMMAND row that bmcctld completes DONE with SUCCESS, and once HOST_STATE reads POWERED_ON again the subscriber receives ResourcePoweredOn.

> Rack manager telemetry (16)

1. test_manager_advertises_telemetry_action: Managers/bmc advertises the SONiC RackManager SubmitTelemetry action and its target.
2. test_submit_telemetry_persists_to_state_db: a valid telemetry POST writes the RACK_MANAGER_DATA rows with value, unit, severity, and timestamp.
3. test_submit_telemetry_updates_existing_record: a later sample overwrites the earlier row so a cleared alert becomes visible.
4. test_submit_telemetry_payload_shapes, 7 cases: alternate envelope names, inherited wrapper severity, missing severity defaulting to Normal, mixed-case severity, unknown fields dropped, multiple envelopes merged, and unrecognised-only payloads persisting nothing.
5. test_submit_telemetry_rejects_bad_requests, 5 cases: malformed JSON, a missing alarms envelope, an unknown manager id, an oversized body, and GET on the action are refused with the right error and write nothing.
6. test_submit_telemetry_bridge_unavailable: with the bridge stopped a telemetry POST is refused rather than silently dropped, and service recovers once it is back.

> Concurrency (3)

1. test_reset_concurrent_with_inventory_poll: five ResetType On requests while four threads poll Chassis, Managers, and FirmwareInventory, every poll answered 200 with stable membership, one command row per reset, RequestedHostTransition set, HOST_STATE back to POWERED_ON, no process restarted.
2. test_duplicate_subscription_create_and_delete: eight identical subscription POSTs at once each get 201 with a unique id, concurrent DELETEs all answer 2xx or 404, and the collection ends empty.
3. test_interleaved_create_delete_churn: four workers each run five create, read, delete cycles with no lost or cross-deleted subscription.

> Pmon interaction (4)

1. test_reset_command_consumed_by_bmcctld: one Reset produces one RACK_MANAGER_COMMAND row that bmcctld drives to DONE with result SUCCESS, the row is retained, and HOST_STATE stays POWERED_ON.
2. test_power_state_consistent_across_layers: HOST_STATE device_power_state and device_status agree with CHASSIS_MODULE_TABLE oper_status.
3. test_critical_alert_blocks_power_on_command: after a Critical SubmitAlert the next POWER_ON fails with CRITICAL_LEAK_PRESENT, and after clearing it the next POWER_ON completes with SUCCESS.
4. test_bmcctld_restart_resyncs_host_state: a bmcctld restart re-publishes HOST_STATE with a newer timestamp, creates no command rows, and a subsequent Reset is still consumed.

> Rack manager alert (10)

1. test_submit_alert_persists_to_state_db: a flat-form alert returns 204 and writes the RACK_MANAGER_ALERT rows with severity and timestamp.
2. test_submit_alert_wrapped_form_inherits_severity: the ShutdownAlert wrapped form resolves to the same records, with sensors inheriting the wrapper severity.
3. test_submit_alert_clear_overwrites_critical: a later Normal alert overwrites an earlier Critical in place.
4. test_submit_alert_minor_only: a single Minor measurement alert writes only that sensor's record.
5. test_submit_alert_rejects_bad_requests, 6 cases: malformed JSON, a missing or wrong-case envelope, an unknown manager id, an oversized body, and GET on the action are refused and write nothing.

> Restart recovery (2)

1. test_bridge_restart_rediscovered_by_running_bmcweb: restarting sonic-dbus-bridge under a running bmcweb restores the same ObjectMapper tree and Redfish inventory, including leak detectors, without bmcweb restarting.
2. test_redfish_container_restart: restarting the redfish container keeps mTLS in force, restores the inventory, and preserves a subscription created before the restart.

### How to verify?

> sonic management test for resdifish with --topology **bmc-shared-mgmt**

### Type of change

- [ ] Bug fix
- [ ] Testbed and Framework(new/improvement)
- [x] New Test case
 - [x] Skipped for non-supported platforms
- [ ] Test case improvement

### Back port request
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511
- [ ] 202512
- [ ] 202605

Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO):
Failure type:

### Tested branch
- [x] master
- [ ] 202311
- [ ] 202405
- [ ] 202411
- [ ] 202505
- [ ] 202511
- [ ] 202512
- [ ] 202605
- [ ] N/A

### Approach
#### What is the motivation for this PR?

#### How did you verify/test it?

Ran the module on a SONiC BMC DUT on master.

#### Any platform specific information?

Needs a SONiC BMC image with the redfish container (bmcweb).

#### Supported testbed topology if it's a new test case?

bmc

### Documentation

N/A

Signed-off-by: Sonic Build Admin <sonicbld@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants