iBGP performance suites against many fastbgp peers
[integration/test.git] / csit / libraries / SSHKeywords.robot
1 *** Settings ***
2 Documentation     Resource enhancing SSHLibrary with Keywords used in multiple suites.
3 ...
4 ...               Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
5 ...
6 ...               This program and the accompanying materials are made available under the
7 ...               terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ...               and is available at http://www.eclipse.org/legal/epl-v10.html
9 ...
10 ...
11 ...               Some suites evolved utility Keywords re-usable with other suites.
12 ...               When the Keywords assume a SSH session is active,
13 ...               and if the Keywords do not fit into a more specific Resource,
14 ...               you can place them here.
15 Library           SSHLibrary
16
17 *** Keywords ***
18 Execute_Command_Passes
19     [Arguments]    ${command}
20     [Documentation]    Execute command via SSH. If RC is nonzero, log everything. Retrun bool string of command success.
21     ${stdout}    ${stderr}    ${rc} =    SSHLibrary.Execute_Command    ${command}    return_stderr=True    return_rc=True
22     BuiltIn.Return_From_Keyword_If    ${rc} == 0    True
23     BuiltIn.Log    ${stdout}
24     BuiltIn.Log    ${stderr}
25     BuiltIn.Log    ${rc}
26     [Return]    False
27
28 Require_Python
29     [Documentation]    Verify current SSH connection leads to machine with python working. Fatal fail otherwise.
30     ${passed} =    Execute_Command_Passes    python --help
31     BuiltIn.Return_From_Keyword_If    ${passed}
32     BuiltIn.Fatal_Error    Python is not installed!
33
34 Assure_Library_Ipaddr
35     [Arguments]    ${target_dir}=.
36     [Documentation]    Tests whether ipaddr module is present on ssh-connected machine, Puts ipaddr.py to target_dir if not.
37     ${passed} =    Execute_Command_Passes    bash -c 'cd "${target_dir}" && python -c "import ipaddr"'
38     BuiltIn.Return_From_Keyword_If    ${passed}
39     SSHLibrary.Put_File    ${CURDIR}/ipaddr.py    ${target_dir}/
40
41 Assure_Library_Counter
42     [Arguments]    ${target_dir}=.
43     [Documentation]    Tests whether Counter is present in collections on ssh-connected machine, Puts Counter.py to workspace if not.
44     ${passed} =    Execute_Command_Passes    bash -c 'cd "${target_dir}" && python -c "from collections import Counter"'
45     # TODO: Move the bash-cd wrapper to separate keyword?
46     BuiltIn.Return_From_Keyword_If    ${passed}
47     SSHLibrary.Put_File    ${CURDIR}/Counter.py    ${target_dir}/