Fix flowspec empty uri
[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 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
22 *** Variables ***
23 @{itm_created}    TZA
24 ${genius_config_dir}    ${CURDIR}/../../variables/genius
25 ${Bridge-1}       BR1
26 ${Bridge-2}       BR2
27 ${TEP_SHOW}       tep:show
28 ${TEP_SHOW_STATE}    tep:show-state
29 ${TUNNEL_MONITOR_ON}    Tunnel Monitoring (for VXLAN tunnels): On
30 ${DEFAULT_MONITORING_INTERVAL}    Tunnel Monitoring Interval (for VXLAN tunnels): 1000
31 ${TUNNEL_MONITOR_OFF}    Tunnel Monitoring (for VXLAN tunnels): Off
32 ${INTERVAL_5000}    {"tunnel-monitor-interval":{"interval":5000}}
33 ${OK_201}         201
34 ${ENABLE_MONITORING}    {"tunnel-monitor-params":{"enabled":true,"monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
35 ${DISABLE_MONITORING}    {"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 *** Test Cases ***
45 BFD_TC00 Create ITM between DPNs Verify_BFD_Enablement
46     [Documentation]    Create ITM between DPNs Verify_BFD_Enablement
47     ${Dpn_id_1}    Genius.Get Dpn Ids    ${conn_id_1}
48     ${Dpn_id_2}    Genius.Get Dpn Ids    ${conn_id_2}
49     ${vlan}=    Set Variable    0
50     ${gateway-ip}=    Set Variable    0.0.0.0
51     Genius.Create Vteps    ${Dpn_id_1}    ${Dpn_id_2}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}    ${vlan}    ${gateway-ip}
52     Wait Until Keyword Succeeds    30s    5s    Genius.Verify Tunnel Status as UP    TZA
53
54 BFD_TC01 Verify by default BFD monitoring is enabled on Controller
55     [Documentation]    Verify by default BFD monitoring is enabled on Controller
56     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Is On
57     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_1000}    ${TUNNEL_MONI_PROTO}
58
59 BFD_TC02 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 Is On
69     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status as UP    TZA
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     ${tun_name}    Wait Until Keyword Succeeds    20    5    Ovs Tunnel Get    ${TOOLS_SYSTEM_1_IP}
80     Wait Until Keyword Succeeds    20s    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun_name}    5000    ovs_system=${TOOLS_SYSTEM_1_IP}
81     ${tun_name}    Wait Until Keyword Succeeds    20    5    Ovs Tunnel Get    ${TOOLS_SYSTEM_2_IP}
82     Wait Until Keyword Succeeds    20s    5    OVSDB.Verify Ovs-vsctl Output    list interface ${tun_name}    5000    ovs_system=${TOOLS_SYSTEM_2_IP}
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     Issue Command On Karaf Console    ${TEP_SHOW}
87     Issue Command On Karaf Console    ${TEP_SHOW_STATE}
88     SSHLibrary.Switch Connection    ${conn_id_1}
89     Execute Command    sudo ovs-vsctl del-controller BR1
90     SSHLibrary.Switch Connection    ${conn_id_2}
91     Execute Command    sudo ovs-vsctl del-controller BR2
92     Issue Command On Karaf Console    ${TEP_SHOW}
93     Issue Command On Karaf Console    ${TEP_SHOW_STATE}
94     Wait Until Keyword Succeeds    10s    1s    Verify Tunnel Status as UNKNOWN
95     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
96     SSHLibrary.Switch Connection    ${conn_id_1}
97     Execute Command    sudo ovs-vsctl set-controller BR1 tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
98     SSHLibrary.Switch Connection    ${conn_id_2}
99     Execute Command    sudo ovs-vsctl set-controller BR2 tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
100     Log    "After connecting CSS with controller"
101     Issue Command On Karaf Console    ${TEP_SHOW}
102     Issue Command On Karaf Console    ${TEP_SHOW_STATE}
103     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status as UP    TZA
104     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
105
106 BFD_TC07 Verify that BFD monitoring is disabled on Controller
107     [Documentation]    Verify that BFD monitoring is disabled on Controller
108     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${DISABLE_MONITORING}
109     Should Be Equal As Strings    ${resp.status_code}    201
110     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_FALSE}
111     ${output}=    Issue Command On Karaf Console    ${TEP_SHOW}
112     Should Contain    ${output}    ${TUNNEL_MONITOR_OFF}
113     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_FALSE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
114     Wait Until Keyword Succeeds    10s    1s    Genius.Verify Tunnel Status as UP    TZA
115     ${resp}    RequestsLibrary.Put Request    session    ${CONFIG_API}/itm-config:tunnel-monitor-params/    data=${ENABLE_MONITORING}
116     Should Be Equal As Strings    ${resp.status_code}    200
117     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Params    ${TUNNEL_MONI_PARAMS_TRUE}
118     Wait Until Keyword Succeeds    10s    2s    Verify Tunnel Monitoring Is On
119     Wait Until Keyword Succeeds    10s    2s    Verify Config Ietf Interface Output    ${INTERFACE_DS_MONI_TRUE}    ${INTERFACE_DS_MONI_INT_5000}    ${TUNNEL_MONI_PROTO}
120
121 *** Keywords ***
122 Verify Config Ietf Interface Output
123     [Arguments]    ${state}    ${interval}    ${proto}
124     ${int_resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/ietf-interfaces:interfaces/
125     ${respjson}    RequestsLibrary.To Json    ${int_resp.content}    pretty_print=True
126     Log    ${respjson}
127     Should Contain    ${respjson}    ${state}
128     Should Contain    ${respjson}    ${interval}
129     Should Contain    ${respjson}    ${proto}
130
131 Ovs Tunnel Get
132     [Arguments]    ${tools_ip}
133     [Documentation]    This keyword will return the tunnel name on OVS
134     ${list_interface}    Utils.Run Command On Remote System    ${tools_ip}    sudo ovs-vsctl list interface
135     ${tun_line}    ${tun_name}    Should Match Regexp    ${list_interface}    name\\s+: "(tun.*)"
136     log    ${tun_name}
137     Should Not Be Empty    ${tun_name}
138     [Return]    ${tun_name}
139
140 Verify Tunnel Monitoring Params
141     [Arguments]    ${flag}
142     @{checklist}    create list    ${flag}
143     Check For Elements At URI    ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/    ${checklist}