Increase timeout and retries for Genius
[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 Stop
5 Test Teardown     Get Model Dump    ${ODL_SYSTEM_IP}    ${data_models}
6 Library           OperatingSystem
7 Library           String
8 Library           RequestsLibrary
9 Library           Collections
10 Library           re
11 Library           SSHLibrary
12 Variables         ../../variables/genius/Modules.py
13 Resource          ../../libraries/DataModels.robot
14 Resource          ../../libraries/Genius.robot
15 Resource          ../../libraries/KarafKeywords.robot
16 Resource          ../../libraries/OVSDB.robot
17 Resource          ../../libraries/Utils.robot
18 Resource          ../../libraries/VpnOperations.robot
19 Resource          ../../variables/Variables.robot
20
21 *** Variables ***
22 @{itm_created}    TZA
23 ${genius_config_dir}    ${CURDIR}/../../variables/genius
24 ${Bridge-1}       BR1
25 ${Bridge-2}       BR2
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 ${OK_201}         201
33 ${ENABLE_MONITORING}    {"tunnel-monitor-params":{"enabled":true,"monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
34 ${DISABLE_MONITORING}    {"tunnel-monitor-params":{"enabled":"false","monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
35 ${TUNNEL_MONI_PARAMS_TRUE}    true
36 ${TUNNEL_MONI_PARAMS_FALSE}    false
37 ${INTERFACE_DS_MONI_FALSE}    "odl-interface:monitor-enabled": false
38 ${INTERFACE_DS_MONI_TRUE}    "odl-interface:monitor-enabled": true
39 ${INTERFACE_DS_MONI_INT_1000}    "odl-interface:monitor-interval": 1000
40 ${INTERFACE_DS_MONI_INT_5000}    "odl-interface:monitor-interval": 5000
41 ${TUNNEL_MONI_PROTO}    tunnel-monitoring-type-bfd
42
43 *** Test Cases ***
44 BFD_TC00 Create ITM between DPNs Verify_BFD_Enablement
45     [Documentation]    Create ITM between DPNs Verify_BFD_Enablement
46     ${Dpn_id_1}    Get Dpn Ids    ${conn_id_1}
47     ${Dpn_id_2}    Get Dpn Ids    ${conn_id_2}
48     Set Global Variable    ${Dpn_id_1}
49     Set Global Variable    ${Dpn_id_2}
50     ${vlan}=    Set Variable    0
51     ${gateway-ip}=    Set Variable    0.0.0.0
52     Create Vteps    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
53     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Status as UP
54
55 BFD_TC01 Verify by default BFD monitoring is enabled on Controller
56     [Documentation]    Verify by default BFD monitoring is enabled on Controller
57     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Is On
58     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
59
60 BFD_TC02 Verify that BFD tunnel monitoring interval is set with appropriate default value i.e.,1000
61     [Documentation]    This will verify BFD tunnel monitoring default interval
62     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
63     Log    ${output}
64     Should Contain    ${output}    ${DEFAULT_MONITORING_INTERVAL}
65     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
66
67 BFD_TC04 Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
68     [Documentation]    Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
69     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Is On
70     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UP
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_TC05 Verify BFD tunnel monitoring interval can be changed.
74     [Documentation]    Verify BFD tunnel monitoring interval can be changed.
75     Log    "Value of BFD monitoring interval before updating with new value"
76     ${oper_int}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/
77     ${respjson}    RequestsLibrary.To Json    ${oper_int.content}    pretty_print=True
78     Log    ${respjson}
79     Log    "Value of BFD monitoring interval is getting updated"
80     ${oper_int}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-interval/    data=${INTERVAL_5000}
81     ${Bfd_updated_value}=    Create List    5000
82     Wait Until Keyword Succeeds    30s    10s    Check For Elements At Uri    ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
83     Wait Until Keyword Succeeds    30s    10s    Check For Elements At Uri    ${CONFIG_API}/itm-config:tunnel-monitor-interval/    ${Bfd_updated_value}
84     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
85     SSHLibrary.Switch Connection    ${conn_id_1}
86     Execute Command    sudo ovs-vsctl del-port ${Bridge-1} tap8ed70586-6c
87     ${ovs_1}    Execute Command    sudo ovs-vsctl show
88     log    ${ovs_1}
89     ${tun_name}    Wait Until Keyword Succeeds    20    5    Ovs Tunnel Get    ${Bridge-1}
90     Wait Until Keyword Succeeds    20s    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun_name}    5000    ovs_system=${TOOLS_SYSTEM_IP}
91     SSHLibrary.Switch Connection    ${conn_id_2}
92     ${ovs_2}    Execute Command    sudo ovs-vsctl show
93     ${tun_name}    Wait Until Keyword Succeeds    20    5    Ovs Tunnel Get    ${Bridge-2}
94     Wait Until Keyword Succeeds    20s    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun_name}    5000    ovs_system=${TOOLS_SYSTEM_2_IP}
95
96 BFD_TC06 Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
97     [Documentation]    Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
98     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
99     Log    ${output}
100     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW_STATE}
101     Log    ${output}
102     SSHLibrary.Switch Connection    ${conn_id_1}
103     Execute Command    sudo ovs-vsctl del-controller BR1
104     SSHLibrary.Switch Connection    ${conn_id_2}
105     Execute Command    sudo ovs-vsctl del-controller BR2
106     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
107     Log    ${output}
108     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW_STATE}
109     Log    ${output}
110     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UNKNOWN
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     SSHLibrary.Switch Connection    ${conn_id_1}
113     Execute Command    sudo ovs-vsctl set-controller BR1 tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
114     SSHLibrary.Switch Connection    ${conn_id_2}
115     Execute Command    sudo ovs-vsctl set-controller BR2 tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
116     Log    "After connecting CSS with controller"
117     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
118     Log    ${output}
119     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW_STATE}
120     Log    ${output}
121     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UP
122     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
123
124 BFD_TC07 Verify that BFD monitoring is disabled on Controller
125     [Documentation]    Verify that BFD monitoring is disabled on Controller
126     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${DISABLE_MONITORING}
127     Should Be Equal As Strings    ${resp.status_code}    201
128     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_FALSE}
129     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
130     Log    ${output}
131     Should Contain    ${output}    ${TUNNEL_MONITOR_OFF}
132     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
133     Log    "Verifying tunnel is UP after BFD is disabled"
134     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UP
135     Log    "Enabling tunnel monitoring once again"
136     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${ENABLE_MONITORING}
137     Should Be Equal As Strings    ${resp.status_code}    200
138     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_TRUE}
139     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Is On
140     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
141
142 *** Keywords ***
143 Verify Config Ietf Interface Output
144     [Arguments]    ${state}    ${interval}    ${proto}
145     ${int_resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
146     ${respjson}    RequestsLibrary.To Json    ${int_resp.content}    pretty_print=True
147     Log    ${respjson}
148     Should Contain    ${respjson}    ${state}
149     Should Contain    ${respjson}    ${interval}
150     Should Contain    ${respjson}    ${proto}
151
152 Verify Tunnel Monitoring Is On
153     [Documentation]    This keyword will get tep:show output and verify tunnel monitoring status
154     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
155     Log    ${output}
156     Should Contain    ${output}    ${TUNNEL_MONITOR_ON}
157
158 Ovs Tunnel Get
159     [Arguments]    ${bridge}
160     log    sudo ovs-vsctl list-ports ${bridge}
161     ${tun_name}    Execute Command    sudo ovs-vsctl list-ports ${bridge}
162     log    ${tun_name}
163     Should Not Be Empty    ${tun_name}
164     [Return]    ${tun_name}
165
166 Verify Tunnel Monitoring Params
167     [Arguments]    ${flag}
168     @{checklist}    create list    ${flag}
169     Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/    ${checklist}