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