Remove setting of TRACE to entire netvirt in vpnservice
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / basic_vpnservice.robot
index 2ff5a610022b0a9c9a8d8c12b942090961a74724..89e4155e65d3a9ebe7e5f81f042974ead9ab2a82 100644 (file)
@@ -15,7 +15,7 @@ Resource          ../../../libraries/DevstackUtils.robot
 Resource          ../../../libraries/VpnOperations.robot
 Resource          ../../../libraries/OVSDB.robot
 Resource          ../../../libraries/SetupUtils.robot
-Variables         ../../../variables/Variables.py
+Resource          ../../../variables/Variables.robot
 
 *** Variables ***
 @{NETWORKS}       NET10    NET20
@@ -31,6 +31,7 @@ Variables         ../../../variables/Variables.py
 @{CREATE_EXPORT_RT}    ["2200:2"]    ["2300:2"]    ["2400:2"]
 @{CREATE_IMPORT_RT}    ["2200:2"]    ["2300:2"]    ["2400:2"]
 @{EXTRA_NW_IP}    40.1.1.2    50.1.1.2
+@{EXTRA_NW_SUBNET}    40.1.1.0/24    50.1.1.0/24
 # Values passed for extra routes
 ${RT_OPTIONS}     --routes type=dict list=true
 ${RT_CLEAR}       --routes action=clear
@@ -44,6 +45,7 @@ Create Neutron Networks
     Log    ${NET_LIST}
     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/networks/    ${NETWORKS}
 
 Create Neutron Subnets
     [Documentation]    Create two subnets for previously created networks
@@ -53,6 +55,7 @@ Create Neutron Subnets
     Log    ${SUB_LIST}
     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/subnets/    ${SUBNETS}
 
 Add Ssh Allow Rule
     [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
@@ -70,12 +73,7 @@ Create Neutron Ports
     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=sg-vpnservice
     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=sg-vpnservice
     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=sg-vpnservice
-
-Check OpenDaylight Neutron Ports
-    [Documentation]    Checking OpenDaylight Neutron API for known ports
-    ${resp}    RequestsLibrary.Get Request    session    ${NEUTRON_PORTS_API}
-    Log    ${resp.content}
-    Should be Equal As Strings    ${resp.status_code}    200
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/ports/    ${PORT_LIST}
 
 Create Nova VMs
     [Documentation]    Create Vm instances on compute node with port
@@ -83,14 +81,28 @@ Create Nova VMs
     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET10[1]}    ${OS_COMPUTE_2_IP}    sg=sg-vpnservice
     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET20[0]}    ${OS_COMPUTE_1_IP}    sg=sg-vpnservice
     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET20[1]}    ${OS_COMPUTE_2_IP}    sg=sg-vpnservice
+    ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
+    : FOR    ${VM}    IN    @{VM_INSTANCES}
+    \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
     Log    Check for routes
     Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate
-    ${VM_IP_NET10}    ${DHCP_IP1}    Wait Until Keyword Succeeds    30s    10s    Verify VMs Received DHCP Lease    @{VM_INSTANCES_NET10}
+    : FOR    ${index}    IN RANGE    1    5
+    \    ${VM_IP_NET10}    ${DHCP_IP1}    Wait Until Keyword Succeeds    30s    10s    Verify VMs Received DHCP Lease
+    \    ...    @{VM_INSTANCES_NET10}
+    \    ${VM_IP_NET20}    ${DHCP_IP2}    Wait Until Keyword Succeeds    30s    10s    Verify VMs Received DHCP Lease
+    \    ...    @{VM_INSTANCES_NET20}
+    \    ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET10}    ${VM_IP_NET20}
+    \    ${status}    ${message}    Run Keyword And Ignore Error    List Should Not Contain Value    ${VM_IPS}    None
+    \    Exit For Loop If    '${status}' == 'PASS'
+    \    BuiltIn.Sleep    5s
+    : FOR    ${vm}    IN    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
+    \    Write Commands Until Prompt    nova console-log ${vm}    30s
     Log    ${VM_IP_NET10}
     Set Suite Variable    ${VM_IP_NET10}
