1*** Settings ***
2Documentation    Test MPIPL (Memory preserving IPL).
3
4#------------------------------------------------------------------
5# This boot path will generated a BMC dump followed by system dump.
6#------------------------------------------------------------------
7
8Resource         ../../lib/resource.robot
9Resource         ../../lib/openbmc_ffdc.robot
10Resource         ../../lib/bmc_redfish_utils.robot
11Resource         ../../lib/bmc_redfish_resource.robot
12Resource         ../../lib/boot_utils.robot
13
14Suite Setup      Redfish.Login
15Test Setup       Test Setup Execution
16Test Teardown    Test Teardown Execution
17Suite Teardown   Suite Teardown Execution
18
19Test Tags       MPIPL_Basic
20
21*** Variables ***
22
23# By default 1 iteration, user can key in nth number of iteration to control
24# how many time it needs MPIPL test runs.
25${MPIPL_LOOP_COUNT}     ${1}
26
27
28** Test Cases **
29
30Trigger User Tool Initiated MPIPL
31    [Documentation]  Trigger And Verify user tool initiated dump using
32    ...              obmc-host-crash target.
33    [Tags]  Trigger_User_Tool_Initiated_MPIPL
34
35    FOR  ${count}  IN RANGE  0  ${MPIPL_LOOP_COUNT}
36        Log To Console   MPIPL LOOP_COUNT:${count} execution.
37        Tool Initd MP Reboot
38        Wait Until Keyword Succeeds  5 min  10 sec  Required Dumps Should Exist
39    END
40
41
42Trigger User Initiated MPIPL Using Redfish
43    [Documentation]  Verify redfish triggered MPIPL flow using diagnostic
44    ...              mode target.
45    [Tags]  Trigger_User_Initiated_MPIPL_Using_Redfish
46
47    FOR  ${count}  IN RANGE  0  ${MPIPL_LOOP_COUNT}
48        Log To Console   MPIPL LOOP_COUNT:${count} execution.
49        Redfish Initiated MPIPL
50        Wait Until Keyword Succeeds  5 min  10 sec  Required Dumps Should Exist
51    END
52
53
54*** Keywords ***
55
56
57Test Setup Execution
58    [Documentation]  Do the post test setup cleanup.
59
60    Test System Cleanup
61    Run Keyword And Ignore Error  Clear All Subscriptions
62
63
64Test Teardown Execution
65    [Documentation]  Do the post test teardown.
66
67    FFDC On Test Case Fail
68
69
70Suite Teardown Execution
71    [Documentation]  Do the post suite teardown.
72
73    Test System Cleanup
74    Run Keyword And Ignore Error  Delete All Redfish Sessions
75
76
77Test System Cleanup
78    [Documentation]  Cleanup errors before exiting.
79
80    Run Keyword And Ignore Error  Redfish Purge Event Log
81    Run Keyword And Ignore Error  Redfish Delete All BMC Dumps
82    Run Keyword And Ignore Error  Redfish Delete All System Dumps
83
84
85Redfish Initiated MPIPL
86    [Documentation]  Trigger redfish triggered MPIPL flow.
87
88    # Power on
89    Redfish Power On
90
91    # Trigger MPIPL
92    Log To Console  Trigger System dump
93    ${payload} =  Create Dictionary
94    ...  DiagnosticDataType=OEM  OEMDiagnosticDataType=System
95    Redfish.Post  ${DUMP_URI}/Actions/LogService.CollectDiagnosticData  body=&{payload}
96    ...  valid_status_codes=[${HTTP_ACCEPTED}]
97
98    Sleep  10s
99
100    Log To Console  Wait for system to transition DiagnosticMode
101    Wait Until Keyword Succeeds  2 min  3 sec  Is Boot Progress Changed
102
103    Log To Console  Wait for system to transition path DiagnosticMode to Runtime.
104    Wait Until Keyword Succeeds  10 min  20 sec  Is Boot Progress Runtime Matched
105
106
107Is Boot Progress Runtime Matched
108    [Documentation]  Get BootProgress state and expect boot state mismatch.
109
110    # Match any of the BootProgress state SystemHardwareInitializationComplete|OSBootStarted|OSRunning
111    ${boot_progress}  ${host_state}=  Redfish Get Boot Progress
112    Should Contain Any  ${boot_progress}  SystemHardwareInitializationComplete  OSBootStarted  OSRunning
113
114
115Required Dumps Should Exist
116    [Documentation]  Check for BMC and system dump.
117
118    #   {
119    #       "@odata.id": "/redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries/4",
120    #       "@odata.type": "#LogEntry.v1_8_0.LogEntry",
121    #       "AdditionalDataSizeBytes": 914254,
122    #       "AdditionalDataURI": "/redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries/4/attachment",
123    #       "Created": "2022-07-22T03:36:23+00:00",
124    #       "DiagnosticDataType": "Manager",
125    #       "EntryType": "Event",
126    #       "Id": "4",
127    #       "Name": "BMC Dump Entry"
128    #   }
129    ${bmc_dump}=  Redfish.Get Properties  /redfish/v1/Managers/${MANAGER_ID}/LogServices/Dump/Entries
130    Log To Console  BMC dumps generated: ${bmc_dump['Members@odata.count']}
131    Should Be True  ${bmc_dump['Members@odata.count']} >= 1  msg=No BMC dump generated.
132
133    #"Members": [
134    #   {
135    #       "@odata.id": "/redfish/v1/Systems/system/LogServices/Dump/Entries/System_1",
136    #       "@odata.type": "#LogEntry.v1_8_0.LogEntry",
137    #       "AdditionalDataSizeBytes": 2363839216,
138    #       "AdditionalDataURI": "/redfish/v1/Systems/system/LogServices/Dump/Entries/System_1/attachment",
139    #       "Created": "2022-07-22T03:38:58+00:00",
140    #       "DiagnosticDataType": "OEM",
141    #       "EntryType": "Event",
142    #       "Id": "System_1",
143    #       "Name": "System Dump Entry",
144    #       "OEMDiagnosticDataType": "System"
145    #   }
146    ${sys_dump}=  Redfish.Get Properties  /redfish/v1/Systems/${SYSTEM_ID}/LogServices/Dump/Entries
147    Log To Console  System dump generated: ${sys_dump['Members@odata.count']}
148    Should Be True  ${sys_dump['Members@odata.count']} == 1  msg=No system dump generated.
149
150
151Clear All Subscriptions
152    [Documentation]  Delete all subscriptions.
153
154    ${subscriptions}=  Redfish.Get Attribute  /redfish/v1/EventService/Subscriptions  Members
155    FOR  ${subscription}  IN  @{subscriptions}
156        Redfish.Delete  ${subscription['@odata.id']}
157    END
158