Update distribution version suite for Nitrogen
[integration/test.git] / csit / suites / genius / 03_Configure_ITM.robot
old mode 100755 (executable)
new mode 100644 (file)
index 4b270d5..ddd92ed
@@ -2,12 +2,16 @@
 Documentation     Test Suite for ITM
 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
 Variables         ../../variables/Variables.py
+Variables         ../../variables/genius/Modules.py
+Resource          ../../libraries/DataModels.robot
 Library           Collections
 Resource          ../../libraries/Utils.robot
+Resource          ../../libraries/CompareStream.robot
 Library           re
 
 *** Variables ***
@@ -36,8 +40,8 @@ Create and Verify VTEP -No Vlan
     ...    ${type}
     Set Global Variable    ${tunnel-2}
     ${tunnel-type}=    Set Variable    type: vxlan
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
     ...    ${tunnel-1}    ${tunnel-type}
@@ -56,7 +60,8 @@ Create and Verify VTEP -No Vlan
     ${port-num-2}    Get From List    ${return}    3
     Log    >>>>>Verify Oper data base of Interface state<<<<<
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-1}
     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-2}
@@ -67,9 +72,10 @@ Create and Verify VTEP -No Vlan
     ${check-4}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_2}    ${Bridge-2}
     ...    ${port-num-2}
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain    ${resp.content}    ${lower-layer-if-1}    ${lower-layer-if-2}
-    Log    ${resp.content}
 
 Delete and Verify VTEP -No Vlan
     [Documentation]    This Delete testcase , deletes the ITM tunnel created between 2 dpns.
@@ -99,8 +105,8 @@ Create and Verify VTEP IPv6 - No Vlan
     ...    ${type}
     Set Global Variable    ${tunnel-2}
     ${tunnel-type}=    Set Variable    type: vxlan
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/    headers=${ACCEPT_XML}
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/    headers=${ACCEPT_XML}
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/    headers=${ACCEPT_XML}
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/    headers=${ACCEPT_XML}
     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
     ...    ${tunnel-1}    ${tunnel-type}
@@ -136,8 +142,8 @@ Create and Verify VTEP-Vlan
     log    ${tunnel-4}
     Set Global Variable    ${tunnel-4}
     ${tunnel-type}=    Set Variable    type: vxlan
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
     Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}    ${TOOLS_SYSTEM_2_IP}
     ...    ${tunnel-3}    ${tunnel-type}
@@ -156,7 +162,8 @@ Create and Verify VTEP-Vlan
     ${port-num-2}    Get From List    ${return}    3
     Log    >>>>>Verify Oper data base of Interface state<<<<<
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-3}
     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-4}
     Log    >>>>> Checking Entry in table 0 on OVS 1<<<<<
@@ -164,7 +171,8 @@ Create and Verify VTEP-Vlan
     Log    >>>>> Checking Entry in table 0 on OVS \ 2<<<<<
     Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_2}    ${Bridge-2}    ${port-num-2}
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain    ${resp.content}    ${lower-layer-if-2}    ${lower-layer-if-1}
 
@@ -194,8 +202,8 @@ Create VTEP - Vlan and Gateway
     log    ${tunnel-6}
     Set Global Variable    ${tunnel-6}
     ${tunnel-type}=    Set Variable    type: vxlan
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
-    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_1}/
+    Wait Until Keyword Succeeds    40    5    Get Data From URI    session    ${CONFIG_API}/itm-state:dpn-endpoints/DPN-TEPs-info/${Dpn_id_2}/
     Log    >>>>OVS Validation in Switch 1 for Tunnel Created<<<<<
     ${check-1}    Wait Until Keyword Succeeds    40    10    Ovs Verification 2 Dpn    ${conn_id_1}    ${TOOLS_SYSTEM_IP}
     ...    ${TOOLS_SYSTEM_2_IP}    ${tunnel-5}    ${tunnel-type}
@@ -213,7 +221,8 @@ Create VTEP - Vlan and Gateway
     ${lower-layer-if-2}    Get from List    ${return}    2
     ${port-num-2}    Get From List    ${return}    3
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Contain    ${resp.content}    ${Dpn_id_1}    ${tunnel-5}
     Should Contain    ${resp.content}    ${Dpn_id_2}    ${tunnel-6}
     ${check-3}    Wait Until Keyword Succeeds    40    10    Check Table0 Entry for 2 Dpn    ${conn_id_1}    ${Bridge-1}
@@ -223,9 +232,10 @@ Create VTEP - Vlan and Gateway
     ...    ${port-num-2}
     Log    ${check-4}
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/opendaylight-inventory:nodes/
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain    ${resp.content}    ${lower-layer-if-2}    ${lower-layer-if-1}
-    Log    ${resp.content}
 
 Delete VTEP -Vlan and gateway
     [Documentation]    This testcase deletes the ITM tunnel created between 2 dpns.
@@ -278,15 +288,18 @@ Get Tunnel
     [Documentation]    This Keyword Gets the Tunnel /Interface name which has been created between 2 DPNS by passing source , destination DPN Ids along with the type of tunnel which is configured.
     ${resp}    RequestsLibrary.Get Request    session    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/${type}/
     Log    ${CONFIG_API}/itm-state:tunnel-list/internal-tunnel/${src}/${dst}/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain    ${resp.content}    ${src}    ${dst}    TUNNEL:
     ${json}=    evaluate    json.loads('''${resp.content}''')    json
     log to console    \nOriginal JSON:\n${json}
-    ${Tunnel}    Collections.Get From Dictionary    ${json["internal-tunnel"][0]}    tunnel-interface-name
-    Log To Console    ${Tunnel}
-    Log    ${Tunnel}
-    [Return]    ${Tunnel}
+    ${expected_tunnel_interface_name} =    Set_Variable_If_At_Least_Carbon    tunnel-interface-names    tunnel-interface-name
+    ${Tunnels}    Collections.Get From Dictionary    ${json["internal-tunnel"][0]}    ${expected_tunnel_interface_name}
+    Log To Console    ${Tunnels}
+    Log    ${Tunnels}
+    ${tunnel_interface} =    Set_Variable_If_At_Least_Carbon    ${Tunnels[0]}    ${Tunnels}
+    [Return]    ${tunnel_interface}
 
 Validate interface state
     [Arguments]    ${tunnel-1}    ${dpid-1}    ${tunnel-2}    ${dpid-2}
@@ -345,7 +358,8 @@ Validate interface state Delete
     [Documentation]    Check for the Tunnel / Interface absence in OPERATIONAL data base of IETF interface after ITM transport zone is deleted.
     Log    ${tunnel}
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    404
     Should not contain    ${resp.content}    ${tunnel}
 
@@ -379,7 +393,8 @@ check interface status
     [Documentation]    Verifies the operational state of the interface .
     ${resp}    RequestsLibrary.Get Request    session    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
     Log    ${OPERATIONAL_API}/ietf-interfaces:interfaces-state/interface/${tunnel}/
-    Log    ${resp.content}
+    ${respjson}    RequestsLibrary.To Json    ${resp.content}    pretty_print=True
+    Log    ${respjson}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should not contain    ${resp.content}    down
     Should Contain    ${resp.content}    ${tunnel}    up    up