Datapath validation test cases for ELAN,router and extra route 36/46836/20
authorrahul.agarwal <rahul.agarwal3@tcs.com>
Wed, 12 Oct 2016 20:05:32 +0000 (01:35 +0530)
committerJamo Luhrsen <jluhrsen@redhat.com>
Mon, 24 Oct 2016 21:51:37 +0000 (21:51 +0000)
Change-Id: Idda6da029d2990600c7a4b9dec9367ad90806ec9
Signed-off-by: rahul.agarwal <rahul.agarwal3@tcs.com>
csit/libraries/OpenStackOperations.robot
csit/suites/openstack/vpnservice/basic_vpnservice.robot

index f018dba6b73faa880c041b40e24110476160768e..b2aadf13d1b749c7f57232998a496ff6c359b7e2 100644 (file)
@@ -280,6 +280,21 @@ Check Metadata Access
     ${output}=    Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
     Should Contain    ${output}    200
 
+Execute Command on VM Instance
+    [Arguments]    ${net_name}    ${src_ip}    ${cmd}    ${user}=cirros    ${password}=cubswin:)
+    [Documentation]    Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
+    ${devstack_conn_id} =    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${net_id} =    Get Net Id    ${net_name}    ${devstack_conn_id}
+    ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh ${user}@${src_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no    d:
+    Log    ${output}
+    ${output} =    Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
+    Log    ${output}
+    ${rcode} =    Run Keyword And Return Status    Check If Console Is VmInstance
+    ${output} =    Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ${cmd}    ${OS_SYSTEM_PROMPT}
+    [Teardown]    Exit From Vm Console
+    [Return]    ${output}
+
 Test Operations From Vm Instance
     [Arguments]    ${net_name}    ${src_ip}    ${list_of_local_dst_ips}    ${l2_or_l3}=l2    ${list_of_external_dst_ips}=${NONE}    ${user}=cirros
     ...    ${password}=cubswin:)
@@ -295,15 +310,9 @@ Test Operations From Vm Instance
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ifconfig    ${OS_SYSTEM_PROMPT}
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route    ${OS_SYSTEM_PROMPT}
     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    arp -an    ${OS_SYSTEM_PROMPT}
-    ${dest_vm}=    Get From List    ${list_of_local_dst_ips}    0
-    Log    ${dest_vm}
-    Run Keyword If    ${rcode}    Check Ping    ${dest_vm}
-    ${dest_dhcp}=    Get From List    ${list_of_local_dst_ips}    1
-    Log    ${dest_dhcp}
-    Run Keyword If    ${rcode}    Check Ping    ${dest_dhcp}
-    ${dest_vm}=    Get From List    ${list_of_local_dst_ips}    2
-    Log    ${dest_vm}
-    Run Keyword If    ${rcode}    Check Ping    ${dest_vm}
+    : FOR    ${dest_ip}    IN    @{list_of_local_dst_ips}
+    \    Log    ${dest_ip}
+    \    Run Keyword If    ${rcode}    Check Ping    ${dest_ip}
     Run Keyword If    ${rcode}    Check Metadata Access
     Run Keyword If    '${l2_or_l3}' == 'l3'    Ping Other Instances    ${list_of_external_dst_ips}
     [Teardown]    Exit From Vm Console
@@ -312,15 +321,9 @@ Ping Other Instances
     [Arguments]    ${list_of_external_dst_ips}
     [Documentation]    Check reachability with other network's instances.
     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
-    ${dest_vm}=    Get From List    ${list_of_external_dst_ips}    0
-    Log    ${dest_vm}
-    Run Keyword If    ${rcode}    Check Ping    ${dest_vm}
-    ${dest_dhcp}=    Get From List    ${list_of_external_dst_ips}    1
-    Log    ${dest_dhcp}
-    Run Keyword If    ${rcode}    Check Ping    ${dest_dhcp}
-    ${dest_vm}=    Get From List    ${list_of_external_dst_ips}    2
-    Log    ${dest_vm}
-    Run Keyword If    ${rcode}    Check Ping    ${dest_vm}
+    : FOR    ${dest_ip}    IN    @{list_of_external_dst_ips}
+    \    Log    ${dest_ip}
+    \    Run Keyword If    ${rcode}    Check Ping    ${dest_ip}
 
 Create Router
     [Arguments]    ${router_name}
