Testplan and suite for 1 iBGP peer performance tests
[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 ...               TODO: The Utils.robot library has a "Run Command On Remote System" if we didn't
18 ...               want to make the assumption that an SSH connection was already open.
19 ...               alternative TODO: Explain that it is not worth to perform separate SSH logins.
20 Library           SSHLibrary
21 Resource          ${CURDIR}/Utils.robot
22
23 *** Variables ***
24 ${BGPSpeaker__OUTPUT_LOG}    play.py.out
25
26 *** Keywords ***
27 Start_BGP_Speaker
28     [Arguments]    ${arguments}
29     [Documentation]    Start the BGP speaker python utility. Redirect its error output to a log file
30     ...    so it can be dumped into the logs later, when stopping it. This also avoids polluting the
31     ...    output seen by "Read Until Prompt" with false propmpts so it won't stop prematurely
32     ...    leading to a spurious test failure, messy log content or other misbehavior.
33     ${command} =    BuiltIn.Set_Variable    python play.py ${arguments} &> ${BGPSpeaker__OUTPUT_LOG}
34     BuiltIn.Log    ${command}
35     ${output} =    SSHLibrary.Write    ${command}
36
37 Dump_BGP_Speaker_Logs
38     [Documentation]    Send all output produced by the play.py utility to Robot logs.
39     ...    This needs to be called if your suite detects play.py crashing and bypasses
40     ...    Kill_BGP_Speaker in that case otherwise the output of play.py (which most
41     ...    likely contains clues about why it crashed) will be lost.
42     ${output_log} =    SSHLibrary.Execute_Command    cat ${BGPSpeaker__OUTPUT_LOG}
43     BuiltIn.Log    ${output_log}
44
45 Kill_BGP_Speaker
46     [Documentation]    Interrupt play.py, fail if no prompt is seen within SSHLibrary timeout.
47     ...    Also dump the logs with the output the program produced.
48     Utils.Write_Bare_Ctrl_C
49     ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    SSHLibrary.Read_Until_Prompt
50     Dump_BGP_Speaker_Logs
51     # TODO: When Propagate_Failure is moved to better Resource, use it instead of the following.
52     BuiltIn.Return_From_Keyword_If    '${status}' == 'PASS'
53     BuiltIn.Log    ${message}
54     BuiltIn.Fail    The prompt was not seen within timeout period.