Add Floating Ip testcases to SNAT suite.
[integration/test.git] / csit / suites / netvirt / snatdnat / snat_dnat.robot
index 4df20e3afc6317fa89078d07b031f76937265444..31f7ea4bb28385b5aa59f985a2b07a099ab16ea6 100644 (file)
@@ -3,13 +3,14 @@ Documentation     Test suite to validate network address translation(snat/dnat)
 ...               All the testcases were written to do flow validation since dc gateway is unavailable in csit environment.
 ...               This suite assumes proper integration bridges and vxlan tunnels are configured in the environment.
 Suite Setup       Start Suite
-Suite Teardown    OpenStackOperations.OpenStack Suite Teardown
+Suite Teardown    Stop Suite
 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
 Test Teardown     OpenStackOperations.Get Test Teardown Debugs
 Library           Collections
 Library           RequestsLibrary
 Library           SSHLibrary
 Library           String
+Resource          ../../../libraries/BgpOperations.robot
 Resource          ../../../libraries/OpenStackOperations.robot
 Resource          ../../../libraries/SetupUtils.robot
 Resource          ../../../libraries/Tcpdump.robot
@@ -24,6 +25,14 @@ ${NETWORK_TYPE}    gre
 ${SNAT_ENABLED}    "enable_snat": true
 ${SNAT_DISABLED}    "enable_snat": false
 ${ROUTER}         nat_router
+${AS_ID}          100
+${BGP_CONFIG_SERVER_CMD}    bgp-connect -h ${ODL_SYSTEM_IP} -p 7644 add
+${DCGW_SYSTEM_IP}    ${TOOLS_SYSTEM_1_IP}
+${LOOPBACK_IP}    5.5.5.2
+${DCGW_RD}        100:1
+${VPN_NAME}       vpn_1
+${VPN_INSTANCE_ID}    4ae8cd92-48ca-49b5-94e1-b2921a261442
+${FIP}            100.100.100.24
 @{NETWORKS}       nat_net_1    nat_net_2
 @{EXTERNAL_NETWORKS}    nat_ext_11    nat_ext_22
 @{EXTERNAL_SUB_NETWORKS}    nat_ext_sub_net_1    nat_ext_sub_net_2
@@ -35,6 +44,7 @@ ${ROUTER}         nat_router
 
 *** Test Cases ***
 Verify Successful Creation Of External Network With Router External Set To TRUE
+    [Documentation]    Create external network,enable snat on router and validate the same.
     OpenStackOperations.Add Router Gateway    ${ROUTER}    @{EXTERNAL_NETWORKS}[0]    --enable-snat
     ${output} =    OpenStackOperations.Show Router    ${ROUTER}
     BuiltIn.Should Contain    ${output}    ${SNAT_ENABLED}
@@ -42,6 +52,7 @@ Verify Successful Creation Of External Network With Router External Set To TRUE
     BuiltIn.Should Contain    ${output}    @{EXTERNAL_NETWORKS}[0]
 
 Verify Successful Update Of Router With External_gateway_info, Disable SNAT And Enable SNAT
+    [Documentation]    Disable snat, enable snat and validate the same.
     OpenStackOperations.Add Router Gateway    ${ROUTER}    @{EXTERNAL_NETWORKS}[0]    --disable-snat
     ${output} =    OpenStackOperations.Show Router    ${ROUTER}
     BuiltIn.Should Contain    ${output}    ${SNAT_DISABLED}
@@ -50,14 +61,52 @@ Verify Successful Update Of Router With External_gateway_info, Disable SNAT And
     BuiltIn.Should Contain    ${output}    ${SNAT_ENABLED}
 
 Verify Successful Deletion Of External Network
+    [Documentation]    Delete the external network and validate the same.
     OpenStackOperations.Remove Gateway    ${ROUTER}
     ${output} =    OpenStackOperations.Show Router    ${ROUTER}
     BuiltIn.Should Not Contain    ${output}    ${SNAT_ENABLED}
 
