1*3468df56SSteven Sombar*** Settings *** 2*3468df56SSteven Sombar 3*3468df56SSteven SombarDocumentation Websocket functionality test. 4*3468df56SSteven Sombar 5*3468df56SSteven Sombar# Test Parameters: 6*3468df56SSteven Sombar# OPENBMC_HOST The BMC host name or IP address. 7*3468df56SSteven Sombar# OPENBMC_USERNAME The username for the BMC login. 8*3468df56SSteven Sombar# OPENBMC_PASSWORD The password for OPENBMC_USERNAME. 9*3468df56SSteven Sombar# OS_HOST The OS host name or IP address. 10*3468df56SSteven Sombar# OS_USERNAME The username for the OS login. 11*3468df56SSteven Sombar# OS_PASSWORD The password for OS_USERNAME. 12*3468df56SSteven Sombar 13*3468df56SSteven SombarResource ../../lib/esel_utils.robot 14*3468df56SSteven SombarResource ../../lib/bmc_redfish_resource.robot 15*3468df56SSteven SombarResource ../../lib/logging_utils.robot 16*3468df56SSteven SombarLibrary ../../lib/gen_cmd.py 17*3468df56SSteven SombarLibrary OperatingSystem 18*3468df56SSteven Sombar 19*3468df56SSteven Sombar 20*3468df56SSteven SombarSuite Setup Suite Setup Execution 21*3468df56SSteven SombarSuite Teardown Suite Teardown Execution 22*3468df56SSteven SombarTest Teardown Test Teardown Execution 23*3468df56SSteven Sombar 24*3468df56SSteven Sombar 25*3468df56SSteven Sombar*** Variables *** 26*3468df56SSteven Sombar 27*3468df56SSteven Sombar${monitor_pgm} bin/websocket_monitor.py 28*3468df56SSteven Sombar${monitor_file} websocket_monitor_out.txt 29*3468df56SSteven Sombar${expected_string} eSEL received over websocket interface 30*3468df56SSteven Sombar${min_number_chars} 22 31*3468df56SSteven Sombar${monitor_cmd} ${monitor_pgm} ${OPENBMC_HOST} --openbmc_username ${OPENBMC_USERNAME} 32*3468df56SSteven Sombar 33*3468df56SSteven Sombar 34*3468df56SSteven Sombar*** Test Cases *** 35*3468df56SSteven Sombar 36*3468df56SSteven Sombar 37*3468df56SSteven SombarTest BMC Websocket Interface 38*3468df56SSteven Sombar [Documentation] Verify eSELs are seen over the websocket interface. 39*3468df56SSteven Sombar [Tags] Test_BMC_Websocket_Interface 40*3468df56SSteven Sombar 41*3468df56SSteven Sombar # Spawn the websocket monitor program and then generate an eSEL. 42*3468df56SSteven Sombar # The monitor should asynchronously receive the eSEL through the 43*3468df56SSteven Sombar # websocket interface and report this fact to standard output. 44*3468df56SSteven Sombar 45*3468df56SSteven Sombar Start Websocket Monitor 46*3468df56SSteven Sombar 47*3468df56SSteven Sombar ${initial_esel_count}= Get Number Of Event Logs 48*3468df56SSteven Sombar 49*3468df56SSteven Sombar # Generate eSEL (e.g. typically "CPU 1 core 3 has failed"). 50*3468df56SSteven Sombar Create eSEL 51*3468df56SSteven Sombar 52*3468df56SSteven Sombar ${current_esel_count}= Get Number Of Event Logs 53*3468df56SSteven Sombar 54*3468df56SSteven Sombar Run Keyword If ${initial_esel_count} == ${current_esel_count} 55*3468df56SSteven Sombar ... Fail msg=System failed to generate eSEL upon request. 56*3468df56SSteven Sombar 57*3468df56SSteven Sombar ${line}= Grep File ${monitor_file} ${expected_string} 58*3468df56SSteven Sombar # Typical monitor_file contents: 59*3468df56SSteven Sombar # --------------- ON_MESSAGE:begin -------------------- 60*3468df56SSteven Sombar # {"event":"PropertiesChanged","interface":"xyz.openbmc_project.Logging. 61*3468df56SSteven Sombar # Entry","path":"/xyz/openbmc_project/logging/entry/5","properties":{"Id":5}} 62*3468df56SSteven Sombar # eSEL received over websocket interface. 63*3468df56SSteven Sombar 64*3468df56SSteven Sombar ${num_chars}= Get Length ${line} 65*3468df56SSteven Sombar Run Keyword If ${num_chars} < ${min_number_chars} Fail 66*3468df56SSteven Sombar ... msg=No eSEL notification from websocket_monitor.py. 67*3468df56SSteven Sombar 68*3468df56SSteven Sombar 69*3468df56SSteven Sombar*** Keywords *** 70*3468df56SSteven Sombar 71*3468df56SSteven Sombar 72*3468df56SSteven SombarStart Websocket Monitor 73*3468df56SSteven Sombar [Documentation] Fork the monitor to run in the background. 74*3468df56SSteven Sombar 75*3468df56SSteven Sombar # Delete the previous output file, if any. 76*3468df56SSteven Sombar Remove File ${monitor_file} 77*3468df56SSteven Sombar 78*3468df56SSteven Sombar # Start the monitor. Fork so its a parallel task. 79*3468df56SSteven Sombar Shell Cmd 80*3468df56SSteven Sombar ... ${monitor_cmd} --openbmc_password ${OPENBMC_PASSWORD} 1>${monitor_file} 2>&1 fork=${1} 81*3468df56SSteven Sombar 82*3468df56SSteven Sombar # Allow time for the monitor to initialize. 83*3468df56SSteven Sombar Sleep 5s 84*3468df56SSteven Sombar 85*3468df56SSteven Sombar 86*3468df56SSteven SombarFind Websocket Monitor 87*3468df56SSteven Sombar [Documentation] Return the process Id(s) of running websocket monitors. 88*3468df56SSteven Sombar 89*3468df56SSteven Sombar ${cmd}= Catenate ps -ef | grep '${monitor_cmd}' 90*3468df56SSteven Sombar ... | grep -v grep | grep -v bash | cut -c10-14 91*3468df56SSteven Sombar ${shell_rc} ${pid}= Shell Cmd ${cmd} 92*3468df56SSteven Sombar # There may be more than one pid returned if there is an instance 93*3468df56SSteven Sombar # of a monitory_pgm running from a previous run. 94*3468df56SSteven Sombar @{pid_list}= Split String ${pid} 95*3468df56SSteven Sombar [Return] ${pid_list} 96*3468df56SSteven Sombar 97*3468df56SSteven Sombar 98*3468df56SSteven SombarKill Websocket Monitor 99*3468df56SSteven Sombar [Documentation] Terminate running websocket monitor. 100*3468df56SSteven Sombar 101*3468df56SSteven Sombar ${pid_list}= Find Websocket Monitor 102*3468df56SSteven Sombar FOR ${pid} IN @{pid_list} 103*3468df56SSteven Sombar Shell Cmd kill -s SIGTERM ${pid} 104*3468df56SSteven Sombar END 105*3468df56SSteven Sombar 106*3468df56SSteven Sombar 107*3468df56SSteven SombarPrint Websocket Monitor Log 108*3468df56SSteven Sombar [Documentation] Show the contents of the monitor output file. 109*3468df56SSteven Sombar 110*3468df56SSteven Sombar ${websocket_monitor_log}= OperatingSystem.Get File ${monitor_file} 111*3468df56SSteven Sombar Log to Console websocket_monitor_log: 112*3468df56SSteven Sombar Log to Console ${websocket_monitor_log} 113*3468df56SSteven Sombar 114*3468df56SSteven Sombar 115*3468df56SSteven SombarSuite Setup Execution 116*3468df56SSteven Sombar [Documentation] Do the suite setup tasks. 117*3468df56SSteven Sombar 118*3468df56SSteven Sombar Run Keyword Redfish Power On stack_mode=skip 119*3468df56SSteven Sombar 120*3468df56SSteven Sombar Redfish.Login 121*3468df56SSteven Sombar 122*3468df56SSteven Sombar Delete All Error Logs 123*3468df56SSteven Sombar Kill Websocket Monitor 124*3468df56SSteven Sombar 125*3468df56SSteven Sombar # Allow time for Error Logs to be deleted. 126*3468df56SSteven Sombar Sleep 5s 127*3468df56SSteven Sombar 128*3468df56SSteven Sombar 129*3468df56SSteven SombarTest Teardown Execution 130*3468df56SSteven Sombar [Documentation] Do teardown tasks after a test. 131*3468df56SSteven Sombar 132*3468df56SSteven Sombar FFDC On Test Case Fail 133*3468df56SSteven Sombar Run Keyword If '${TEST_STATUS}' == 'FAIL' Print Websocket Monitor Log 134*3468df56SSteven Sombar Kill Websocket Monitor 135*3468df56SSteven Sombar 136*3468df56SSteven Sombar 137*3468df56SSteven SombarSuite Teardown Execution 138*3468df56SSteven Sombar [Documentation] Do the post-suite teardown. 139*3468df56SSteven Sombar 140*3468df56SSteven Sombar Delete All Error Logs 141*3468df56SSteven Sombar Run Keyword and Return Status Redfish.Logout 142