GENIUS-136 : Enhance Genius-CSIT to 3 Switches
[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     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    Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_OFF}
48     CompareStream.Run_Keyword_If_Less_Than_Neon    Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
49     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}
50     ...    ${TUNNEL_MONI_PROTO}
51     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}
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} =    Issue Command On Karaf Console    ${TEP_SHOW}
62     ${tunnel_monitoring} =    Get Lines Containing String    ${output}    Tunnel Monitoring Interval
63     Should Be Equal    ${tunnel_monitoring}    ${DEFAULT_MONITORING_INTERVAL}
64     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     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
69     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
70     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}=    Create List    5000
76     Wait Until Keyword Succeeds    30s    10s    Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
77     Wait Until Keyword Succeeds    30s    10s    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
83 BFD_TC06 Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
84     [Documentation]    Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
85     ToolsSystem.Run Command On All Tools Systems    sudo ovs-vsctl del-controller ${Bridge}
86     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UNKNOWN
87     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
88     ToolsSystem.Run Command On All Tools Systems    sudo ovs-vsctl set-controller ${Bridge} tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
89     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
90     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
91
92 BFD_TC07 Set BFD monitoring To Default Value
93     [Documentation]    Disable BFD monitoring(setting it to default value) and verify that BFD is disabled on the controller.
94     CompareStream.Run_Keyword_If_At_Least_Neon    Disable BFD And Verify
95     CompareStream.Run_Keyword_If_Less_Than_Neon    Enable BFD And Verify    ${INTERFACE_DS_MONI_INT_5000}
96
97 *** Keywords ***
98 Verify Config Ietf Interface Output
99     [Arguments]    ${state}    ${interval}    ${proto}
100     [Documentation]    This keyword will get request from config ietf interface and verifies state, interval and proto are present
101     ${int_resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
102     ${respjson}    RequestsLibrary.To Json    ${int_resp.content}    pretty_print=True
103     Should Contain    ${respjson}    ${state}
104     Should Contain    ${respjson}    ${interval}
105     Should Contain    ${respjson}    ${proto}
106
107 Ovs Tunnel Get
108     [Arguments]    ${tools_ip}
109     [Documentation]    This keyword will return the tunnel name on OVS
110     ${list_interface}    Utils.Run Command On Remote System    ${tools_ip}    sudo ovs-vsctl list interface
111     ${tun_line}    ${tun_name}    Should Match Regexp    ${list_interface}    name\\s+: "(tun.*)"
112     log    ${tun_name}
113     Should Not Be Empty    ${tun_name}
114     [Return]    ${tun_name}
115
116 Verify Tunnel Monitoring Params
117     [Arguments]    ${flag}
118     [Documentation]    This keyword will verify the tunnel monitoring is true or false
119     @{checklist}    create list    ${flag}
120     Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/    ${checklist}
121
122 Enable BFD And Verify
123     [Arguments]    ${interface_ds_moni_int}
124     [Documentation]    Enable BFD Monitoring And Verify On Controller.
125     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${ENABLE_MONITORING}
126     Should Be Equal As Strings    ${resp.status_code}    201
127     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_TRUE}
128     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_ON}
129     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${interface_ds_moni_int}    ${TUNNEL_MONI_PROTO}
130     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
131
132 Disable BFD And Verify
133     [Documentation]    Disable BFD Monitoring And Verify On Controller.
134     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${DISABLE_MONITORING}
135     Should Be Equal As Strings    ${resp.status_code}    200
136     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_FALSE}
137     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Status    ${TUNNEL_MONITOR_OFF}
138     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
139     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status As Up
140
141 Verify ovs-vsctl Output For Each Tunnel
142     [Arguments]    ${tun_names}    ${tool_system_index}
143     ${no of tunnels} =    BuiltIn.Get Length    ${tun_names}
144     : FOR    ${each_tun}    IN RANGE    ${no of tunnels}
145     \    ${tun}    Collections.Get From List    ${tun_names}    ${each_tun}
146     \    BuiltIn.Wait Until Keyword Succeeds    20    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun}    5000
147     \    ...    ovs_system=@{TOOLS_SYSTEM_ALL_IPS}[${tool_system_index}]