Updated Test Connectivity to retry ping and capture ping output
[osm/tests.git] / robot-systest / lib / connectivity_lib.robot
index 7b86593..3db20b8 100644 (file)
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
+*** Variables ***
+${success_return_code}   0
+${connectivity_pol_time}   5sec
+${connectivity_max_wait_time}   30sec
+
 *** Keywords ***
+Test Ping Host
+    [Documentation]   Run Ping
+    ...               Parameters:
+    ...                  host: IP or name of the host
+    ...               Execution example:
+    ...                  Ping Test   \${host}
+
+    [Arguments]  ${host}
+
+    ${rc}   ${stdout}=   Run and Return RC and Output   ping -c 2 -W 1 ${host}
+    log   ${stdout}
+    Should Be Equal As Integers   ${rc}   ${success_return_code}
+
 Test Connectivity
     [Arguments]  ${host}
 
-    ${result}  Run Process  ping -c 5 -W 1 ${host} > /dev/null && echo OK  shell=True
-    Log     all output: ${result.stdout}
-    Should Contain  ${result.stdout}  OK
+    WAIT UNTIL KEYWORD SUCCEEDS   ${connectivity_max_wait_time}   ${connectivity_pol_time}   Test Ping Host   ${host}