iBGP performance suites against many fastbgp peers
[integration/test.git] / csit / libraries / BGPSpeaker.robot
1 *** Settings ***
2 Documentation     Robot keyword library (Resource) for handling the BGP speaker Python utilities.
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 ...               This library assumes that a SSH connection exists (and is switched to)
12 ...               to a Linux machine (usualy TOOLS_SYSTEM) where the Python BGP speaker should be run.
13 ...               It also assumes that the current working directory on that connection is the
14 ...               directory where the speaker tool was deployed as there are no paths to neither
15 ...               the play.py nor the log files in the commands.
16 ...
17 ...               Aside BGP Speaker utility, there is also BGP Manager starting utilities in parallel.
18 ...               For purpose of dumping logs and killing, Manager behaves the same as Speaker.
19 ...
20 ...               TODO: The Utils.robot library has a "Run Command On Remote System" if we didn't
21 ...               want to make the assumption that an SSH connection was already open.
22 ...               alternative TODO: Explain that it is not worth to perform separate SSH logins.
23 Library           SSHLibrary
24 Resource          ${CURDIR}/Utils.robot
25
26 *** Variables ***
27 ${BGPSpeaker__OUTPUT_LOG}    play.py.out
28
29 *** Keywords ***
30 Start_BGP_Speaker
31     [Arguments]    ${arguments}
32     [Documentation]    Start the BGP speaker python utility. Redirect its error output to a log file
33     ...    so it can be dumped into the logs later, when stopping it. This also avoids polluting the
34     ...    output seen by "Read Until Prompt" with false propmpts so it won't stop prematurely
35     ...    leading to a spurious test failure, messy log content or other misbehavior.
36     ${command} =    BuiltIn.Set_Variable    python play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
37     BuiltIn.Log    ${command}
38     ${output} =    SSHLibrary.Write    ${command}
39
40 Start_BGP_Manager
41     [Arguments]    ${arguments}
42     [Documentation]    Start the BGP manager python utility. Redirect its error output to a log file.
43     ${command}=    BuiltIn.Set_Variable    python manage_play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
44     BuiltIn.Log    ${command}
45     ${output}=    SSHLibrary.Write    ${command}
46
47 Dump_BGP_Speaker_Logs
48     [Documentation]    Send all output produced by the play.py utility to Robot logs.
49     ...    This needs to be called if your suite detects play.py crashing and bypasses
50     ...    Kill_BGP_Speaker in that case otherwise the output of play.py (which most
51     ...    likely contains clues about why it crashed) will be lost.
52     ${output_log} =    SSHLibrary.Execute_Command    cat ${BGPSpeaker__OUTPUT_LOG}
53     BuiltIn.Log    ${output_log}
54
55 Kill_BGP_Speaker
56     [Documentation]    Interrupt play.py, fail if no prompt is seen within SSHLibrary timeout.
57     ...    Also dump the logs with the output the program produced.
58     ...    This keyword is also suitable for stopping BGP manager.
59     Utils.Write_Bare_Ctrl_C
60     ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Read_Until_Prompt
61     Dump_BGP_Speaker_Logs
62     # TODO: When Propagate_Failure is moved to better Resource, use it instead of the following.
63     BuiltIn.Return_From_Keyword_If    '${status}' == 'PASS'
64     BuiltIn.Log    ${message}
65     BuiltIn.Fail    The prompt was not seen within timeout period.