xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_discovery.robot (revision 4ebb32815b41550d1d8802b985dcafb1f4e42419)
18023a8cfSSushil Singh*** Settings ***
2c5e9ebc6SSushil SinghDocumentation        Test to discover the BMC. Before running suit,
3c5e9ebc6SSushil Singh...                  check BMC and Avahi browse machine should be in same subnet.
48023a8cfSSushil Singh
58023a8cfSSushil SinghVariables            ../../data/variables.py
68023a8cfSSushil SinghLibrary              SSHLibrary
78023a8cfSSushil SinghLibrary              ../../lib/external_intf/management_console_utils.py
88023a8cfSSushil SinghLibrary              ../../lib/gen_robot_print.py
98023a8cfSSushil SinghLibrary              ../../lib/gen_print.py
10c5e9ebc6SSushil SinghLibrary              ../../lib/gen_misc.py
11c5e9ebc6SSushil SinghResource             ../../lib/external_intf/management_console_utils.robot
12a2bf3f3cSSushil SinghResource             ../../lib/redfish_code_update_utils.robot
13c5e9ebc6SSushil SinghResource             ../../lib/boot_utils.robot
14a28061a0SGeorge KeishingResource             ../../lib/os_utilities.robot
15a313c97aSSushil SinghResource             ../../lib/code_update_utils.robot
168023a8cfSSushil Singh
178023a8cfSSushil SinghSuite Setup          Suite Setup Execution
1851be134eSSushil SinghSuite Teardown       Redfish.Logout
1951be134eSSushil SinghTest Setup           Printn
20a2bf3f3cSSushil SinghTest Teardown        FFDC On Test Case Fail
218023a8cfSSushil Singh
228023a8cfSSushil Singh*** Test Cases ***
238023a8cfSSushil Singh
248023a8cfSSushil SinghDiscover BMC With Different Service Type
258023a8cfSSushil Singh    [Documentation]  Discover all the BMC with different service type support.
268023a8cfSSushil Singh    [Tags]  Discover_BMC_With_Different_Service_Type
278023a8cfSSushil Singh    [Template]  Discover BMC With Service Type
288023a8cfSSushil Singh
298023a8cfSSushil Singh    # Service type
308023a8cfSSushil Singh    _obmc_rest._tcp
318023a8cfSSushil Singh    _obmc_redfish._tcp
328023a8cfSSushil Singh
338023a8cfSSushil Singh
34e6edfadbSSushil SinghDiscover BMC Pre And Post Reboot
35e6edfadbSSushil Singh    [Documentation]  Discover BMC before and after reboot.
36e6edfadbSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Reboot
37e6edfadbSSushil Singh    [Template]  Set Daemon And Discover BMC After Reboot
38c5e9ebc6SSushil Singh
39c5e9ebc6SSushil Singh    # Service type
40c5e9ebc6SSushil Singh    _obmc_rest._tcp
41c5e9ebc6SSushil Singh    _obmc_redfish._tcp
42c5e9ebc6SSushil Singh
43e6edfadbSSushil Singh
44e6edfadbSSushil SinghDisable AvahiDaemon And Discover BMC After Reboot
45e20f82cdSGeorge Keishing    [Documentation]  BMC should be discoverable in next reboot even after disabling Avahi daemon.
46e6edfadbSSushil Singh    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
47e6edfadbSSushil Singh    [Template]  Set Daemon And Discover BMC After Reboot
48e6edfadbSSushil Singh
49e6edfadbSSushil Singh    # Service type       skip
50e6edfadbSSushil Singh    _obmc_rest._tcp      True
51e6edfadbSSushil Singh    _obmc_redfish._tcp   True
52e6edfadbSSushil Singh
53a2bf3f3cSSushil Singh
54e46ba2daSSushil SinghDiscover BMC Pre And Post Firmware Update Of Same Release
55e46ba2daSSushil Singh    [Documentation]  Discover BMC, when firmware update occurs for same release.
56e46ba2daSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Same_Release
57a2bf3f3cSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
58a2bf3f3cSSushil Singh
59e46ba2daSSushil Singh    # Service type   Service type        status
60e46ba2daSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp  True
61a2bf3f3cSSushil Singh
626a8cb08fSSushil Singh
63e46ba2daSSushil SinghDiscover BMC Pre And Post Firmware Update Of Different Release
64e46ba2daSSushil Singh    [Documentation]  Discover BMC, when firmware update occurs for different release.
65e46ba2daSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Different_Release
666a8cb08fSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
676a8cb08fSSushil Singh
68e46ba2daSSushil Singh    # Service type   Service type        status
69e46ba2daSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp  True
706a8cb08fSSushil Singh
7151be134eSSushil Singh
72e46ba2daSSushil SinghDiscover BMC Fail After Firmware Update Of Different Release
73e46ba2daSSushil Singh    [Documentation]  Discover BMC fail, when firmware update occurs for different release.
74e46ba2daSSushil Singh    [Tags]  Discover_BMC_Fail_After_Firmware_Update_Of_Different_Release
75e46ba2daSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
76e46ba2daSSushil Singh
77e46ba2daSSushil Singh    # Service type   Service type        status
78e46ba2daSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp  False
79e46ba2daSSushil Singh
80e46ba2daSSushil Singh
81e46ba2daSSushil SinghDiscover BMC Pre And Post When Host Boot InProgress
82e46ba2daSSushil Singh    [Documentation]  Discover BMC, when Host boot in progress.
83e46ba2daSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_When_Host_Boot_InProgress
84e46ba2daSSushil Singh    [Template]  Discover BMC Pre And Post When Host Boot
8551be134eSSushil Singh
8651be134eSSushil Singh    # Service type   Service type
8751be134eSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp
8851be134eSSushil Singh
898023a8cfSSushil Singh*** Keywords ***
908023a8cfSSushil Singh
918023a8cfSSushil SinghSuite Setup Execution
928023a8cfSSushil Singh    [Documentation]  Do the suite setup.
938023a8cfSSushil Singh
948023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT}
958023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
968023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
978023a8cfSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
988023a8cfSSushil Singh    Check Avahi Package
9951be134eSSushil Singh    Redfish.Login
1008023a8cfSSushil Singh
1018023a8cfSSushil Singh
1028023a8cfSSushil SinghCheck Avahi Package
1038023a8cfSSushil Singh    [Documentation]  To check for avahi-tools package.
1048023a8cfSSushil Singh
1058023a8cfSSushil Singh    # Expected command output as below.
1068023a8cfSSushil Singh    # avahi-tools-0.6.31-19.el7.x86_64
1078023a8cfSSushil Singh
1088023a8cfSSushil Singh    ${command}=  Set Variable  rpm -qa | grep avahi-tools
1098023a8cfSSushil Singh    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
1108023a8cfSSushil Singh    Should Be Empty  ${stderr}
1118023a8cfSSushil Singh    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
1128023a8cfSSushil Singh
1138023a8cfSSushil Singh
1148023a8cfSSushil SinghDiscover BMC With Service Type
115*4ebb3281SGeorge Keishing    [Documentation]  To get the discovered BMC list.
1168023a8cfSSushil Singh    [Arguments]  ${service_type}
1178023a8cfSSushil Singh
1188023a8cfSSushil Singh    # Description of argument(s):
1198023a8cfSSushil Singh    # service_type  BMC service type e.g.
1208023a8cfSSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
1218023a8cfSSushil Singh
1228023a8cfSSushil Singh    # bmc_list:
1238023a8cfSSushil Singh    # [1]:
1248023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
1258023a8cfSSushil Singh    #    [hostname]:         System Name
1268023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
1278023a8cfSSushil Singh    #    [port]:             XXX
1288023a8cfSSushil Singh    #    [txt]:
1298023a8cfSSushil Singh    # [2]:
1308023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
1318023a8cfSSushil Singh    #    [hostname]:         System Name
1328023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
1338023a8cfSSushil Singh    #    [port]:             XXX
1348023a8cfSSushil Singh    #    [txt]:
1358023a8cfSSushil Singh
1368023a8cfSSushil Singh    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
1378023a8cfSSushil Singh    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
1388023a8cfSSushil Singh    Print Timen  Exception message is ${exc_msg}
1398023a8cfSSushil Singh    Should Not Be Empty  ${bmc_list}
1408023a8cfSSushil Singh    Rprint Vars  bmc_list
141409df05dSGeorge Keishing    RETURN  ${bmc_list}
142c5e9ebc6SSushil Singh
143c5e9ebc6SSushil Singh
144c5e9ebc6SSushil SinghVerify Existence Of BMC Record From List
145c5e9ebc6SSushil Singh    [Documentation]  Verify the existence of BMC record from list of BMC records.
146c5e9ebc6SSushil Singh    [Arguments]  ${service_type}
147c5e9ebc6SSushil Singh
148c5e9ebc6SSushil Singh    # Description of argument(s):
149c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
150c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
151c5e9ebc6SSushil Singh
152c5e9ebc6SSushil Singh    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
153c5e9ebc6SSushil Singh    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
154c5e9ebc6SSushil Singh    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
155c5e9ebc6SSushil Singh    Should Be True  'True' == '${resp}'
156c5e9ebc6SSushil Singh
157c5e9ebc6SSushil Singh
158e6edfadbSSushil SinghSet Daemon And Discover BMC After Reboot
159c5e9ebc6SSushil Singh    [Documentation]  Discover BMC After reboot.
160e6edfadbSSushil Singh    [Arguments]  ${service_type}  ${skip}=False
161c5e9ebc6SSushil Singh
162c5e9ebc6SSushil Singh    # Description of argument(s):
163c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
164c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
165e6edfadbSSushil Singh    # skip          Default value set to False.
166e6edfadbSSushil Singh    #               If the value is True, Disable the AvahiDaemon.
167e6edfadbSSushil Singh    #               If the value is False, skip the step to disable the AvahiDaemon.
168c5e9ebc6SSushil Singh
169e6edfadbSSushil Singh    Verify Existence Of BMC Record From List  ${service_type}
170e6edfadbSSushil Singh    Run Keyword If  '${skip}' == 'True'  Set AvahiDaemon Service  command=stop
171c5e9ebc6SSushil Singh    Redfish OBMC Reboot (off)
172c5e9ebc6SSushil Singh    Verify AvahiDaemon Service Status  message=start
173c5e9ebc6SSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
174c5e9ebc6SSushil Singh    Wait Until Keyword Succeeds  2 min  30 sec
175c5e9ebc6SSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type}
176a2bf3f3cSSushil Singh
177a2bf3f3cSSushil Singh
178a313c97aSSushil SinghRedfish Update Firmware
179a313c97aSSushil Singh    [Documentation]  Update the BMC firmware via redfish interface and verify the bmc version
180a313c97aSSushil Singh    ...              and apply time.
181a313c97aSSushil Singh    [Arguments]  ${apply_time}
182a313c97aSSushil Singh
183a313c97aSSushil Singh    # Description of argument(s):
184a313c97aSSushil Singh    # apply_time    ApplyTime allowed values (e.g. "OnReset", "Immediate").
185a313c97aSSushil Singh
186a313c97aSSushil Singh    ${post_code_update_actions}=  Get Post Boot Action
187a313c97aSSushil Singh    ${state}=  Get Pre Reboot State
188a313c97aSSushil Singh    Rprint Vars  state
189a313c97aSSushil Singh    Set ApplyTime  policy=${apply_Time}
190a313c97aSSushil Singh    Redfish Upload Image And Check Progress State
191a313c97aSSushil Singh    Run Key  ${post_code_update_actions['BMC image']['${apply_time}']}
192a313c97aSSushil Singh    Redfish.Login
193a313c97aSSushil Singh    Redfish Verify BMC Version  ${IMAGE_FILE_PATH}
194a313c97aSSushil Singh    Verify Get ApplyTime  ${apply_time}
195a313c97aSSushil Singh
196a313c97aSSushil Singh
197a2bf3f3cSSushil SinghDiscover BMC Pre And Post Firmware Update
198a2bf3f3cSSushil Singh    [Documentation]  Discover BMC, After code update.
199a313c97aSSushil Singh    [Arguments]  ${service_type1}  ${service_type2}  ${status}
200a2bf3f3cSSushil Singh
201a2bf3f3cSSushil Singh    # Description of argument(s):
202a2bf3f3cSSushil Singh    # service_type     BMC service type e.g.
203a2bf3f3cSSushil Singh    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
204a313c97aSSushil Singh    # status           True or False
205a2bf3f3cSSushil Singh
206a2bf3f3cSSushil Singh    Valid File Path  IMAGE_FILE_PATH
207a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
208a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
209a313c97aSSushil Singh    Redfish Update Firmware  apply_time=Immediate
210e46ba2daSSushil Singh    ${keyword_status}=  Run Keyword And Return Status
211e46ba2daSSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type1}
212e46ba2daSSushil Singh    Should Be Equal  '${status}'  '${keyword_status}'
213e46ba2daSSushil Singh    ${keyword_status}=  Run Keyword And Return Status
214e46ba2daSSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type2}
215e46ba2daSSushil Singh    Should Be Equal  '${status}'  '${keyword_status}'
21651be134eSSushil Singh
21751be134eSSushil Singh
218e46ba2daSSushil SinghDiscover BMC Pre And Post When Host Boot
219a313c97aSSushil Singh    [Documentation]  Discover BMC, when host boot in progress.
22051be134eSSushil Singh    [Arguments]  ${service_type1}  ${service_type2}
22151be134eSSushil Singh
22251be134eSSushil Singh    # Description of argument(s):
22351be134eSSushil Singh    # service_type     BMC service type e.g.
22451be134eSSushil Singh    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
22551be134eSSushil Singh
22651be134eSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
22751be134eSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
22851be134eSSushil Singh    Redfish Power Off  stack_mode=skip
22951be134eSSushil Singh    Get Host Power State
23051be134eSSushil Singh    Redfish Power Operation  reset_type=On
23151be134eSSushil Singh    Sleep  15s
23251be134eSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
23351be134eSSushil Singh    FOR  ${index}  IN RANGE  10
23451be134eSSushil Singh        Sleep  3s
23551be134eSSushil Singh        Verify Existence Of BMC Record From List  ${service_type1}
23651be134eSSushil Singh        Verify Existence Of BMC Record From List  ${service_type2}
23751be134eSSushil Singh    END
23851be134eSSushil Singh    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Booted
239