xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_discovery.robot (revision e46ba2da09b8ac8e4076ed3b75946ff1c8fa94ff)
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
148023a8cfSSushil SinghResource             ../../syslib/utils_os.robot
158023a8cfSSushil Singh
168023a8cfSSushil SinghSuite Setup          Suite Setup Execution
1751be134eSSushil SinghSuite Teardown       Redfish.Logout
1851be134eSSushil SinghTest Setup           Printn
19a2bf3f3cSSushil SinghTest Teardown        FFDC On Test Case Fail
208023a8cfSSushil Singh
218023a8cfSSushil Singh*** Test Cases ***
228023a8cfSSushil Singh
238023a8cfSSushil SinghDiscover BMC With Different Service Type
248023a8cfSSushil Singh    [Documentation]  Discover all the BMC with different service type support.
258023a8cfSSushil Singh    [Tags]  Discover_BMC_With_Different_Service_Type
268023a8cfSSushil Singh    [Template]  Discover BMC With Service Type
278023a8cfSSushil Singh
288023a8cfSSushil Singh    # Service type
298023a8cfSSushil Singh    _obmc_rest._tcp
308023a8cfSSushil Singh    _obmc_redfish._tcp
318023a8cfSSushil Singh
328023a8cfSSushil Singh
33e6edfadbSSushil SinghDiscover BMC Pre And Post Reboot
34e6edfadbSSushil Singh    [Documentation]  Discover BMC before and after reboot.
35e6edfadbSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Reboot
36e6edfadbSSushil Singh    [Template]  Set Daemon And Discover BMC After Reboot
37c5e9ebc6SSushil Singh
38c5e9ebc6SSushil Singh    # Service type
39c5e9ebc6SSushil Singh    _obmc_rest._tcp
40c5e9ebc6SSushil Singh    _obmc_redfish._tcp
41c5e9ebc6SSushil Singh
42e6edfadbSSushil Singh
43e6edfadbSSushil SinghDisable AvahiDaemon And Discover BMC After Reboot
44e20f82cdSGeorge Keishing    [Documentation]  BMC should be discoverable in next reboot even after disabling Avahi daemon.
45e6edfadbSSushil Singh    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
46e6edfadbSSushil Singh    [Template]  Set Daemon And Discover BMC After Reboot
47e6edfadbSSushil Singh
48e6edfadbSSushil Singh    # Service type       skip
49e6edfadbSSushil Singh    _obmc_rest._tcp      True
50e6edfadbSSushil Singh    _obmc_redfish._tcp   True
51e6edfadbSSushil Singh
52a2bf3f3cSSushil Singh
53*e46ba2daSSushil SinghDiscover BMC Pre And Post Firmware Update Of Same Release
54*e46ba2daSSushil Singh    [Documentation]  Discover BMC, when firmware update occurs for same release.
55*e46ba2daSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Same_Release
56a2bf3f3cSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
57a2bf3f3cSSushil Singh
58*e46ba2daSSushil Singh    # Service type   Service type        status
59*e46ba2daSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp  True
60a2bf3f3cSSushil Singh
616a8cb08fSSushil Singh
62*e46ba2daSSushil SinghDiscover BMC Pre And Post Firmware Update Of Different Release
63*e46ba2daSSushil Singh    [Documentation]  Discover BMC, when firmware update occurs for different release.
64*e46ba2daSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Different_Release
656a8cb08fSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
666a8cb08fSSushil Singh
67*e46ba2daSSushil Singh    # Service type   Service type        status
68*e46ba2daSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp  True
696a8cb08fSSushil Singh
7051be134eSSushil Singh
71*e46ba2daSSushil SinghDiscover BMC Fail After Firmware Update Of Different Release
72*e46ba2daSSushil Singh    [Documentation]  Discover BMC fail, when firmware update occurs for different release.
73*e46ba2daSSushil Singh    [Tags]  Discover_BMC_Fail_After_Firmware_Update_Of_Different_Release
74*e46ba2daSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
75*e46ba2daSSushil Singh
76*e46ba2daSSushil Singh    # Service type   Service type        status
77*e46ba2daSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp  False
78*e46ba2daSSushil Singh
79*e46ba2daSSushil Singh
80*e46ba2daSSushil SinghDiscover BMC Pre And Post When Host Boot InProgress
81*e46ba2daSSushil Singh    [Documentation]  Discover BMC, when Host boot in progress.
82*e46ba2daSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_When_Host_Boot_InProgress
83*e46ba2daSSushil Singh    [Template]  Discover BMC Pre And Post When Host Boot
8451be134eSSushil Singh
8551be134eSSushil Singh    # Service type   Service type
8651be134eSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp
8751be134eSSushil Singh
888023a8cfSSushil Singh*** Keywords ***
898023a8cfSSushil Singh
908023a8cfSSushil SinghSuite Setup Execution
918023a8cfSSushil Singh    [Documentation]  Do the suite setup.
928023a8cfSSushil Singh
938023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT}
948023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
958023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
968023a8cfSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
978023a8cfSSushil Singh    Check Avahi Package
9851be134eSSushil Singh    Redfish.Login
998023a8cfSSushil Singh
1008023a8cfSSushil Singh
1018023a8cfSSushil SinghCheck Avahi Package
1028023a8cfSSushil Singh    [Documentation]  To check for avahi-tools package.
1038023a8cfSSushil Singh
1048023a8cfSSushil Singh    # Expected command output as below.
1058023a8cfSSushil Singh    # avahi-tools-0.6.31-19.el7.x86_64
1068023a8cfSSushil Singh
1078023a8cfSSushil Singh    ${command}=  Set Variable  rpm -qa | grep avahi-tools
1088023a8cfSSushil Singh    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
1098023a8cfSSushil Singh    Should Be Empty  ${stderr}
1108023a8cfSSushil Singh    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
1118023a8cfSSushil Singh
1128023a8cfSSushil Singh
1138023a8cfSSushil SinghDiscover BMC With Service Type
1148023a8cfSSushil Singh    [Documentation]  To get the discoverd BMC list.
1158023a8cfSSushil Singh    [Arguments]  ${service_type}
1168023a8cfSSushil Singh
1178023a8cfSSushil Singh    # Description of argument(s):
1188023a8cfSSushil Singh    # service_type  BMC service type e.g.
1198023a8cfSSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
1208023a8cfSSushil Singh
1218023a8cfSSushil Singh    # bmc_list:
1228023a8cfSSushil Singh    # [1]:
1238023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
1248023a8cfSSushil Singh    #    [hostname]:         System Name
1258023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
1268023a8cfSSushil Singh    #    [port]:             XXX
1278023a8cfSSushil Singh    #    [txt]:
1288023a8cfSSushil Singh    # [2]:
1298023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
1308023a8cfSSushil Singh    #    [hostname]:         System Name
1318023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
1328023a8cfSSushil Singh    #    [port]:             XXX
1338023a8cfSSushil Singh    #    [txt]:
1348023a8cfSSushil Singh
1358023a8cfSSushil Singh    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
1368023a8cfSSushil Singh    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
1378023a8cfSSushil Singh    Print Timen  Exception message is ${exc_msg}
1388023a8cfSSushil Singh    Should Not Be Empty  ${bmc_list}
1398023a8cfSSushil Singh    Rprint Vars  bmc_list
140c5e9ebc6SSushil Singh    [Return]  ${bmc_list}
141c5e9ebc6SSushil Singh
142c5e9ebc6SSushil Singh
143c5e9ebc6SSushil SinghVerify Existence Of BMC Record From List
144c5e9ebc6SSushil Singh    [Documentation]  Verify the existence of BMC record from list of BMC records.
145c5e9ebc6SSushil Singh    [Arguments]  ${service_type}
146c5e9ebc6SSushil Singh
147c5e9ebc6SSushil Singh    # Description of argument(s):
148c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
149c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
150c5e9ebc6SSushil Singh
151c5e9ebc6SSushil Singh    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
152c5e9ebc6SSushil Singh    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
153c5e9ebc6SSushil Singh    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
154c5e9ebc6SSushil Singh    Should Be True  'True' == '${resp}'
155c5e9ebc6SSushil Singh
156c5e9ebc6SSushil Singh
157e6edfadbSSushil SinghSet Daemon And Discover BMC After Reboot
158c5e9ebc6SSushil Singh    [Documentation]  Discover BMC After reboot.
159e6edfadbSSushil Singh    [Arguments]  ${service_type}  ${skip}=False
160c5e9ebc6SSushil Singh
161c5e9ebc6SSushil Singh    # Description of argument(s):
162c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
163c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
164e6edfadbSSushil Singh    # skip          Default value set to False.
165e6edfadbSSushil Singh    #               If the value is True, Disable the AvahiDaemon.
166e6edfadbSSushil Singh    #               If the value is False, skip the step to disable the AvahiDaemon.
167c5e9ebc6SSushil Singh
168e6edfadbSSushil Singh    Verify Existence Of BMC Record From List  ${service_type}
169e6edfadbSSushil Singh    Run Keyword If  '${skip}' == 'True'  Set AvahiDaemon Service  command=stop
170c5e9ebc6SSushil Singh    Redfish OBMC Reboot (off)
171c5e9ebc6SSushil Singh    Verify AvahiDaemon Service Status  message=start
172c5e9ebc6SSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
173c5e9ebc6SSushil Singh    Wait Until Keyword Succeeds  2 min  30 sec
174c5e9ebc6SSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type}
175a2bf3f3cSSushil Singh
176a2bf3f3cSSushil Singh
177a2bf3f3cSSushil SinghDiscover BMC Pre And Post Firmware Update
178a2bf3f3cSSushil Singh    [Documentation]  Discover BMC, After code update.
179a2bf3f3cSSushil Singh    [Arguments]  ${service_type1}  ${service_type2}
180a2bf3f3cSSushil Singh
181a2bf3f3cSSushil Singh    # Description of argument(s):
182a2bf3f3cSSushil Singh    # service_type     BMC service type e.g.
183a2bf3f3cSSushil Singh    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
184a2bf3f3cSSushil Singh
185a2bf3f3cSSushil Singh    Valid File Path  IMAGE_FILE_PATH
186a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
187a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
188a2bf3f3cSSushil Singh    Redfish Update Firmware  apply_time=Immediate   image_type=BMC image
189*e46ba2daSSushil Singh    ${keyword_status}=  Run Keyword And Return Status
190*e46ba2daSSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type1}
191*e46ba2daSSushil Singh    Should Be Equal  '${status}'  '${keyword_status}'
192*e46ba2daSSushil Singh    ${keyword_status}=  Run Keyword And Return Status
193*e46ba2daSSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type2}
194*e46ba2daSSushil Singh    Should Be Equal  '${status}'  '${keyword_status}'
19551be134eSSushil Singh
19651be134eSSushil Singh
197*e46ba2daSSushil SinghDiscover BMC Pre And Post When Host Boot
198*e46ba2daSSushil Singh    [Documentation]  Discover BMC, when host boot progress.
19951be134eSSushil Singh    [Arguments]  ${service_type1}  ${service_type2}
20051be134eSSushil Singh
20151be134eSSushil Singh    # Description of argument(s):
20251be134eSSushil Singh    # service_type     BMC service type e.g.
20351be134eSSushil Singh    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
20451be134eSSushil Singh
20551be134eSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
20651be134eSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
20751be134eSSushil Singh    Redfish Power Off  stack_mode=skip
20851be134eSSushil Singh    Get Host Power State
20951be134eSSushil Singh    Redfish Power Operation  reset_type=On
21051be134eSSushil Singh    Sleep  15s
21151be134eSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
21251be134eSSushil Singh    FOR  ${index}  IN RANGE  10
21351be134eSSushil Singh        Sleep  3s
21451be134eSSushil Singh        Verify Existence Of BMC Record From List  ${service_type1}
21551be134eSSushil Singh        Verify Existence Of BMC Record From List  ${service_type2}
21651be134eSSushil Singh    END
21751be134eSSushil Singh    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Booted
218