@@ -348,6 +351,24 @@ Remove Interface
     Close Connection
     Should Contain    ${output}    Removed interface from router
 
+Update Router
+    [Arguments]    ${router_name}    ${cmd}
+    [Documentation]    Update the router with the command. Router name and command should be passed as argument.
+    ${devstack_conn_id} =    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output} =    Write Commands Until Prompt    neutron router-update ${router_name} ${cmd}    30s
+    Close Connection
+    Should Contain    ${output}    Updated
+
+Show Router
+    [Arguments]    ${router_name}    ${options}
+    [Documentation]    Show information of a given router. Router name and optional fields should be sent as arguments.
+    ${devstack_conn_id} =    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output} =    Write Commands Until Prompt    neutron router-show ${router_name} ${options}    30s
+    Log    ${output}
+    Close Connection
+
 Delete Router
     [Arguments]    ${router_name}
     [Documentation]    Delete Router and Interface to the subnets.
index 608c15f562abd347c07470bb48ad6d5ea1851ff5..a449dea564aac07714334f205c68f8e8d3492286 100644 (file)
@@ -2,10 +2,11 @@
 Documentation     Test suite to validate vpnservice functionality in an openstack integrated environment.
 ...               The assumption of this suite is that the environment is already configured with the proper
 ...               integration bridges and vxlan tunnels.
-Suite Setup       Basic Vpnservice Suite Setup
-Suite Teardown    Basic Vpnservice Suite Teardown
+Suite Setup       BuiltIn.Run Keywords    SetupUtils.Setup_Utils_For_Setup_And_Teardown
+...               AND    DevstackUtils.Devstack Suite Setup Tests
+Suite Teardown    Close All Connections
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
-Library           SSHLibrary
+Test Teardown     Get OvsDebugInfo
 Library           OperatingSystem
 Library           RequestsLibrary
 Resource          ../../../libraries/Utils.robot
@@ -22,6 +23,8 @@ Variables         ../../../variables/Variables.py
 @{SUBNET_CIDR}    10.1.1.0/24    20.1.1.0/24
 @{PORT_LIST}      PORT11    PORT21    PORT12    PORT22
 @{VM_INSTANCES}    VM11    VM21    VM12    VM22
+@{NET10_VM_IPS}    10.1.1.3    10.1.1.4
+@{NET20_VM_IPS}    20.1.1.3    20.1.1.4
 @{ROUTERS}        ROUTER_1    ROUTER_2
 # Values passed by the calling method to API
 @{CREATE_ID}      "4ae8cd92-48ca-49b5-94e1-b2921a261111"    "4ae8cd92-48ca-49b5-94e1-b2921a261112"    "4ae8cd92-48ca-49b5-94e1-b2921a261113"
@@ -32,26 +35,14 @@ ${CREATE_IMPORT_RT}    ["3300:2","8800:2"]
 ${CREATE_TENANT_ID}    "6c53df3a-3456-11e5-a151-feff819c1111"
 @{VPN_INSTANCE}    vpn_instance_template.json
 @{VPN_INSTANCE_NAME}    4ae8cd92-48ca-49b5-94e1-b2921a2661c7    4ae8cd92-48ca-49b5-94e1-b2921a261111
+@{EXTRA_NW_IP}    40.1.1.2    50.1.1.2
+# Values passed for extra routes
+${EXT_RT1}        destination=40.1.1.0/24,nexthop=10.1.1.3
+${EXT_RT2}        destination=50.1.1.0/24,nexthop=10.1.1.3
+${RT_OPTIONS}     --routes type=dict list=true
+${RT_CLEAR}       --routes action=clear
 
 *** Test Cases ***
