Update Robot Framework format - step 3
[integration/test.git] / csit / suites / bgpcep / bgpfunct / 050_bmp_basic.robot
1 *** Settings ***
2 Documentation       Basic tests for odl-bgpcep-bmp feature
3 ...
4 ...                 Copyright (c) 2016 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 ...                 This is a basic suite for bgp monitoring protocol feature.
11 ...                 After the feature odl-bgpcep-bmp installation the port 12345 should be
12 ...                 bound for listening,
13 ...                 To test this feature bgp-bmp-mock tool is used. It is a part of the
14 ...                 bgpcep project. It is a java tool which simulates more peers and more
15 ...                 routers.
16 ...                 In this particular test suite it simulates 1 peer with 1 router, which
17 ...                 means it advertizes one peer ipv4 address towards odl. As a result one
18 ...                 route should appear in the restconf/operational/bmp-monitor:bmp-monitor.
19
20 Library             SSHLibrary
21 Library             RequestsLibrary
22 Resource            ${CURDIR}/../../../libraries/CompareStream.robot
23 Resource            ${CURDIR}/../../../libraries/NexusKeywords.robot
24 Resource            ${CURDIR}/../../../libraries/RemoteBash.robot
25 Resource            ${CURDIR}/../../../libraries/TemplatedRequests.robot
26
27 Suite Setup         Set_It_Up
28 Suite Teardown      Tear_It_Down
29
30
31 *** Variables ***
32 ${CONFIG_SESSION}           config-session
33 ${BGP_BMP_DIR}              ${CURDIR}/../../../variables/bgpfunctional/bmp_basic/filled_structure
34 ${BGP_BMP_FEAT_DIR}         ${CURDIR}/../../../variables/bgpfunctional/bmp_basic/empty_structure
35 ${BMP_LOG_FILE}             bmpmock.log
36 ${NEW_IPV4_ROUTES_LINE}     ${EMPTY}
37 ${OLD_IPV4_ROUTES_LINE}     \n"bgp-inet:ipv4-routes": {},
38
39
40 *** Test Cases ***
41 Verify BMP Feature
42     [Documentation]    Verifies if feature is up
43     &{mapping}=    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}
44     BuiltIn.Wait_Until_Keyword_Succeeds
45     ...    180s
46     ...    5s
47     ...    TemplatedRequests.Get_As_Json_Templated
48     ...    folder=${BGP_BMP_FEAT_DIR}
49     ...    mapping=${mapping}
50     ...    session=${CONFIG_SESSION}
51     ...    verify=True
52
53 Start_Bmp_Mock
54     [Documentation]    Starts bmp-mock on tools vm
55     ${command}=    NexusKeywords.Compose_Full_Java_Command
56     ...    -jar ${filename} --local_address ${TOOLS_SYSTEM_IP} --remote_address ${ODL_SYSTEM_IP}:12345 --routers_count 1 --peers_count 1 --log_level DEBUG 2>&1 | tee ${BMP_LOG_FILE}
57     BuiltIn.Log    ${command}
58     SSHLibrary.Set_Client_Configuration    timeout=30s
59     SSHLibrary.Write    ${command}
60     ${until_phrase}=    Set Variable    successfully established.
61     SSHLibrary.Read_Until    ${until_phrase}
62
63 Verify Data Reported
64     [Documentation]    Verifies if the tool reported expected data
65     ${IPV4_ROUTES_LINE}=    CompareStream.Set_Variable_If_At_Least_Neon
66     ...    ${NEW_IPV4_ROUTES_LINE}
67     ...    ${OLD_IPV4_ROUTES_LINE}
68     &{mapping}=    BuiltIn.Create_Dictionary    TOOL_IP=${TOOLS_SYSTEM_IP}    ROUTES_LINE=${IPV4_ROUTES_LINE}
69     BuiltIn.Wait_Until_Keyword_Succeeds
70     ...    3x
71     ...    2s
72     ...    TemplatedRequests.Get_As_Json_Templated
73     ...    folder=${BGP_BMP_DIR}
74     ...    mapping=${mapping}
75     ...    session=${CONFIG_SESSION}
76     ...    verify=True
77
78 Stop_Bmp_Mock
79     [Documentation]    Send ctrl+c to bmp-mock to stop it
80     RemoteBash.Write_Bare_Ctrl_C
81     ${output}=    SSHLibrary.Read_Until_Prompt
82     BuiltIn.Log    ${output}
83
84
85 *** Keywords ***
86 Set_It_Up
87     [Documentation]    Create SSH session to ToolsVm, prepare HTTP client session to Controller.
88     ...    Figure out latest pcc-mock version and download it from Nexus to ToolsVm.
89     NexusKeywords.Initialize_Artifact_Deployment_And_Usage
90     RequestsLibrary.Create_Session    ${CONFIG_SESSION}    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}
91     ${name}=    NexusKeywords.Deploy_Test_Tool    bgpcep    bgp-bmp-mock
92     BuiltIn.Set_Suite_Variable    ${filename}    ${name}
93
94 Tear_It_Down
95     [Documentation]    Download bmpmock.log and Log its contents.
96     ...    Compute and Log the diff between expected and actual normalized responses.
97     ...    Close both HTTP client session and SSH connection to Mininet.
98     SSHLibrary.Get_File    ${BMP_LOG_FILE}
99     ${cnt}=    OperatingSystem.Get_File    ${BMP_LOG_FILE}
100     Log    ${cnt}
101     Delete_All_Sessions
102     Close_All_Connections