GENIUS-268: Disable BFD Greater than Neon
[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           re
12 Library           SSHLibrary
13 Variables         ../../variables/genius/Modules.py
14 Resource          ../../libraries/DataModels.robot
15 Resource          ../../libraries/Genius.robot
16 Resource          ../../libraries/KarafKeywords.robot
17 Resource          ../../libraries/OVSDB.robot
18 Resource          ../../libraries/Utils.robot
19 Resource          ../../libraries/VpnOperations.robot
20 Resource          ../../variables/Variables.robot
21 Resource          ../../libraries/CompareStream.robot
22
23 *** Variables ***
24 @{itm_created}    TZA
25 ${genius_config_dir}    ${CURDIR}/../../variables/genius
26 ${TEP_SHOW}       tep:show
27 ${TEP_SHOW_STATE}    tep:show-state
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}    {"tunnel-monitor-params":{"enabled":true,"monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
33 ${DISABLE_MONITORING}    {"tunnel-monitor-params":{"enabled":"false","monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
34 ${TUNNEL_MONI_PARAMS_TRUE}    true
35 ${TUNNEL_MONI_PARAMS_FALSE}    false
36 ${INTERFACE_DS_MONI_FALSE}    "odl-interface:monitor-enabled": false
37 ${INTERFACE_DS_MONI_TRUE}    "odl-interface:monitor-enabled": true
38 ${INTERFACE_DS_MONI_INT_1000}    "odl-interface:monitor-interval": 1000
39 ${INTERFACE_DS_MONI_INT_5000}    "odl-interface:monitor-interval": 5000
40 ${TUNNEL_MONI_PROTO}    tunnel-monitoring-type-bfd
41
42 *** Test Cases ***
43 BFD_TC00 Create ITM between DPNs
44     [Documentation]    Create ITM between DPNs
45     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
46     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
47     ${vlan}=    Set Variable    0
48     ${gateway-ip}=    Set Variable    0.0.0.0
49     Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
50     Wait Until Keyword Succeeds    30s    5s    Genius.Verify Tunnel Status as UP    TZA
51
52 BFD_TC01 Verify default BFD monitoring status on Controller
53     [Documentation]    Verify the default value of BFD monitoring \ on the Controller
54     CompareStream.Run_Keyword_If_At_Least_Neon    Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_OFF}
55     CompareStream.Run_Keyword_If_Less_Than_Neon    Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
56     CompareStream.Run_Keyword_If_At_Least_Neon    Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_1000}
57     ...    ${TUNNEL_MONI_PROTO}
58     CompareStream.Run_Keyword_If_Less_Than_Neon    Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}
59     ...    ${TUNNEL_MONI_PROTO}
60
61 BFD_TC02 Enable BFD Monitoring And Verify On Controller
62     [Documentation]    Enable BFD monitoring in branches greater than neon and verify that BFD is enabled in the controller.
63     CompareStream.Run_Keyword_If_Less_Than_Neon    BuiltIn.Pass Execution    Test case valid only for versions Neon and above
64     Enable BFD And Verify    ${INTERFACE_DS_MONI_INT_1000}
65
66 BFD_TC03 Verify that BFD tunnel monitoring interval is set with appropriate default value i.e.,1000
67     [Documentation]    This will verify BFD tunnel monitoring default interval
68     ${output} =    Issue Command On Karaf Console    ${TEP_SHOW}
69     ${tunnel_monitoring} =    Get Lines Containing String    ${output}    Tunnel Monitoring Interval
70     Should Be Equal    ${tunnel_monitoring}    ${DEFAULT_MONITORING_INTERVAL}
71     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
72
73 BFD_TC04 Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
74     [Documentation]    Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
75     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Is On
76     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status as UP    TZA
77     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
78
79 BFD_TC05 Verify BFD tunnel monitoring interval can be changed.
80     [Documentation]    Verify BFD tunnel monitoring interval can be changed.
81     ${oper_int}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-interval/    data=${INTERVAL_5000}
82     ${Bfd_updated_value}=    Create List    5000
83     Wait Until Keyword Succeeds    30s    10s    Check For Elements At Uri    ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
84     Wait Until Keyword Succeeds    30s    10s    Check For Elements At Uri    ${CONFIG_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
85     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
86     ${tun_name}    Wait Until Keyword Succeeds    20    5    Ovs Tunnel Get    ${TOOLS_SYSTEM_1_IP}
87     Wait Until Keyword Succeeds    20s    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun_name}    5000    ovs_system=${TOOLS_SYSTEM_1_IP}
88     ${tun_name}    Wait Until Keyword Succeeds    20    5    Ovs Tunnel Get    ${TOOLS_SYSTEM_2_IP}
89     Wait Until Keyword Succeeds    20s    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun_name}    5000    ovs_system=${TOOLS_SYSTEM_2_IP}
90
91 BFD_TC06 Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
92     [Documentation]    Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
93     Issue Command On Karaf Console    ${TEP_SHOW}
94     Issue Command On Karaf Console    ${TEP_SHOW_STATE}
95     SSHLibrary.Switch Connection    ${conn_id_1}
96     Execute Command    sudo ovs-vsctl del-controller ${Bridge}
97     SSHLibrary.Switch Connection    ${conn_id_2}
98     Execute Command    sudo ovs-vsctl del-controller ${Bridge}
99     Issue Command On Karaf Console    ${TEP_SHOW}
100     Issue Command On Karaf Console    ${TEP_SHOW_STATE}
101     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UNKNOWN
102     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
103     SSHLibrary.Switch Connection    ${conn_id_1}
104     Execute Command    sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
105     SSHLibrary.Switch Connection    ${conn_id_2}
106     Execute Command    sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
107     Log    "After connecting CSS with controller"
108     Issue Command On Karaf Console    ${TEP_SHOW}
109     Issue Command On Karaf Console    ${TEP_SHOW_STATE}
110     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status as UP    TZA
111     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
112
113 BFD_TC07 Set BFD monitoring To Default Value
114     [Documentation]    Disable BFD monitoring(setting it to default value) and verify that BFD is disabled on the controller.
115     CompareStream.Run_Keyword_If_At_Least_Neon    Disable BFD And Verify
116     CompareStream.Run_Keyword_If_Less_Than_Neon    Enable BFD And Verify    ${INTERFACE_DS_MONI_INT_5000}
117
118 *** Keywords ***
119 Verify Config Ietf Interface Output
120     [Arguments]    ${state}    ${interval}    ${proto}
121     ${int_resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
122     ${respjson}    RequestsLibrary.To Json    ${int_resp.content}    pretty_print=True
123     Log    ${respjson}
124     Should Contain    ${respjson}    ${state}
125     Should Contain    ${respjson}    ${interval}
126     Should Contain    ${respjson}    ${proto}
127
128 Ovs Tunnel Get
129     [Arguments]    ${tools_ip}
130     [Documentation]    This keyword will return the tunnel name on OVS
131     ${list_interface}    Utils.Run Command On Remote System    ${tools_ip}    sudo ovs-vsctl list interface
132     ${tun_line}    ${tun_name}    Should Match Regexp    ${list_interface}    name\\s+: "(tun.*)"
133     log    ${tun_name}
134     Should Not Be Empty    ${tun_name}
135     [Return]    ${tun_name}
136
137 Verify Tunnel Monitoring Params
138     [Arguments]    ${flag}
139     @{checklist}    create list    ${flag}
140     Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/    ${checklist}
141
142 Enable BFD And Verify
143     [Arguments]    ${interface_ds_moni_int}
144     [Documentation]    Enable BFD Monitoring And Verify On Controller.
145     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${ENABLE_MONITORING}
146     Should Be Equal As Strings    ${resp.status_code}    201
147     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_TRUE}
148     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
149     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${interface_ds_moni_int}    ${TUNNEL_MONI_PROTO}
150     Wait Until Keyword Succeeds    20    2    Genius.Verify Tunnel Status as UP    TZA
151
152 Disable BFD And Verify
153     [Documentation]    Disable BFD Monitoring And Verify On Controller.
154     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${DISABLE_MONITORING}
155     Should Be Equal As Strings    ${resp.status_code}    200
156     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_FALSE}
157     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_OFF}
158     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
159     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status as UP    TZA