Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / genius / BFD_monitoring.robot
1 *** Settings ***
2 Documentation     Test Suite for BFD tunnel monitoring
3 Suite Setup       Genius Suite Setup
4 Suite Teardown    BFD Suite Teardown
5 Test Setup        Genius Test Setup
6 Test Teardown     Genius Test Teardown    ${data_models}
7 Library           OperatingSystem
8 Library           String
9 Library           RequestsLibrary
10 Library           Collections
11 Library           SSHLibrary
12 Resource          ../../libraries/DataModels.robot
13 Resource          ../../libraries/Genius.robot
14 Resource          ../../libraries/KarafKeywords.robot
15 Resource          ../../libraries/OVSDB.robot
16 Resource          ../../libraries/ToolsSystem.robot
17 Resource          ../../libraries/Utils.robot
18 Resource          ../../libraries/VpnOperations.robot
19 Resource          ../../variables/netvirt/Variables.robot
20 Resource          ../../variables/Variables.robot
21 Resource          ../../libraries/CompareStream.robot
22 Variables         ../../variables/genius/Modules.py
23
24 *** Variables ***
25 ${TUNNEL_MONITOR_ON}    Tunnel Monitoring (for VXLAN tunnels): On
26 ${DEFAULT_MONITORING_INTERVAL}    Tunnel Monitoring Interval (for VXLAN tunnels): 1000
27 ${TUNNEL_MONITOR_OFF}    Tunnel Monitoring (for VXLAN tunnels): Off
28 ${INTERVAL_5000}    {"tunnel-monitor-interval":{"interval":5000}}
29 ${ENABLE_MONITORING}    {"tunnel-monitor-params":{"enabled":true,"monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
30 ${DISABLE_MONITORING}    {"tunnel-monitor-params":{"enabled":"false","monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
31 ${TUNNEL_MONI_PARAMS_TRUE}    true
32 ${TUNNEL_MONI_PARAMS_FALSE}    false
33 ${INTERFACE_DS_MONI_FALSE}    "odl-interface:monitor-enabled": false
34 ${INTERFACE_DS_MONI_TRUE}    "odl-interface:monitor-enabled": true
35 ${INTERFACE_DS_MONI_INT_1000}    "odl-interface:monitor-interval": 1000
36 ${INTERFACE_DS_MONI_INT_5000}    "odl-interface:monitor-interval": 5000
37 ${TUNNEL_MONI_PROTO}    tunnel-monitoring-type-bfd
38
39 *** Test Cases ***
40 BFD_TC00 Create ITM between DPNs
41     [Documentation]    Create ITM between DPNs
42     Genius.Create Vteps    ${NO_VLAN}    ${gateway_ip}
43     BuiltIn.Wait Until Keyword Succeeds    30s    5s    Genius.Verify Tunnel Status As Up
44
45 BFD_TC01 Verify default BFD monitoring status on Controller
46     [Documentation]    Verify the default value of BFD monitoring \ on the Controller
47     CompareStream.Run_Keyword_If_At_Least_Neon    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_OFF}
48     CompareStream.Run_Keyword_If_Less_Than_Neon    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
49     CompareStream.Run_Keyword_If_At_Least_Neon    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_1000}
50     ...    ${TUNNEL_MONI_PROTO}
51     CompareStream.Run_Keyword_If_Less_Than_Neon    BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}
52     ...    ${TUNNEL_MONI_PROTO}
53
54 BFD_TC02 Enable BFD Monitoring And Verify On Controller
55     [Documentation]    Enable BFD monitoring in branches greater than neon and verify that BFD is enabled in the controller.
56     CompareStream.Run_Keyword_If_Less_Than_Neon    BuiltIn.Pass Execution    Test case valid only for versions Neon and above
57     Enable BFD And Verify    ${INTERFACE_DS_MONI_INT_1000}
58
59 BFD_TC03 Verify that BFD tunnel monitoring interval is set with appropriate default value i.e.,1000
60     [Documentation]    This will verify BFD tunnel monitoring default interval
61     ${output} =    KarafKeywords.Issue Command On Karaf Console    ${TEP_SHOW}
62     ${tunnel_monitoring} =    String.Get Lines Containing String    ${output}    Tunnel Monitoring Interval
63     BuiltIn.Should Be Equal    ${tunnel_monitoring}    ${DEFAULT_MONITORING_INTERVAL}
64     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
65
66 BFD_TC04 Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
67     [Documentation]    Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
68     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
69     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
70     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
71
72 BFD_TC05 Verify BFD tunnel monitoring interval can be changed.
73     [Documentation]    Verify BFD tunnel monitoring interval can be changed.
74     ${oper_int} =    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-interval/    data=${INTERVAL_5000}
75     ${Bfd_updated_value}=    BuiltIn.Create List    5000
76     Wait Until Keyword Succeeds    30s    10s    Utils.Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
77     Wait Until Keyword Succeeds    30s    10s    Utils.Check For Elements At URI    ${CONFIG_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
78     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
79     FOR    ${tool_system_index}    IN RANGE    ${NUM_TOOLS_SYSTEM}
80         ${tun_names}    Genius.Get Tunnels On OVS    ${TOOLS_SYSTEM_ALL_CONN_IDS[${tool_system_index}]}
81         Verify ovs-vsctl Output For Each Tunnel    ${tun_names}    ${tool_system_index}
82     END
83
84 BFD_TC06 Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
85     [Documentation]    Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
86     ToolsSystem.Run Command On All Tools Systems    sudo ovs-vsctl del-controller ${Bridge}
87     BuiltIn.Wait Until Keyword Succeeds    10s    1s    VpnOperations.Verify Tunnel Status as UNKNOWN
88     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
89     ToolsSystem.Run Command On All Tools Systems    sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
90     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
91     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
92
93 BFD_TC07 Set BFD monitoring To Default Value
94     [Documentation]    Disable BFD monitoring(setting it to default value) and verify that BFD is disabled on the controller.
95     CompareStream.Run_Keyword_If_At_Least_Neon    Disable BFD And Verify
96     CompareStream.Run_Keyword_If_Less_Than_Neon    Enable BFD And Verify    ${INTERFACE_DS_MONI_INT_5000}
97
98 *** Keywords ***
99 Verify Config Ietf Interface Output
100     [Arguments]    ${state}    ${interval}    ${proto}
101     [Documentation]    This keyword will get request from config ietf interface and verifies state, interval and proto are present
102     ${int_resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
103     ${respjson} =    RequestsLibrary.To Json    ${int_resp.content}    pretty_print=True
104     BuiltIn.Should Contain    ${respjson}    ${state}
105     BuiltIn.Should Contain    ${respjson}    ${interval}
106     BuiltIn.Should Contain    ${respjson}    ${proto}
107
108 Ovs Tunnel Get
109     [Arguments]    ${tools_ip}
110     [Documentation]    This keyword will return the tunnel name on OVS
111     ${list_interface} =    Utils.Run Command On Remote System    ${tools_ip}    sudo ovs-vsctl list interface
112     ${tun_line} =    ${tun_name}    BuiltIn.Should Match Regexp    ${list_interface}    name\\s+: "(tun.*)"
113     BuiltIn.Log    ${tun_name}
114     BuiltIn.Should Not Be Empty    ${tun_name}
115     [Return]    ${tun_name}
116
117 Verify Tunnel Monitoring Params
118     [Arguments]    ${flag}
119     [Documentation]    This keyword will verify the tunnel monitoring is true or false
120     @{checklist}    BuiltIn.Create List    ${flag}
121     Utils.Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/    ${checklist}
122
123 Enable BFD And Verify
124     [Arguments]    ${interface_ds_moni_int}
125     [Documentation]    Enable BFD Monitoring And Verify On Controller.
126     ${resp} =    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${ENABLE_MONITORING}
127     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    201
128     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_TRUE}
129     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
130     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${interface_ds_moni_int}    ${TUNNEL_MONI_PROTO}
131     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
132
133 Disable BFD And Verify
134     [Documentation]    Disable BFD Monitoring And Verify On Controller.
135     ${resp} =    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${DISABLE_MONITORING}
136     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
137     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_FALSE}
138     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Genius.Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_OFF}
139     BuiltIn.Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
140     BuiltIn.Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
141
142 Verify ovs-vsctl Output For Each Tunnel
143     [Arguments]    ${tun_names}    ${tool_system_index}
144     ${no of tunnels} =    BuiltIn.Get Length    ${tun_names}
145     FOR    ${each_tun}    IN RANGE    ${no of tunnels}
146         ${tun}    Collections.Get From List    ${tun_names}    ${each_tun}
147         BuiltIn.Wait Until Keyword Succeeds    20    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun}    5000
148         ...    ovs_system=@{TOOLS_SYSTEM_ALL_IPS}[${tool_system_index}]
149     END