VPNservice Datapath TC and added additional validation 03/49403/10
authorsuvitha.balu <suvitha.balu@tcs.com>
Thu, 15 Dec 2016 05:06:51 +0000 (10:36 +0530)
committerJamo Luhrsen <jluhrsen@redhat.com>
Sat, 7 Jan 2017 05:36:33 +0000 (05:36 +0000)
Change-Id: Ibd2c344ec867536b861e42d111af937422852ce6
Signed-off-by: suvitha.balu <suvitha.balu@tcs.com>
csit/libraries/OpenStackOperations.robot
csit/libraries/VpnOperations.robot
csit/suites/netvirt/Netvirt_Vpnservice/basic_vpnservice.robot

index 3ade496689bccd702dc0c9f7f5321b49b3c64623..26355e3c23c57c33055526e74c4ea2a68ac1ef46 100644 (file)
@@ -3,7 +3,7 @@ Documentation     Openstack library. This library is useful for tests to create
 Library           SSHLibrary
 Resource          Netvirt.robot
 Resource          Utils.robot
-Variables         ../variables/Variables.py
+Resource          ../variables/Variables.robot
 
 *** Keywords ***
 Source Password
@@ -187,6 +187,17 @@ Get Net Id
     Log    ${net_id}
     [Return]    ${net_id}
 
+Get Subnet Id
+    [Arguments]    ${subnet_name}    ${devstack_conn_id}
+    [Documentation]    Retrieve the subnet id for the given subnet name
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron subnet-list | grep "${subnet_name}" | awk '{print $2}'    30s
+    Log    ${output}
+    ${splitted_output}=    Split String    ${output}    ${EMPTY}
+    ${subnet_id}=    Get from List    ${splitted_output}    0
+    Log    ${subnet_id}
+    [Return]    ${subnet_id}
+
 Get Port Id
     [Arguments]    ${port_name}    ${devstack_conn_id}
     [Documentation]    Retrieve the port id for the given port name to attach specific vm instance to a particular port
@@ -200,7 +211,7 @@ Get Port Id
 
 Get Router Id
     [Arguments]    ${router1}    ${devstack_conn_id}
-    [Documentation]    Retrieve the net id for the given network name to create specific vm instance
+    [Documentation]    Retrieve the router id for the given router name
     Switch Connection    ${devstack_conn_id}
     ${output}=    Write Commands Until Prompt    neutron router-list | grep "${router1}" | awk '{print $2}'    30s
     Log    ${output}
@@ -228,7 +239,6 @@ Create Vm Instance With Port On Compute Node
     ${hostname_compute_node}=    Run Command On Remote System    ${compute_node}    hostname
     ${output}=    Write Commands Until Prompt    nova boot --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg} --availability-zone nova:${hostname_compute_node}    30s
     Log    ${output}
-    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${vm_instance_name}
 
 Verify VM Is ACTIVE
     [Arguments]    ${vm_name}
@@ -407,6 +417,15 @@ Create Router
     Close Connection
     Should Contain    ${output}    Created a new router
 
+List Router
+    [Documentation]    List Router and return output with neutron client.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron router-list    30s
+    Close Connection
+    Log    ${output}
+    [Return]    ${output}
+
 Add Router Interface
     [Arguments]    ${router_name}    ${interface_name}
     ${devstack_conn_id}=    Get ControlNode Connection
@@ -415,6 +434,16 @@ Add Router Interface
     Close Connection
     Should Contain    ${output}    Added interface
 
+Show Router Interface
+    [Arguments]    ${router_name}
+    [Documentation]    List Router interface associated with given Router and return output with neutron client.
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    neutron router-port-list ${router_name} -f csv    30s
+    Close Connection
+    Log    ${output}
+    [Return]    ${output}
+
 Add Router Gateway
     [Arguments]    ${router_name}    ${network_name}
     ${devstack_conn_id}=    Get ControlNode Connection
index 8c54061d3f5200b4a5398de21c2b37c3a80ec687..dba38bbf48af2186f77d134ea0c6ca205c9d14ed 100644 (file)
@@ -7,13 +7,13 @@ Resource          ../variables/Variables.robot
 Library           Collections
 Library           String
 Library           OperatingSystem
