xref: /openbmc/openbmc-test-automation/openpower/ext_interfaces/test_discovery.robot (revision c5e9ebc68157a13c4a6602e10a42c5aed69d887b)
18023a8cfSSushil Singh*** Settings ***
2*c5e9ebc6SSushil SinghDocumentation        Test to discover the BMC. Before running suit,
3*c5e9ebc6SSushil 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
10*c5e9ebc6SSushil SinghLibrary              ../../lib/gen_misc.py
11*c5e9ebc6SSushil SinghResource             ../../lib/external_intf/management_console_utils.robot
12*c5e9ebc6SSushil SinghResource             ../../lib/boot_utils.robot
138023a8cfSSushil SinghResource             ../../syslib/utils_os.robot
148023a8cfSSushil Singh
158023a8cfSSushil SinghSuite Setup          Suite Setup Execution
168023a8cfSSushil Singh
178023a8cfSSushil Singh*** Test Cases ***
188023a8cfSSushil Singh
198023a8cfSSushil SinghDiscover BMC With Different Service Type
208023a8cfSSushil Singh    [Documentation]  Discover all the BMC with different service type support.
218023a8cfSSushil Singh    [Tags]  Discover_BMC_With_Different_Service_Type
228023a8cfSSushil Singh    [Template]  Discover BMC With Service Type
238023a8cfSSushil Singh
248023a8cfSSushil Singh    # Service type
258023a8cfSSushil Singh    _obmc_rest._tcp
268023a8cfSSushil Singh    _obmc_redfish._tcp
278023a8cfSSushil Singh
288023a8cfSSushil Singh
29*c5e9ebc6SSushil SinghDisable AvahiDaemon And Discover BMC After Reboot
30*c5e9ebc6SSushil Singh    [Documentation]  Check the input BMC is discoverd and then disable the avahi daemon,
31*c5e9ebc6SSushil Singh    ...  in next reboot same input BMC should discoverable.
32*c5e9ebc6SSushil Singh    [Tags]  Disable_AvahiDaemon_And_Discover_BMC_After_Reboot
33*c5e9ebc6SSushil Singh    [Template]  Disable Daemon And Discover BMC After Reboot
34*c5e9ebc6SSushil Singh
35*c5e9ebc6SSushil Singh    # Service type
36*c5e9ebc6SSushil Singh    _obmc_rest._tcp
37*c5e9ebc6SSushil Singh    _obmc_redfish._tcp
38*c5e9ebc6SSushil Singh
398023a8cfSSushil Singh*** Keywords ***
408023a8cfSSushil Singh
418023a8cfSSushil SinghSuite Setup Execution
428023a8cfSSushil Singh    [Documentation]  Do the suite setup.
438023a8cfSSushil Singh
448023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT}
458023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_USERNAME}
468023a8cfSSushil Singh    Should Not Be Empty  ${AVAHI_CLIENT_PASSWORD}
478023a8cfSSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
488023a8cfSSushil Singh    Check Avahi Package
498023a8cfSSushil Singh
508023a8cfSSushil Singh
518023a8cfSSushil SinghCheck Avahi Package
528023a8cfSSushil Singh    [Documentation]  To check for avahi-tools package.
538023a8cfSSushil Singh
548023a8cfSSushil Singh    # Expected command output as below.
558023a8cfSSushil Singh    # avahi-tools-0.6.31-19.el7.x86_64
568023a8cfSSushil Singh
578023a8cfSSushil Singh    ${command}=  Set Variable  rpm -qa | grep avahi-tools
588023a8cfSSushil Singh    ${resp_rpm}  ${stderr}=  Execute Command  ${command}  return_stderr=True
598023a8cfSSushil Singh    Should Be Empty  ${stderr}
608023a8cfSSushil Singh    Should Contain  ${resp_rpm}  avahi-tools  ignore_case=True  msg=avahi-tools is not available.
618023a8cfSSushil Singh
628023a8cfSSushil Singh
638023a8cfSSushil SinghDiscover BMC With Service Type
648023a8cfSSushil Singh    [Documentation]  To get the discoverd BMC list.
658023a8cfSSushil Singh    [Arguments]  ${service_type}
668023a8cfSSushil Singh
678023a8cfSSushil Singh    # Description of argument(s):
688023a8cfSSushil Singh    # service_type  BMC service type e.g.
698023a8cfSSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
708023a8cfSSushil Singh
718023a8cfSSushil Singh    # bmc_list:
728023a8cfSSushil Singh    # [1]:
738023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
748023a8cfSSushil Singh    #    [hostname]:         System Name
758023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
768023a8cfSSushil Singh    #    [port]:             XXX
778023a8cfSSushil Singh    #    [txt]:
788023a8cfSSushil Singh    # [2]:
798023a8cfSSushil Singh    #    [service]:          _obmc_XXXX._tcp
808023a8cfSSushil Singh    #    [hostname]:         System Name
818023a8cfSSushil Singh    #    [address]:          XXX.XXX.XXX.XXX
828023a8cfSSushil Singh    #    [port]:             XXX
838023a8cfSSushil Singh    #    [txt]:
848023a8cfSSushil Singh
858023a8cfSSushil Singh    ${resp_service}  ${stderr}=  Execute Command  avahi-browse -rt ${service_type}  return_stderr=True
868023a8cfSSushil Singh    ${bmc_list}  ${exc_msg}=  Get BMC Records  ${service_type}  ${resp_service}
878023a8cfSSushil Singh    Print Timen  Exception message is ${exc_msg}
888023a8cfSSushil Singh    Should Not Be Empty  ${bmc_list}
898023a8cfSSushil Singh    Rprint Vars  bmc_list
90*c5e9ebc6SSushil Singh    [Return]  ${bmc_list}
91*c5e9ebc6SSushil Singh
92*c5e9ebc6SSushil Singh
93*c5e9ebc6SSushil SinghVerify Existence Of BMC Record From List
94*c5e9ebc6SSushil Singh    [Documentation]  Verify the existence of BMC record from list of BMC records.
95*c5e9ebc6SSushil Singh    [Arguments]  ${service_type}
96*c5e9ebc6SSushil Singh
97*c5e9ebc6SSushil Singh    # Description of argument(s):
98*c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
99*c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
100*c5e9ebc6SSushil Singh
101*c5e9ebc6SSushil Singh    ${bmc_list}=  Discover BMC With Service Type  ${service_type}
102*c5e9ebc6SSushil Singh    ${openbmc_host_name}  ${openbmc_ip}=  Get Host Name IP  host=${OPENBMC_HOST}
103*c5e9ebc6SSushil Singh    ${resp}=  Check BMC Record Exists  ${bmc_list}  ${openbmc_ip}
104*c5e9ebc6SSushil Singh    Should Be True  'True' == '${resp}'
105*c5e9ebc6SSushil Singh
106*c5e9ebc6SSushil Singh
107*c5e9ebc6SSushil SinghDisable Daemon And Discover BMC After Reboot
108*c5e9ebc6SSushil Singh    [Documentation]  Discover BMC After reboot.
109*c5e9ebc6SSushil Singh    [Arguments]  ${service_type}
110*c5e9ebc6SSushil Singh
111*c5e9ebc6SSushil Singh    # Description of argument(s):
112*c5e9ebc6SSushil Singh    # service_type  BMC service type e.g.
113*c5e9ebc6SSushil Singh    #               (REST Service = _obmc_rest._tcp, Redfish Service = _obmc_redfish._tcp).
114*c5e9ebc6SSushil Singh
115*c5e9ebc6SSushil Singh    Set AvahiDaemon Service  command=stop
116*c5e9ebc6SSushil Singh    Redfish OBMC Reboot (off)
117*c5e9ebc6SSushil Singh    Verify AvahiDaemon Service Status  message=start
118*c5e9ebc6SSushil Singh    Login To OS  ${AVAHI_CLIENT}  ${AVAHI_CLIENT_USERNAME}  ${AVAHI_CLIENT_PASSWORD}
119*c5e9ebc6SSushil Singh    Wait Until Keyword Succeeds  2 min  30 sec
120*c5e9ebc6SSushil Singh    ...  Verify Existence Of BMC Record From List  ${service_type}
121