-Create ITM Tunnel
-    [Documentation]    Checks that vxlan tunnels are created successfully. The proc expects that the two DPNs are in the same network and populates the gateway accordingly.
-    ${node_1_dpid} =    Get DPID    ${OS_COMPUTE_1_IP}
-    ${node_2_dpid} =    Get DPID    ${OS_COMPUTE_2_IP}
-    ${node_1_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
-    ${node_2_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
-    ${first_two_octets}    ${third_octet}    ${last_octet}=    Split String From Right    ${OS_COMPUTE_1_IP}    .    2
-    ${subnet} =    Set Variable    ${first_two_octets}.0.0/16
-    ${gateway} =    Get Default Gateway    ${OS_COMPUTE_1_IP}
-    ITM Create Tunnel    tunnel-type=vxlan    vlan-id=0    ip-address1="${OS_COMPUTE_1_IP}"    dpn-id1=${node_1_dpid}    portname1="${node_1_adapter}"    ip-address2="${OS_COMPUTE_2_IP}"
-    ...    dpn-id2=${node_2_dpid}    portname2="${node_2_adapter}"    prefix="${subnet}"    gateway-ip="${gateway}"
-    ${output}=    Run Command On Remote System    ${OS_COMPUTE_1_IP}    sudo ovs-vsctl show
-    Log    ${output}
-    ${output}=    Run Command On Remote System    ${OS_COMPUTE_2_IP}    sudo ovs-vsctl show
-    Log    ${output}
-    ${output} =    ITM Get Tunnels
-    Log    ${output}
-
 Create Neutron Networks
     [Documentation]    Create two networks
     Create Network    ${NETWORKS[0]}
@@ -89,11 +80,15 @@ Create Nova VMs
     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES[1]}    ${OS_COMPUTE_2_IP}
     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES[2]}    ${OS_COMPUTE_1_IP}
     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES[3]}    ${OS_COMPUTE_2_IP}
+    Log    Check for routes
+    Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate
 
 Check ELAN Datapath Traffic Within The Networks
     [Documentation]    Checks datapath within the same network with different vlans.
-    [Tags]    exclude
-    Log    This test will be added in the next patch
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    @{NET10_VM_IPS}[0]    ping -c 3 @{NET10_VM_IPS}[1]
+    Should Contain    ${output}    64 bytes
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    @{NET20_VM_IPS}[0]    ping -c 3 @{NET20_VM_IPS}[1]
+    Should Contain    ${output}    64 bytes
 
 Create Routers
     [Documentation]    Create Router
@@ -105,9 +100,39 @@ Add Interfaces To Router
     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
 
 Check L3_Datapath Traffic Across Networks With Router