-Variables         ../variables/Variables.py
 
 *** Variables ***
 &{ITM_CREATE_DEFAULT}    tunneltype=vxlan    vlanid=0    prefix=1.1.1.1/24    gateway=0.0.0.0    dpnid1=1    portname1=BR1-eth1    ipaddress1=2.2.2.2
 ...               dpnid2=2    portname2= BR2-eth1    ipaddress2=3.3.3.3
 &{L3VPN_CREATE_DEFAULT}    vpnid=4ae8cd92-48ca-49b5-94e1-b2921a261111    name=vpn1    rd=["2200:1"]    exportrt=["2200:1","8800:1"]    importrt=["2200:1","8800:1"]    tenantid=6c53df3a-3456-11e5-a151-feff819cdc9f
 ${VAR_BASE}       ${CURDIR}/../variables/vpnservice/
+${ODL_FLOWTABLE_L3VPN}    21
 
 *** Keywords ***
 VPN Create L3VPN
@@ -78,3 +78,14 @@ ITM Delete Tunnel
     Log    ${resp.content}
     Should Be Equal As Strings    ${resp.status_code}    200
     [Return]    ${resp.content}
+
+Verify Flows Are Present For L3VPN
+    [Arguments]    ${ip}    ${vm_ips}
+    [Documentation]    Verify Flows Are Present For L3VPN
+    ${flow_output}=    Run Command On Remote System    ${ip}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
+    Log    ${flow_output}
+    Should Contain    ${flow_output}    table=${ODL_FLOWTABLE_L3VPN}
+    ${l3vpn_table} =    Get Lines Containing String    ${flow_output}    table=${ODL_FLOWTABLE_L3VPN}
+    Log    ${l3vpn_table}
+    : FOR    ${i}    IN    @{vm_ips}
+    \    ${resp}=    Should Contain    ${l3vpn_table}    ${i}
index 2ff5a610022b0a9c9a8d8c12b942090961a74724..8dbaa829f3454de1e7b4356cae18c1221c988ce1 100644 (file)
@@ -4,9 +4,10 @@ Documentation     Test suite to validate vpnservice functionality in an openstac
 ...               integration bridges and vxlan tunnels.
 Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
 ...               AND    DevstackUtils.Devstack Suite Setup
+...               AND    Enable ODL Karaf Log
 Suite Teardown    Close All Connections
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
-Test Teardown     Get Test Teardown Debugs
+Test Teardown     Run Keyword If Test Failed    Get Test Teardown Debugs
 Library           OperatingSystem
 Library           RequestsLibrary
 Resource          ../../../libraries/Utils.robot
@@ -15,7 +16,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 +32,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 +46,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 +56,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 +74,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,6 +82,9 @@ 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}
@@ -102,18 +104,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 +148,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]
@@ -156,11 +177,6 @@ Delete And Recreate Extra Route
     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}
-
 Create L3VPN
     [Documentation]    Creates L3VPN and verify the same
     ${devstack_conn_id} =    Get ControlNode Connection
@@ -179,7 +195,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 +222,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 Unknown ID
+    [Documentation]    Delete router with unknown ID
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output} =    Write Commands Until Prompt    neutron router-delete unknowRouter    30s
+    Close Connection
+    Should Contain    ${output}    Unable to find router with name or id
+
 Associate L3VPN To Networks
     [Documentation]    Associates L3VPN to networks and verify
     ${devstack_conn_id} =    Get ControlNode Connection
@@ -211,10 +280,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 +313,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}
 
@@ -302,3 +367,9 @@ Wait For Routes To Propogate
     ${net_id} =    Get Net Id    @{NETWORKS}[1]    ${devstack_conn_id}
     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
     Should Contain    ${output}    @{SUBNET_CIDR}[1]
+
+Enable ODL Karaf Log
+    [Documentation]    Uses log:set TRACE org.opendaylight.netvirt to enable log
+    Log    "Enabled ODL Karaf log for org.opendaylight.netvirt"
+    ${output}=    Issue Command On Karaf Console    log:set TRACE org.opendaylight.netvirt
+    Log    ${output}