--- /dev/null
+*** Settings ***
+Documentation This suite is a common keywordis file for genius project.
+Library OperatingSystem
+Library RequestsLibrary
+Library SSHLibrary
+Resource ../../variables/Variables.robot
+
+*** Variables ***
+
+*** Keywords ***
+Create Vteps
+ [Arguments] ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip}
+ [Documentation] This keyword creates VTEPs between ${TOOLS_SYSTEM_IP} and ${TOOLS_SYSTEM_2_IP}
+ ${body} OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan.json
+ ${substr} Should Match Regexp ${TOOLS_SYSTEM_IP} [0-9]\{1,3}\.[0-9]\{1,3}\.[0-9]\{1,3}\.
+ ${subnet} Catenate ${substr}0
+ Log ${subnet}
+ Set Global Variable ${subnet}
+ ${vlan}= Set Variable ${vlan}
+ ${gateway-ip}= Set Variable ${gateway-ip}
+ ${body} Set Json ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip} ${subnet}
+ ${vtep_body} Set Variable ${body}
+ Set Global Variable ${vtep_body}
+ ${resp} RequestsLibrary.Post Request session ${CONFIG_API}/itm:transport-zones/ data=${body}
+ Log ${resp.status_code}
+ should be equal as strings ${resp.status_code} 204
+
+Set Json
+ [Arguments] ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip} ${subnet}
+ [Documentation] Sets Json with the values passed for it.
+ ${body} OperatingSystem.Get File ${genius_config_dir}/Itm_creation_no_vlan.json
+ ${body} replace string ${body} 1.1.1.1 ${subnet}
+ ${body} replace string ${body} "dpn-id": 101 "dpn-id": ${Dpn_id_1}
+ ${body} replace string ${body} "dpn-id": 102 "dpn-id": ${Dpn_id_2}
+ ${body} replace string ${body} "ip-address": "2.2.2.2" "ip-address": "${TOOLS_SYSTEM_IP}"
+ ${body} replace string ${body} "ip-address": "3.3.3.3" "ip-address": "${TOOLS_SYSTEM_2_IP}"
+ ${body} replace string ${body} "vlan-id": 0 "vlan-id": ${vlan}
+ ${body} replace string ${body} "gateway-ip": "0.0.0.0" "gateway-ip": "${gateway-ip}"
+ Log ${body}
+ [Return] ${body} # returns complete json that has been updated
+
+Get Dpn Ids
+ [Arguments] ${connection_id}
+ [Documentation] This keyword gets the DPN id of the switch after configuring bridges on it.It returns the captured DPN id.
+ Switch connection ${connection_id}
+ ${cmd} set Variable sudo ovs-vsctl show | grep Bridge | awk -F "\\"" '{print $2}'
+ ${Bridgename1} Execute command ${cmd}
+ log ${Bridgename1}
+ ${output1} Execute command sudo ovs-ofctl show -O Openflow13 ${Bridgename1} | head -1 | awk -F "dpid:" '{ print $2 }'
+ log ${output1}
+ # "echo \$\(\(16\#${output1}\)\) command below converts ovs dpnid (i.e., output1) from hexadecimal to decimal."
+ ${Dpn_id} Execute command echo \$\(\(16\#${output1}\)\)
+ log ${Dpn_id}
+ [Return] ${Dpn_id}
+
+Delete All Sessions
+ [Documentation] This will delete vtep.
+ ${resp} RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/ data=${vtep_body}
+ Log ${resp.status_code}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Log "Before disconnecting CSS with controller"
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
+ Log ${output}
--- /dev/null
+*** Settings ***
+Documentation Test Suite for BFD tunnel monitoring
+Suite Setup Create Session session http://${ODL_SYSTEM_IP}:${RESTCONFPORT} auth=${AUTH} headers=${HEADERS}
+Suite Teardown Delete All Sessions
+Test Teardown Get Model Dump ${ODL_SYSTEM_IP} ${bfd_data_models}
+Library OperatingSystem
+Library String
+Library RequestsLibrary
+Library Collections
+Library re
+Library SSHLibrary
+Resource ../../variables/Variables.robot
+Variables ../../variables/genius/Modules.py
+Resource ../../libraries/Genius.robot
+Resource ../../libraries/DataModels.robot
+Resource ../../libraries/Utils.robot
+Resource ../../libraries/VpnOperations.robot
+Resource ../../libraries/KarafKeywords.robot
+
+*** Variables ***
+@{itm_created} TZA
+${genius_config_dir} ${CURDIR}/../../variables/genius
+${Bridge-1} BR1
+${Bridge-2} BR2
+${TEP_SHOW} tep:show
+${TEP_SHOW_STATE} tep:show-state
+${TUNNEL_MONITOR_ON} Tunnel Monitoring (for VXLAN tunnels): On
+${DEFAULT_MONITORING_INTERVAL} Tunnel Monitoring Interval (for VXLAN tunnels): 1000
+${TUNNEL_MONITOR_OFF} Tunnel Monitoring (for VXLAN tunnels): Off
+${INTERVAL_5000} {"tunnel-monitor-interval":{"interval":5000}}
+${OK_201} 201
+${ENABLE_MONITORING} {"tunnel-monitor-params":{"enabled":true,"monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
+${DISABLE_MONITORING} {"tunnel-monitor-params":{"enabled":"false","monitor-protocol":"odl-interface:tunnel-monitoring-type-bfd"}}
+${INTERFACE_DS_MONI_FALSE} "odl-interface:monitor-enabled": false
+${INTERFACE_DS_MONI_TRUE} "odl-interface:monitor-enabled": true
+${INTERFACE_DS_MONI_INT_1000} "odl-interface:monitor-interval": 1000
+${INTERFACE_DS_MONI_INT_5000} "odl-interface:monitor-interval": 5000
+${TUNNEL_MONI_PROTO} tunnel-monitoring-type-bfd
+
+*** Test Cases ***
+BFD_TC00 Create ITM between DPNs Verify_BFD_Enablement
+ [Documentation] Create ITM between DPNs Verify_BFD_Enablement
+ ${Dpn_id_1} Get Dpn Ids ${conn_id_1}
+ ${Dpn_id_2} Get Dpn Ids ${conn_id_2}
+ Set Global Variable ${Dpn_id_1}
+ Set Global Variable ${Dpn_id_2}
+ ${vlan}= Set Variable 0
+ ${gateway-ip}= Set Variable 0.0.0.0
+ Create Vteps ${TOOLS_SYSTEM_IP} ${TOOLS_SYSTEM_2_IP} ${vlan} ${gateway-ip}
+ Wait Until Keyword Succeeds 10s 1s Verify Tunnel Status as UP
+
+BFD_TC01 Verify by default BFD monitoring is enabled on Controller
+ [Documentation] Verify by default BFD monitoring is enabled on Controller
+ Verify Tunnel Monitoring Is On
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_1000} ${TUNNEL_MONI_PROTO}
+
+BFD_TC02 Verify that BFD tunnel monitoring interval is set with appropriate default value i.e.,1000
+ [Documentation] This will verify BFD tunnel monitoring default interval
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ Should Contain ${output} ${DEFAULT_MONITORING_INTERVAL}
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_1000} ${TUNNEL_MONI_PROTO}
+
+BFD_TC04 Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
+ [Documentation] Verify that in controller tunnel status is up when ITM tunnel interface is brought up.
+ Verify Tunnel Monitoring Is On
+ Wait Until Keyword Succeeds 10s 1s Verify Tunnel Status as UP
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_1000} ${TUNNEL_MONI_PROTO}
+
+BFD_TC05 Verify BFD tunnel monitoring interval can be changed.
+ [Documentation] Verify BFD tunnel monitoring interval can be changed.
+ Log "Value of BFD monitoring interval before updating with new value"
+ ${oper_int} RequestsLibrary.Get Request session ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/
+ ${respjson} RequestsLibrary.To Json ${oper_int.content} pretty_print=True
+ Log ${respjson}
+ Log "Value of BFD monitoring interval is getting updated"
+ ${oper_int} RequestsLibrary.Put Request session ${CONFIG_API}/itm-config:tunnel-monitor-interval/ data=${INTERVAL_5000}
+ ${oper_int} RequestsLibrary.Get Request session ${OPERATIONAL_API}/itm-config:tunnel-monitor-interval/
+ ${respjson} RequestsLibrary.To Json ${oper_int.content} pretty_print=True
+ Log ${respjson}
+ Should Contain ${respjson} 5000
+ ${config_int} RequestsLibrary.Get Request session ${CONFIG_API}/itm-config:tunnel-monitor-interval/
+ ${respjson} RequestsLibrary.To Json ${config_int.content} pretty_print=True
+ Log ${respjson}
+ Should Contain ${respjson} 5000
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_5000} ${TUNNEL_MONI_PROTO}
+ SSHLibrary.Switch Connection ${conn_id_1}
+ Execute Command sudo ovs-vsctl del-port BR1 tap8ed70586-6c
+ ${tun_name} Execute Command sudo ovs-vsctl list-ports BR1
+ ${BFD_int_verification} Execute Command sudo ovs-vsctl list interface ${tun_name}
+ Should Contain ${BFD_int_verification} 5000
+ SSHLibrary.Switch Connection ${conn_id_2}
+ ${tun_name} Execute Command sudo ovs-vsctl list-ports BR2
+ ${BFD_int_verification} Execute Command sudo ovs-vsctl list interface ${tun_name}
+ Should Contain ${BFD_int_verification} 5000
+
+BFD_TC06 Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
+ [Documentation] Verify that the tunnel state goes to UNKNOWN when DPN is disconnected
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
+ Log ${output}
+ SSHLibrary.Switch Connection ${conn_id_1}
+ Execute Command sudo ovs-vsctl del-controller BR1
+ SSHLibrary.Switch Connection ${conn_id_2}
+ Execute Command sudo ovs-vsctl del-controller BR2
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
+ Log ${output}
+ Wait Until Keyword Succeeds 10s 1s Verify Tunnel Status as UNKNOWN
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_5000} ${TUNNEL_MONI_PROTO}
+ SSHLibrary.Switch Connection ${conn_id_1}
+ Execute Command sudo ovs-vsctl set-controller BR1 tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
+ SSHLibrary.Switch Connection ${conn_id_2}
+ Execute Command sudo ovs-vsctl set-controller BR2 tcp:${ODL_SYSTEM_IP}:${ODL_OF_PORT}
+ Log "After connecting CSS with controller"
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW_STATE}
+ Log ${output}
+ Wait Until Keyword Succeeds 10s 1s Verify Tunnel Status as UP
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_5000} ${TUNNEL_MONI_PROTO}
+
+BFD_TC07 Verify that BFD monitoring is disabled on Controller
+ [Documentation] Verify that BFD monitoring is disabled on Controller
+ ${resp} RequestsLibrary.Put Request session ${CONFIG_API}/itm-config:tunnel-monitor-params/ data=${DISABLE_MONITORING}
+ Should Be Equal As Strings ${resp.status_code} 201
+ ${oper} RequestsLibrary.Get Request session ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/
+ Log ${oper}
+ ${respjson} RequestsLibrary.To Json ${oper.content} pretty_print=True
+ Log ${respjson}
+ Should Contain ${respjson} false
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ Should Contain ${output} ${TUNNEL_MONITOR_OFF}
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_FALSE} ${INTERFACE_DS_MONI_INT_5000} ${TUNNEL_MONI_PROTO}
+ Log "Verifying tunnel is UP after BFD is disabled"
+ Wait Until Keyword Succeeds 10s 1s Verify Tunnel Status as UP
+ Log "Enabling tunnel monitoring once again"
+ ${resp} RequestsLibrary.Put Request session ${CONFIG_API}/itm-config:tunnel-monitor-params/ data=${ENABLE_MONITORING}
+ Should Be Equal As Strings ${resp.status_code} 200
+ ${oper} RequestsLibrary.Get Request session ${OPERATIONAL_API}/itm-config:tunnel-monitor-params/
+ Log ${oper}
+ ${respjson} RequestsLibrary.To Json ${oper.content} pretty_print=True
+ Log ${respjson}
+ Should Contain ${respjson} true
+ Verify Tunnel Monitoring Is On
+ Verify Config Ietf Interface Output ${INTERFACE_DS_MONI_TRUE} ${INTERFACE_DS_MONI_INT_5000} ${TUNNEL_MONI_PROTO}
+
+*** Keywords ***
+Verify Config Ietf Interface Output
+ [Arguments] ${state} ${interval} ${proto}
+ ${int_resp} RequestsLibrary.Get Request session ${CONFIG_API}/ietf-interfaces:interfaces/
+ ${respjson} RequestsLibrary.To Json ${int_resp.content} pretty_print=True
+ Log ${respjson}
+ Should Contain ${respjson} ${state}
+ Should Contain ${respjson} ${interval}
+ Should Contain ${respjson} ${proto}
+
+Verify Tunnel Monitoring Is On
+ [Documentation] This keyword will get tep:show output and verify tunnel monitoring status
+ ${output}= Issue Command On Karaf Console ${TEP_SHOW}
+ Log ${output}
+ Should Contain ${output} ${TUNNEL_MONITOR_ON}