+Verify Floating Ip Provision And Reachability From External Network Via Neutron Router Through L3vpn
+    [Documentation]    Check floating IP should be present in dump flows after creating the floating IP and associating it to external network
+    ...    which is associated to L3VPN
+    VpnOperations.VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID}    name=${VPN_NAME}    rd=["${DCGW_RD}"]    exportrt=["${DCGW_RD}"]    importrt=["${DCGW_RD}"]
+    ${ext_net_id} =    OpenStackOperations.Get Net Id    @{EXTERNAL_NETWORKS}[0]
+    VpnOperations.Associate L3VPN To Network    networkid=${ext_net_id}    vpnid=${VPN_INSTANCE_ID}
+    OpenStackOperations.Add Router Gateway    ${ROUTER}    @{EXTERNAL_NETWORKS}[0]    --disable-snat
+    ${output} =    OpenStackOperations.Show Router    ${ROUTER}
+    BuiltIn.Should Contain    ${output}    ${SNAT_DISABLED}
+    ${subnetid} =    OpenStackOperations.Get Subnet Id    @{EXTERNAL_SUB_NETWORKS}[0]
+    OpenStackOperations.Add Router Gateway    ${ROUTER}    @{EXTERNAL_NETWORKS}[0]    --fixed-ip subnet=${subnetid},ip-address=${FIP}
+    ${float} =    OpenStackOperations.Create And Associate Floating IPs    @{EXTERNAL_NETWORKS}[0]    @{NET_1_VMS}[0]
+    ${output} =    OVSDB.Get Flow Entries On Node    ${OS_CMP1_CONN_ID}
+    BuiltIn.Should Contain    ${output}    ${FIP}
+
+Verify Floating Ip De-provision And Reachability From External Network Via Neutron Router Through L3vpn
+    [Documentation]    Check floating IP should not be present in dump flows after deleting the floating IP
+    ...    and removing the external gateway from router which is associated to L3VPN
+    OpenStackOperations.Get ControlNode Connection
+    ${output} =    OpenStackOperations.OpenStack CLI    openstack floating ip list |awk '{print$2}'
+    ${floating_id} =    BuiltIn.Should Match Regexp    ${output}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
+    OpenStackOperations.Delete Floating IP    ${floating_id}
+    OpenStackOperations.Remove Gateway    ${ROUTER}
+    ${output} =    OVSDB.Get Flow Entries On Node    ${OS_CMP1_CONN_ID}
+    BuiltIn.Should Not Contain    ${output}    ${FIP}
+
+Verify Floating Ip Re-provision And Reachability From External Network Via Neutron Router Through L3vpn
+    [Documentation]    Check floating IP should be present in dump flows after creating the floating IP again wnd associating it to external network
+    ...    which is associated to L3VPN
+    ${subnetid} =    OpenStackOperations.Get Subnet Id    @{EXTERNAL_SUB_NETWORKS}[0]
+    OpenStackOperations.Add Router Gateway    ${ROUTER}    @{EXTERNAL_NETWORKS}[0]    --fixed-ip subnet=${subnetid},ip-address=${FIP}
+    ${float} =    OpenStackOperations.Create And Associate Floating IPs    @{EXTERNAL_NETWORKS}[0]    @{NET_1_VMS}[0]
+    ${output} =    OVSDB.Get Flow Entries On Node    ${OS_CMP1_CONN_ID}
+    BuiltIn.Should Contain    ${output}    ${FIP}
+
 *** Keywords ***
 Start Suite
     [Documentation]    Test Suite for Subnet_Routing_and_Multicast_Deployments.
     VpnOperations.Basic Suite Setup
+    BgpOperations.Start Quagga Processes On ODL    ${ODL_SYSTEM_IP}
+    BgpOperations.Start Quagga Processes On DCGW    ${DCGW_SYSTEM_IP}
     Create Setup
     OpenStackOperations.Show Debugs    @{NET_1_VMS}
     OpenStackOperations.Get Suite Debugs
@@ -69,6 +118,8 @@ Create Setup
     OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
     Create Neutron Ports
     Create Nova VMs
+    BgpOperations.Setup BGP Peering On ODL    ${ODL_SYSTEM_IP}    ${AS_ID}    ${DCGW_SYSTEM_IP}
+    BgpOperations.Setup BGP Peering On DCGW    ${DCGW_SYSTEM_IP}    ${AS_ID}    ${ODL_SYSTEM_IP}    ${VPN_NAME}    ${DCGW_RD}    ${LOOPBACK_IP}
     OpenStackOperations.Create Router    ${ROUTER}
     OpenStackOperations.Add Router Interface    ${ROUTER}    @{SUBNETS}[0]
 
@@ -104,3 +155,11 @@ Create Nova VMs
     BuiltIn.Set Suite Variable    @{NET_1_VM_IPS}
     BuiltIn.Should Not Contain    ${NET_1_VM_IPS}    None
     BuiltIn.Should Not Contain    ${NET_1_DHCP_IP}    None
+
+Stop Suite
+    [Documentation]    Test teardown for snat suite.
+    BgpOperations.Delete BGP Configuration On ODL    session
+    BgpOperations.Delete BGP Config On Quagga    ${DCGW_SYSTEM_IP}    ${AS_ID}
+    BgpOperations.Stop BGP Processes On Node    ${ODL_SYSTEM_IP}
+    BgpOperations.Stop BGP Processes On Node    ${DCGW_SYSTEM_IP}
+    OpenStackOperations.OpenStack Suite Teardown