Performance fix and correction for events verification post reboot

Seeing failure for event post reboot this particular test since many
test runs and manual execution as well. This turns out to be due to
fixed sleep and doing REST operation. With this changes, the test is
sanely doing the test and consitently passing on a given good driver.

This changes includes:
   - Adding new keyword in utils.robot for general usage and
     removing it from code update utils.
   - Tweaks "Verify Ping and REST Authentication" keyword

Resolves openbmc/openbmc-test-automation#115

Change-Id: Ief10e948fd03736a024a13add208de478ac9fecb
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/extended/code_update/code_update_utils.robot b/extended/code_update/code_update_utils.robot
index 640e421..a54b7f2 100644
--- a/extended/code_update/code_update_utils.robot
+++ b/extended/code_update/code_update_utils.robot
@@ -54,17 +54,12 @@
 
 
 System Readiness Test
-    ${l_status} =   Run Keyword    Verify Ping and REST Authentication
+    ${l_status} =   Run Keyword and Return Status
+    ...   Verify Ping and REST Authentication
     Run Keyword If  '${l_status}' == '${False}'
     ...   Fail  msg=System not in ideal state to use [ERROR]
 
 
-Check If BMC is Up
-    ${status}=    Verify Ping and REST Authentication
-    Run Keyword If   '${status}' == '${False}'
-    ...     Fail   msg=Ping and REST auth failed
-
-
 Validate BMC Version
     [Arguments]   ${args}=post
     # Check BMC installed version
diff --git a/extended/code_update/update_bmc.robot b/extended/code_update/update_bmc.robot
index 6c22803..6d4ca55 100644
--- a/extended/code_update/update_bmc.robot
+++ b/extended/code_update/update_bmc.robot
@@ -41,7 +41,6 @@
     Run Keyword If   '${session_active}' == '${True}'
     ...    Trigger Warm Reset via Reboot
 
-    Wait Until Keyword Succeeds
-    ...  30 min   10 sec     Check If BMC is Up
+    Check If BMC is Up    30 min   10 sec
     Sleep  1 min
     Validate BMC Version
diff --git a/lib/utils.robot b/lib/utils.robot
index 219f951..0f56d78 100644
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -189,18 +189,30 @@
 Verify Ping and REST Authentication
     ${l_ping} =   Run Keyword And Return Status
     ...    Ping Host  ${OPENBMC_HOST}
-    Return From Keyword If  '${l_ping}' == '${False}'    ${False}
+    Run Keyword If  '${l_ping}' == '${False}'
+    ...    Fail   msg=Ping Failed
 
     ${l_rest} =   Run Keyword And Return Status
     ...    Initialize OpenBMC
-    Return From Keyword If  '${l_rest}' == '${False}'    ${False}
+    Run Keyword If  '${l_rest}' == '${False}'
+    ...    Fail   msg=REST Authentication Failed
 
     # Just to make sure the SSH is working for SCP
     Open Connection And Log In
     ${system}   ${stderr}=    Execute Command   hostname   return_stderr=True
     Should Be Empty     ${stderr}
 
-    [return]    ${True}
+
+Check If BMC is Up
+    [Documentation]  Wait for Host to be online. Checks every X seconds
+    ...              interval for Y minutes and fails if timed out.
+    ...              Default MAX timedout is 10 min, interval 10 seconds.
+    [arguments]      ${max_timeout}=${OPENBMC_REBOOT_TIMEOUT}
+    ...              ${interval}=10 sec
+
+    Wait Until Keyword Succeeds
+    ...   ${max_timeout}  ${interval}   Verify Ping and REST Authentication
+
 
 Check If warmReset is Initiated
     [Documentation]  Ping would be still alive, so try SSH to connect
diff --git a/tests/test_eventlog.robot b/tests/test_eventlog.robot
index fbf6e3e..1d5b28c 100644
--- a/tests/test_eventlog.robot
+++ b/tests/test_eventlog.robot
@@ -163,9 +163,7 @@
     ${pre_reboot_event}=         create a test log
 
     ${output}=      Execute Command    /sbin/reboot
-    Sleep   ${SYSTEM_SHUTDOWN_TIME}
-    Wait For Host To Ping   ${OPENBMC_HOST}
-    Sleep   ${WAIT_FOR_SERVICES_UP}
+    Check If BMC is Up   5 min    10 sec
 
     ${resp} =    openbmc get request     ${pre_reboot_event}
     should be equal as strings      ${resp.status_code}     ${HTTP_OK}