1d6ec8369SGeorge Keishing*** Settings ***
29480af52SGeorge KeishingDocumentation    Test MPIPL (Memory preserving IPL).
39480af52SGeorge Keishing
49480af52SGeorge Keishing#------------------------------------------------------------------
59480af52SGeorge Keishing# This boot path will generated a BMC dump followed by system dump.
69480af52SGeorge Keishing#------------------------------------------------------------------
7d6ec8369SGeorge Keishing
8d6ec8369SGeorge KeishingResource         ../../lib/resource.robot
9d6ec8369SGeorge KeishingResource         ../../lib/openbmc_ffdc.robot
10d6ec8369SGeorge KeishingResource         ../../lib/bmc_redfish_utils.robot
11d6ec8369SGeorge KeishingResource         ../../lib/bmc_redfish_resource.robot
12d6ec8369SGeorge KeishingResource         ../../lib/boot_utils.robot
13d6ec8369SGeorge Keishing
149480af52SGeorge KeishingSuite Setup      Redfish.Login
159480af52SGeorge KeishingTest Setup       Test Setup Execution
16d6ec8369SGeorge KeishingTest Teardown    Test Teardown Execution
179480af52SGeorge KeishingSuite Teardown   Suite Teardown Execution
18d6ec8369SGeorge Keishing
19d6ec8369SGeorge Keishing*** Variables ***
20d6ec8369SGeorge Keishing
219480af52SGeorge Keishing# By default 1 iteration, user can key in nth number of iteration to control
229480af52SGeorge Keishing# how many time it needs MPIPL test runs.
239480af52SGeorge Keishing${MPIPL_LOOP_COUNT}     ${1}
249480af52SGeorge Keishing
25d6ec8369SGeorge Keishing
26d6ec8369SGeorge Keishing** Test Cases **
27d6ec8369SGeorge Keishing
289480af52SGeorge KeishingTrigger User Tool Initiated MPIPL
299480af52SGeorge Keishing    [Documentation]  Trigger And Verify user tool initiated dump using
309480af52SGeorge Keishing    ...              obmc-host-crash target.
319480af52SGeorge Keishing    [Tags]  Trigger_User_Tool_Initiated_MPIPL
32d6ec8369SGeorge Keishing
339480af52SGeorge Keishing    FOR  ${count}  IN RANGE  0  ${MPIPL_LOOP_COUNT}
349480af52SGeorge Keishing        Log To Console   MPIPL LOOP_COUNT:${count} execution.
359480af52SGeorge Keishing        Tool Initd MP Reboot
369480af52SGeorge Keishing        Required Dumps Should Exist
379480af52SGeorge Keishing    END
38d6ec8369SGeorge Keishing
39d6ec8369SGeorge Keishing
409480af52SGeorge KeishingTrigger User Initiated MPIPL Using Redfish
419480af52SGeorge Keishing    [Documentation]  Verify redfish triggered MPIPL flow using diagnostic
429480af52SGeorge Keishing    ...              mode target.
439480af52SGeorge Keishing    [Tags]  Trigger_User_Initiated_MPIPL_Using_Redfish
44d6ec8369SGeorge Keishing
459480af52SGeorge Keishing    FOR  ${count}  IN RANGE  0  ${MPIPL_LOOP_COUNT}
469480af52SGeorge Keishing        Log To Console   MPIPL LOOP_COUNT:${count} execution.
479480af52SGeorge Keishing        Redfish Initiated MPIPL
489480af52SGeorge Keishing        Required Dumps Should Exist
499480af52SGeorge Keishing    END
50d6ec8369SGeorge Keishing
51d6ec8369SGeorge Keishing
529480af52SGeorge Keishing*** Keywords ***
53d6ec8369SGeorge Keishing
54d6ec8369SGeorge Keishing
559480af52SGeorge KeishingTest Setup Execution
569480af52SGeorge Keishing    [Documentation]  Do the post test setup cleanup.
57d6ec8369SGeorge Keishing
589480af52SGeorge Keishing    Test System Cleanup
5940abba25SGeorge Keishing    Run Keyword And Ignore Error  Clear All Subscriptions
60d6ec8369SGeorge Keishing
619480af52SGeorge Keishing
629480af52SGeorge KeishingTest Teardown Execution
639480af52SGeorge Keishing    [Documentation]  Do the post test teardown.
649480af52SGeorge Keishing
659480af52SGeorge Keishing    FFDC On Test Case Fail
669480af52SGeorge Keishing
679480af52SGeorge Keishing
689480af52SGeorge KeishingSuite Teardown Execution
699480af52SGeorge Keishing    [Documentation]  Do the post suite teardown.
709480af52SGeorge Keishing
719480af52SGeorge Keishing    Test System Cleanup
729480af52SGeorge Keishing    Run Keyword And Ignore Error  Delete All Redfish Sessions
739480af52SGeorge Keishing
749480af52SGeorge Keishing
759480af52SGeorge KeishingTest System Cleanup
769480af52SGeorge Keishing    [Documentation]  Cleanup errors before exiting.
779480af52SGeorge Keishing
789480af52SGeorge Keishing    Run Keyword And Ignore Error  Redfish Purge Event Log
799480af52SGeorge Keishing    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
809480af52SGeorge Keishing    Run Keyword And Ignore Error  Redfish Delete All System Dumps
819480af52SGeorge Keishing
829480af52SGeorge Keishing
839480af52SGeorge KeishingRedfish Initiated MPIPL
849480af52SGeorge Keishing    [Documentation]  Trigger redfish triggered MPIPL flow.
85d6ec8369SGeorge Keishing
86d6ec8369SGeorge Keishing    # Power on
87d6ec8369SGeorge Keishing    Redfish Power On
88d6ec8369SGeorge Keishing
89d6ec8369SGeorge Keishing    # Trigger MPIPL
9040abba25SGeorge Keishing    Log To Console  Trigger System dump
91d6ec8369SGeorge Keishing    ${payload} =  Create Dictionary
92d6ec8369SGeorge Keishing    ...  DiagnosticDataType=OEM  OEMDiagnosticDataType=System
939480af52SGeorge Keishing    Redfish.Post  ${DUMP_URI}/Actions/LogService.CollectDiagnosticData  body=&{payload}
94d6ec8369SGeorge Keishing    ...  valid_status_codes=[${HTTP_ACCEPTED}]
95d6ec8369SGeorge Keishing
9640abba25SGeorge Keishing    Sleep  10s
9740abba25SGeorge Keishing
989480af52SGeorge Keishing    Log To Console  Wait for system to transition DiagnosticMode
9940abba25SGeorge Keishing    Wait Until Keyword Succeeds  2 min  3 sec  Is Boot Progress Changed
100d6ec8369SGeorge Keishing
1019480af52SGeorge Keishing    Log To Console  Wait for system to transition path DiagnosticMode to Runtime.
1029480af52SGeorge Keishing    Wait Until Keyword Succeeds  10 min  20 sec  Is Boot Progress Runtime Matched
103d6ec8369SGeorge Keishing
104d6ec8369SGeorge Keishing
1059480af52SGeorge KeishingIs Boot Progress Runtime Matched
1069480af52SGeorge Keishing    [Documentation]  Get BootProgress state and expect boot state mismatch.
107d6ec8369SGeorge Keishing
1089480af52SGeorge Keishing    # Match any of the BootProgress state SystemHardwareInitializationComplete|OSBootStarted|OSRunning
1099480af52SGeorge Keishing    ${boot_progress}  ${host_state}=  Redfish Get Boot Progress
1109480af52SGeorge Keishing    Should Contain Any  ${boot_progress}  SystemHardwareInitializationComplete  OSBootStarted  OSRunning
111d6ec8369SGeorge Keishing
112d6ec8369SGeorge Keishing
1139480af52SGeorge KeishingRequired Dumps Should Exist
1149480af52SGeorge Keishing    [Documentation]  Check for BMC and system dump.
1159480af52SGeorge Keishing
1169480af52SGeorge Keishing    #   {
1179480af52SGeorge Keishing    #       "@odata.id": "/redfish/v1/Managers/bmc/LogServices/Dump/Entries/4",
1189480af52SGeorge Keishing    #       "@odata.type": "#LogEntry.v1_8_0.LogEntry",
1199480af52SGeorge Keishing    #       "AdditionalDataSizeBytes": 914254,
1209480af52SGeorge Keishing    #       "AdditionalDataURI": "/redfish/v1/Managers/bmc/LogServices/Dump/Entries/4/attachment",
1219480af52SGeorge Keishing    #       "Created": "2022-07-22T03:36:23+00:00",
1229480af52SGeorge Keishing    #       "DiagnosticDataType": "Manager",
1239480af52SGeorge Keishing    #       "EntryType": "Event",
1249480af52SGeorge Keishing    #       "Id": "4",
1259480af52SGeorge Keishing    #       "Name": "BMC Dump Entry"
1269480af52SGeorge Keishing    #   }
1279480af52SGeorge Keishing    ${bmc_dump}=  Redfish.Get Properties  /redfish/v1/Managers/bmc/LogServices/Dump/Entries
1289480af52SGeorge Keishing    Log To Console  BMC dumps generated: ${bmc_dump['Members@odata.count']}
1299480af52SGeorge Keishing    Should Be True  ${bmc_dump['Members@odata.count']} >= 1  msg=No BMC dump generated.
1309480af52SGeorge Keishing
1319480af52SGeorge Keishing    #"Members": [
1329480af52SGeorge Keishing    #   {
1339480af52SGeorge Keishing    #       "@odata.id": "/redfish/v1/Systems/system/LogServices/Dump/Entries/System_1",
1349480af52SGeorge Keishing    #       "@odata.type": "#LogEntry.v1_8_0.LogEntry",
1359480af52SGeorge Keishing    #       "AdditionalDataSizeBytes": 2363839216,
1369480af52SGeorge Keishing    #       "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/Dump/Entries/System_1/attachment",
1379480af52SGeorge Keishing    #       "Created": "2022-07-22T03:38:58+00:00",
1389480af52SGeorge Keishing    #       "DiagnosticDataType": "OEM",
1399480af52SGeorge Keishing    #       "EntryType": "Event",
1409480af52SGeorge Keishing    #       "Id": "System_1",
1419480af52SGeorge Keishing    #       "Name": "System Dump Entry",
1429480af52SGeorge Keishing    #       "OEMDiagnosticDataType": "System"
1439480af52SGeorge Keishing    #   }
1449480af52SGeorge Keishing    ${sys_dump}=  Redfish.Get Properties  /redfish/v1/Systems/system/LogServices/Dump/Entries
1459480af52SGeorge Keishing    Log To Console  System dump generated: ${sys_dump['Members@odata.count']}
1469480af52SGeorge Keishing    Should Be True  ${sys_dump['Members@odata.count']} == 1  msg=No system dump generated.
147*c69c45a6SGeorge Keishing
148*c69c45a6SGeorge Keishing
149*c69c45a6SGeorge KeishingClear All Subscriptions
150*c69c45a6SGeorge Keishing    [Documentation]  Delete all subscriptions.
151*c69c45a6SGeorge Keishing
152*c69c45a6SGeorge Keishing    ${subscriptions}=  Redfish.Get Attribute  /redfish/v1/EventService/Subscriptions  Members
153*c69c45a6SGeorge Keishing    FOR  ${subscription}  IN  @{subscriptions}
154*c69c45a6SGeorge Keishing        Redfish.Delete  ${subscription['@odata.id']}
155*c69c45a6SGeorge Keishing    END
156