Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / lib / connectivity_lib.resource
1 *** Comments ***
2 #   Licensed under the Apache License, Version 2.0 (the "License");
3 #   you may not use this file except in compliance with the License.
4 #   You may obtain a copy of the License at
5 #
6 #       http://www.apache.org/licenses/LICENSE-2.0
7 #
8 #   Unless required by applicable law or agreed to in writing, software
9 #   distributed under the License is distributed on an "AS IS" BASIS,
10 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 #   See the License for the specific language governing permissions and
12 #   limitations under the License.
13
14
15 *** Settings ***
16 Documentation   Library providing keywords for testing connectivity to hosts via ping.
17 Library   OperatingSystem
18
19
20 *** Variables ***
21 ${SUCCESS_RETURN_CODE}   0
22 ${CONNECTIVITY_POL_TIME}   5sec
23 ${CONNECTIVITY_MAX_WAIT_TIME}   30sec
24
25
26 *** Keywords ***
27 Test Ping Host
28     [Documentation]   Run Ping
29     ...               Parameters:
30     ...                  host: IP or name of the host
31     ...               Execution example:
32     ...                  Ping Test   \${host}
33     [Arguments]   ${host}
34     ${rc}   ${stdout}=   Run And Return Rc And Output   ping -c 2 -W 1 ${host}
35     Log   ${stdout}
36     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
37
38 Test Connectivity
39     [Documentation]   Ping a host several times during ${CONNECTIVITY_MAX_WAIT_TIME} until it succeeds or raises a timeout.
40     [Arguments]   ${host}
41     Wait Until Keyword Succeeds   ${CONNECTIVITY_MAX_WAIT_TIME}   ${CONNECTIVITY_POL_TIME}   Test Ping Host   ${host}