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