-    [Documentation]    Datapath Test Across the networks using Router for L3.
-    [Tags]    exclude
-    Log    This test will be added in the next patch
+    [Documentation]    Datapath test across the networks using router for L3.
+    ${dst_ip_list} =    Create List    @{NET10_VM_IPS}[1]
+    Log    ${dst_ip_list}
+    ${other_dst_ip_list} =    Create List    @{NET20_VM_IPS}[0]    @{NET20_VM_IPS}[1]
+    Log    ${other_dst_ip_list}
+    Test Operations From Vm Instance    ${NETWORKS[0]}    @{NET10_VM_IPS}[0]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+    ${dst_ip_list} =    Create List    @{NET20_VM_IPS}[1]
+    Log    ${dst_ip_list}
+    ${other_dst_ip_list} =    Create List    @{NET10_VM_IPS}[0]    @{NET10_VM_IPS}[1]
+    Log    ${other_dst_ip_list}
+    Test Operations From Vm Instance    ${NETWORKS[1]}    @{NET20_VM_IPS}[0]    ${dst_ip_list}    l2_or_l3=l3    list_of_external_dst_ips=${other_dst_ip_list}
+
+Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
+    [Documentation]    Add multiple extra routes and check data path before L3VPN creation
+    Log    "Adding extra one route to VM"
+    ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ifconfig eth0:1 @{EXTRA_NW_IP}[0] netmask 255.255.255.0 up
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    @{NET10_VM_IPS}[0]    ${CONFIG_EXTRA_ROUTE_IP1}
+    ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ifconfig eth0:2 @{EXTRA_NW_IP}[1] netmask 255.255.255.0 up
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    @{NET10_VM_IPS}[0]    ${CONFIG_EXTRA_ROUTE_IP2}
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    @{NET10_VM_IPS}[0]    ifconfig
+    ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${EXT_RT2}
+    Update Router    @{ROUTERS}[0]    ${cmd}
+    Show Router    @{ROUTERS}[0]    -D
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    @{NET10_VM_IPS}[1]    ping -c 3 @{EXTRA_NW_IP}[1]
+    Should Contain    ${output}    64 bytes
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    @{NET20_VM_IPS}[1]    ping -c 3 @{EXTRA_NW_IP}[1]
+    Should Contain    ${output}    64 bytes
+    ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    @{NET10_VM_IPS}[1]    ping -c 3 @{EXTRA_NW_IP}[0]
+    Should Contain    ${output}    64 bytes
+
+Delete Extra Route
+    [Documentation]    Delete the extra routes
+    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
 
 Delete Router Interfaces
     [Documentation]    Remove Interface to the subnets.
@@ -197,15 +222,39 @@ Delete Networks
     : FOR    ${Network}    IN    @{NETWORKS}
     \    Delete Network    ${Network}
 
+Create ITM Tunnel
+    [Documentation]    Checks that vxlan tunnels are created successfully. The proc expects that the two DPNs are in the same network and populates the gateway accordingly.
+    ${node_1_dpid} =    Get DPID    ${OS_COMPUTE_1_IP}
+    ${node_2_dpid} =    Get DPID    ${OS_COMPUTE_2_IP}
+    ${node_1_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_1_IP}
+    ${node_2_adapter} =    Get Ethernet Adapter    ${OS_COMPUTE_2_IP}
+    ${first_two_octets}    ${third_octet}    ${last_octet}=    Split String From Right    ${OS_COMPUTE_1_IP}    .    2
+    ${subnet} =    Set Variable    ${first_two_octets}.0.0/16
+    ${gateway} =    Get Default Gateway    ${OS_COMPUTE_1_IP}
+    ITM Create Tunnel    tunnel-type=vxlan    vlan-id=0    ip-address1="${OS_COMPUTE_1_IP}"    dpn-id1=${node_1_dpid}    portname1="${node_1_adapter}"    ip-address2="${OS_COMPUTE_2_IP}"
+    ...    dpn-id2=${node_2_dpid}    portname2="${node_2_adapter}"    prefix="${subnet}"    gateway-ip="${gateway}"
+    Get DumpFlows And Ovsconfig    ${OS_COMPUTE_1_IP}
+    Get DumpFlows And Ovsconfig    ${OS_COMPUTE_2_IP}
+    ${output} =    ITM Get Tunnels
+    Log    ${output}
+
 Delete ITM Tunnel
     [Documentation]    Delete tunnels with specific transport-zone.
     ITM Delete Tunnel    TZA
 
 *** Keywords ***
 Basic Vpnservice Suite Setup
-    [Documentation]    Initialize SetupUtils, create session
-    SetupUtils.Setup_Utils_For_Setup_And_Teardown
     Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
 
 Basic Vpnservice Suite Teardown
     Delete All Sessions
+
+Wait For Routes To Propogate
+    ${devstack_conn_id} =    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
+    ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ip route    ]>
+    Should Contain    ${output}    @{SUBNET_CIDR}[0]
+    ${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]