-    ${VM_IP_NET20}    ${DHCP_IP2}    Wait Until Keyword Succeeds    30s    10s    Verify VMs Received DHCP Lease    @{VM_INSTANCES_NET20}
     Log    ${VM_IP_NET20}
     Set Suite Variable    ${VM_IP_NET20}
+    Should Not Contain    ${VM_IP_NET10)    None
+    Should Not Contain    ${VM_IP_NET20}    None
 
 Check ELAN Datapath Traffic Within The Networks
     [Documentation]    Checks datapath within the same network with different vlans.
@@ -102,18 +114,34 @@ Check ELAN Datapath Traffic Within The Networks
 Create Routers
     [Documentation]    Create Router
     Create Router    ${ROUTERS[0]}
+    ${router_output} =    List Router
+    Log    ${router_output}
+    Should Contain    ${router_output}    ${ROUTERS[0]}
+    ${router_list} =    Create List    ${ROUTERS[0]}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${CONFIG_API}/neutron:neutron/routers/    ${router_list}
 
 Add Interfaces To Router
     [Documentation]    Add Interfaces
+    ${devstack_conn_id} =    Get ControlNode Connection
     : FOR    ${INTERFACE}    IN    @{SUBNETS}
     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
+    ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
+    : FOR    ${INTERFACE}    IN    @{SUBNETS}
+    \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
+    \    Should Contain    ${interface_output}    ${subnet_id}
 
 Check L3_Datapath Traffic Across Networks With Router
     [Documentation]    Datapath test across the networks using router for L3.
-    ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    ${VM_IP_NET20[0]}    ${VM_IP_NET20[1]}
+    Log    Verification of FIB Entries and Flow
+    ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
+    Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/    ${vm_instances}
+    Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${VM_IP_NET10}
+    Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${VM_IP_NET20}
+    Log    L3 Datapath test across the networks using router
+    ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    @{VM_IP_NET20}
     Log    ${dst_ip_list}
     Test Operations From Vm Instance    ${NETWORKS[0]}    ${VM_IP_NET10[1]}    ${dst_ip_list}
-    ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    ${VM_IP_NET10[0]}    ${VM_IP_NET10[1]}
+    ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    @{VM_IP_NET10}
     Log    ${dst_ip_list}
     Test Operations From Vm Instance    ${NETWORKS[1]}    ${VM_IP_NET20[0]}    ${dst_ip_list}
 
@@ -130,6 +158,9 @@ Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${EXT_RT2}
     Update Router    @{ROUTERS}[0]    ${cmd}
     Show Router    @{ROUTERS}[0]    -D
+    Log    "Verify FIB table"
+    ${vm_instances} =    Create List    @{EXTRA_NW_SUBNET}
+    Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/    ${vm_instances}
     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
     Should Contain    ${output}    64 bytes
     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping -c 3 @{EXTRA_NW_IP}[1]
@@ -153,13 +184,10 @@ Delete And Recreate Extra Route
     Show Router    @{ROUTERS}[0]    -D
     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping -c 3 @{EXTRA_NW_IP}[0]
     Should Contain    ${output}    64 bytes
-    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
-    Show Router    @{ROUTERS}[0]    -D
-
-Delete Router Interfaces
-    [Documentation]    Remove Interface to the subnets.
-    : FOR    ${INTERFACE}    IN    @{SUBNETS}
-    \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
+    # clear off extra-routes before the next set of tests
+    [Teardown]    Run Keywords    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
+    ...    AND    Show Router    @{ROUTERS}[0]    -D
+    ...    AND    Get Test Teardown Debugs
 
 Create L3VPN
     [Documentation]    Creates L3VPN and verify the same
@@ -179,7 +207,26 @@ Associate L3VPN To Routers
     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
     Should Contain    ${resp}    ${router_id}
 
