xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_discovery.robot (revision e20f82cdaf153b512a0a2fd53220e2d9b64f1e84)
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
44*e20f82cdSGeorge 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
53a2bf3f3cSSushil SinghDiscover BMC Pre And Post Firmware Update Of Same Build
54a2bf3f3cSSushil Singh    [Documentation]  Discover BMC, when code update occurs for same build.
55a2bf3f3cSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Same_Build
56a2bf3f3cSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
57a2bf3f3cSSushil Singh
58a2bf3f3cSSushil Singh    # Service type   Service type
59a2bf3f3cSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp
60a2bf3f3cSSushil Singh
616a8cb08fSSushil Singh
626a8cb08fSSushil SinghDiscover BMC Pre And Post Firmware Update Of Different Build
6351be134eSSushil Singh    [Documentation]  Discover BMC, when code update occurs for different release.
646a8cb08fSSushil Singh    [Tags]  Discover_BMC_Pre_And_Post_Firmware_Update_Of_Different_Build
656a8cb08fSSushil Singh    [Template]  Discover BMC Pre And Post Firmware Update
666a8cb08fSSushil Singh
676a8cb08fSSushil Singh    # Service type   Service type
686a8cb08fSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp
696a8cb08fSSushil Singh
7051be134eSSushil Singh
7151be134eSSushil SinghDiscover BMC Pre And While Host Boot InProgress
7251be134eSSushil Singh    [Documentation]  Discover BMC, while Host boot in progress.
7351be134eSSushil Singh    [Tags]  Discover_BMC_Pre_And_While_Host_Boot_InProgress
7451be134eSSushil Singh    [Template]  Discover BMC Before And During Host Boot
7551be134eSSushil Singh
7651be134eSSushil Singh    # Service type   Service type
7751be134eSSushil Singh    _obmc_rest._tcp  _obmc_redfish._tcp
7851be134eSSushil Singh
798023a8cfSSushil Singh*** Keywords ***
808023a8cfSSushil Singh
818023a8cfSSushil SinghSuite Setup Execution
828023a8cfSSushil Singh    [Documentation]  Do the suite setup.
838023a8cfSSushil Singh
848023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT}
858023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
868023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
878023a8cfSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
888023a8cfSSushil Singh    Check Avahi Package
8951be134eSSushil Singh    Redfish.Login
908023a8cfSSushil Singh
918023a8cfSSushil Singh
928023a8cfSSushil SinghCheck Avahi Package
938023a8cfSSushil Singh    [Documentation]  To check for avahi-tools package.
948023a8cfSSushil Singh
958023a8cfSSushil Singh    # Expected command output as below.
968023a8cfSSushil Singh    # avahi-tools-0.6.31-19.el7.x86_64
978023a8cfSSushil Singh
988023a8cfSSushil Singh    ${command}=  Set Variable  rpm -qa | grep avahi-tools
998023a8cfSSushil Singh    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
1008023a8cfSSushil Singh    Should Be Empty  ${stderr}
1018023a8cfSSushil Singh    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
1028023a8cfSSushil Singh
1038023a8cfSSushil Singh
1048023a8cfSSushil SinghDiscover BMC With Service Type
1058023a8cfSSushil Singh    [Documentation]  To get the discoverd BMC list.
1068023a8cfSSushil Singh    [Arguments]  ${service_type}
1078023a8cfSSushil Singh
1088023a8cfSSushil Singh    # Description of argument(s):
1098023a8cfSSushil Singh    # service_type  BMC service type e.g.
1108023a8cfSSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
1118023a8cfSSushil Singh
1128023a8cfSSushil Singh    # bmc_list:
1138023a8cfSSushil Singh    # [1]:
1148023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
1158023a8cfSSushil Singh    #    [hostname]:         System Name
1168023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
1178023a8cfSSushil Singh    #    [port]:             XXX
1188023a8cfSSushil Singh    #    [txt]:
1198023a8cfSSushil Singh    # [2]:
1208023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
1218023a8cfSSushil Singh    #    [hostname]:         System Name
1228023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
1238023a8cfSSushil Singh    #    [port]:             XXX
1248023a8cfSSushil Singh    #    [txt]:
1258023a8cfSSushil Singh
1268023a8cfSSushil Singh    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
1278023a8cfSSushil Singh    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
1288023a8cfSSushil Singh    Print Timen  Exception message is ${exc_msg}
1298023a8cfSSushil Singh    Should Not Be Empty  ${bmc_list}
1308023a8cfSSushil Singh    Rprint Vars  bmc_list
131c5e9ebc6SSushil Singh    [Return]  ${bmc_list}
132c5e9ebc6SSushil Singh
133c5e9ebc6SSushil Singh
134c5e9ebc6SSushil SinghVerify Existence Of BMC Record From List
135c5e9ebc6SSushil Singh    [Documentation]  Verify the existence of BMC record from list of BMC records.
136c5e9ebc6SSushil Singh    [Arguments]  ${service_type}
137c5e9ebc6SSushil Singh
138c5e9ebc6SSushil Singh    # Description of argument(s):
139c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
140c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
141c5e9ebc6SSushil Singh
142c5e9ebc6SSushil Singh    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
143c5e9ebc6SSushil Singh    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
144c5e9ebc6SSushil Singh    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
145c5e9ebc6SSushil Singh    Should Be True  'True' == '${resp}'
146c5e9ebc6SSushil Singh
147c5e9ebc6SSushil Singh
148e6edfadbSSushil SinghSet Daemon And Discover BMC After Reboot
149c5e9ebc6SSushil Singh    [Documentation]  Discover BMC After reboot.
150e6edfadbSSushil Singh    [Arguments]  ${service_type}  ${skip}=False
151c5e9ebc6SSushil Singh
152c5e9ebc6SSushil Singh    # Description of argument(s):
153c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
154c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
155e6edfadbSSushil Singh    # skip          Default value set to False.
156e6edfadbSSushil Singh    #               If the value is True, Disable the AvahiDaemon.
157e6edfadbSSushil Singh    #               If the value is False, skip the step to disable the AvahiDaemon.
158c5e9ebc6SSushil Singh
159e6edfadbSSushil Singh    Verify Existence Of BMC Record From List  ${service_type}
160e6edfadbSSushil Singh    Run Keyword If  '${skip}' == 'True'  Set AvahiDaemon Service  command=stop
161c5e9ebc6SSushil Singh    Redfish OBMC Reboot (off)
162c5e9ebc6SSushil Singh    Verify AvahiDaemon Service Status  message=start
163c5e9ebc6SSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
164c5e9ebc6SSushil Singh    Wait Until Keyword Succeeds  2 min  30 sec
165c5e9ebc6SSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type}
166a2bf3f3cSSushil Singh
167a2bf3f3cSSushil Singh
168a2bf3f3cSSushil SinghDiscover BMC Pre And Post Firmware Update
169a2bf3f3cSSushil Singh    [Documentation]  Discover BMC, After code update.
170a2bf3f3cSSushil Singh    [Arguments]  ${service_type1}  ${service_type2}
171a2bf3f3cSSushil Singh
172a2bf3f3cSSushil Singh    # Description of argument(s):
173a2bf3f3cSSushil Singh    # service_type     BMC service type e.g.
174a2bf3f3cSSushil Singh    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
175a2bf3f3cSSushil Singh
176a2bf3f3cSSushil Singh    Valid File Path  IMAGE_FILE_PATH
177a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
178a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
179a2bf3f3cSSushil Singh    Redfish Update Firmware  apply_time=Immediate   image_type=BMC image
180a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
181a2bf3f3cSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
18251be134eSSushil Singh
18351be134eSSushil Singh
18451be134eSSushil SinghDiscover BMC Before And During Host Boot
18551be134eSSushil Singh    [Documentation]  Discover BMC, when host boot in progress.
18651be134eSSushil Singh    [Arguments]  ${service_type1}  ${service_type2}
18751be134eSSushil Singh
18851be134eSSushil Singh    # Description of argument(s):
18951be134eSSushil Singh    # service_type     BMC service type e.g.
19051be134eSSushil Singh    #                  (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
19151be134eSSushil Singh
19251be134eSSushil Singh    Verify Existence Of BMC Record From List  ${service_type1}
19351be134eSSushil Singh    Verify Existence Of BMC Record From List  ${service_type2}
19451be134eSSushil Singh    Redfish Power Off  stack_mode=skip
19551be134eSSushil Singh    Get Host Power State
19651be134eSSushil Singh    Redfish Power Operation  reset_type=On
19751be134eSSushil Singh    Sleep  15s
19851be134eSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
19951be134eSSushil Singh    FOR  ${index}  IN RANGE  10
20051be134eSSushil Singh        Sleep  3s
20151be134eSSushil Singh        Verify Existence Of BMC Record From List  ${service_type1}
20251be134eSSushil Singh        Verify Existence Of BMC Record From List  ${service_type2}
20351be134eSSushil Singh    END
20451be134eSSushil Singh    Wait Until Keyword Succeeds  10 min  10 sec  Is OS Booted
205