BFD tunnel monitoring test cases suite. 49/53649/21
authorNazeerahamed <nazeerahamed.hunshyal@tcs.com>
Wed, 22 Mar 2017 14:47:51 +0000 (07:47 -0700)
committerJamo Luhrsen <jluhrsen@redhat.com>
Fri, 12 May 2017 22:36:39 +0000 (22:36 +0000)
New library added and Moved Datastore dump to this
common genius library file

Adding BFD file to testplan file of genius
Added __init__.robot to executed before BFD suite

Incorporate the review comments given by JamO like
implemented local keyword for repatative code,
removed sleeps, and defined a array to log required
datastore.

Removed single file execution which was there in genius
test plan file.

Update of review comment of patch 18 and rename of variable
in "Get Model Dump" keyword of common library

Review update on patch 19.
1. Add comment line for converting hex to decimal
2. Delete unwanted logs
3. Have a keyword for repeat lines

Change-Id: I0b6cff1c53b725c8f852ef0b063e37a73fce761a
Signed-off-by: Nazeerahamed <nazeerahamed.hunshyal@tcs.com>
csit/libraries/DataModels.robot
csit/libraries/Genius.robot [new file with mode: 0644]
csit/suites/genius/04_BFD_monitoring.robot [new file with mode: 0644]
csit/variables/genius/Modules.py [new file with mode: 0644]

index caa76fad5e28e8494e0ebfd51bdf37095e2b0ff5..36553c0fb92348527d98c1273747fe9d06ee8c4c 100644 (file)
@@ -4,11 +4,11 @@ Documentation     Library to deal with mdsal data models. Initially, as a common
 Library           RequestsLibrary
 
 *** Variables ***
-@{data_models}    ${EMPTY}
+@{internal_data_models}    ${EMPTY}
 
 *** Keywords ***
 Get Model Dump
-    [Arguments]    ${controller_ip}    ${data_models}=@{data_models}
+    [Arguments]    ${controller_ip}    ${data_models}=@{internal_data_models}
     [Documentation]    Will output a list of mdsal models using ${data_models} list
     # while feature request in bug 7892 is not done, we will quickly timeout and not retry the model dump get
     # request. This is because when it's done in a failed cluster state, it could take 20s for the reesponse to
diff --git a/csit/libraries/Genius.robot b/csit/libraries/Genius.robot
new file mode 100644 (file)
index 0000000..35ce273
--- /dev/null
@@ -0,0 +1,65 @@
+*** 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}
diff --git a/csit/suites/genius/04_BFD_monitoring.robot b/csit/suites/genius/04_BFD_monitoring.robot
new file mode 100644 (file)
index 0000000..3001118
--- /dev/null
@@ -0,0 +1,165 @@
+*** 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}
diff --git a/csit/variables/genius/Modules.py b/csit/variables/genius/Modules.py
new file mode 100644 (file)
index 0000000..539308f
--- /dev/null
@@ -0,0 +1,16 @@
+bfd_data_models = [
+        'config/itm-config:tunnel-monitor-enabled',
+        'config/itm-config:tunnel-monitor-interval',
+        'config/itm-state:dpn-endpoints',
+        'config/itm-state:external-tunnel-list',
+        'config/itm:transport-zones',
+        'config/network-topology:network-topology',
+        'config/opendaylight-inventory:nodes',
+        'operational/ietf-interfaces:interfaces',
+        'operational/ietf-interfaces:interfaces-state',
+        'operational/itm-config:tunnel-monitor-enabled',
+        'operational/itm-config:tunnel-monitor-interval',
+        'operational/itm-state:tunnels_state',
+        'operational/network-topology:network-topology',
+        'operational/odl-interface-meta:bridge-ref-info',
+]