-Dissociate L3VPN To Routers
+Verify L3VPN Datapath With Router Association
+    [Documentation]    Datapath test across the networks using L3VPN with router association.
+    Log    Verify VPN interfaces, FIB entries and Flow table
+    ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
+    Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${CONFIG_API}/l3vpn:vpn-interfaces/    ${vm_instances}
+    ${RD} =    Strip String    ${CREATE_RD[0]}    characters="[]
+    Log    ${RD}
+    Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${RD}/    ${vm_instances}
+    Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
+    Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
+    Log    Check datapath from network1 to network2
+    ${dst_ip_list} =    Create List    @{VM_IP_NET10}[1]    @{VM_IP_NET20}
+    Log    ${dst_ip_list}
+    Test Operations From Vm Instance    ${NETWORKS[0]}    @{VM_IP_NET10}[0]    ${dst_ip_list}
+    Log    Check datapath from network2 to network1
+    ${dst_ip_list} =    Create List    @{VM_IP_NET20}[1]    @{VM_IP_NET10}
+    Log    ${dst_ip_list}
+    Test Operations From Vm Instance    ${NETWORKS[1]}    @{VM_IP_NET20}[0]    ${dst_ip_list}
+
+Dissociate L3VPN From Routers
     [Documentation]    Dissociating router from L3VPN
     ${devstack_conn_id}=    Get ControlNode Connection
     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
@@ -187,6 +234,40 @@ Dissociate L3VPN To Routers
     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
     Should Not Contain    ${resp}    ${router_id}
 
+Delete Router And Router Interfaces With L3VPN
+    [Documentation]    Delete Router and Interface to the subnets with L3VPN assciate
+    # Asscoiate router with L3VPN
+    ${devstack_conn_id} =    Get ControlNode Connection
+    ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
+    Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
+    ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
+    Should Contain    ${resp}    ${router_id}
+    #Delete Interface
+    : FOR    ${INTERFACE}    IN    @{SUBNETS}
+    \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
+    ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
+    : FOR    ${INTERFACE}    IN    @{SUBNETS}
+    \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
+    \    Should Not Contain    ${interface_output}    ${subnet_id}
+    # Delete Router and Interface to the subnets.
+    Delete Router    ${ROUTERS[0]}
+    ${router_output} =    List Router
+    Log    ${router_output}
+    Should Not Contain    ${router_output}    ${ROUTERS[0]}
+    ${router_list} =    Create List    ${ROUTERS[0]}
+    Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${CONFIG_API}/neutron:neutron/routers/    ${router_list}
+    # Verify Router Entry removed from L3VPN
+    ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
+    Should Not Contain    ${resp}    ${router_id}
+
+Delete Router With NonExistentRouter Name
+    [Documentation]    Delete router with nonExistentRouter name
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output} =    Write Commands Until Prompt    neutron router-delete nonExistentRouter    30s
+    Close Connection
+    Should Match Regexp    ${output}    Unable to find router with name or id 'nonExistentRouter'|Unable to find router\\(s\\) with id\\(s\\) 'nonExistentRouter'
+
 Associate L3VPN To Networks
     [Documentation]    Associates L3VPN to networks and verify
     ${devstack_conn_id} =    Get ControlNode Connection
@@ -211,10 +292,6 @@ Dissociate L3VPN From Networks
     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
     Should Not Contain    ${resp}    ${network2_id}
 
-Delete Routers
-    [Documentation]    Delete Router and Interface to the subnets.
-    Delete Router    ${ROUTERS[0]}
-
 Delete L3VPN
     [Documentation]    Delete L3VPN
     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
@@ -248,7 +325,7 @@ Check Datapath Traffic Across Networks With L3VPN
 
 Delete Vm Instances
     [Documentation]    Delete Vm instances in the given Instance List
-    @{VM_INSTANCES}    Collections.Combine Lists    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
+    ${VM_INSTANCES} =    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
     : FOR    ${VmInstance}    IN    @{VM_INSTANCES}
     \    Delete Vm Instance    ${VmInstance}