Add SNAT test to netvirt CSIT 17/49217/32
authorAlon Kochba <alonko@hpe.com>
Sun, 11 Dec 2016 12:07:35 +0000 (14:07 +0200)
committerJamo Luhrsen <jluhrsen@redhat.com>
Wed, 18 Jan 2017 22:48:40 +0000 (22:48 +0000)
Change-Id: I8caba0858a9cf85c0cda8e22cf22ea8c998ca500
Signed-off-by: Alon Kochba <alonko@hpe.com>
Signed-off-by: Koby Aizer <koby.aizer@hpe.com>
csit/libraries/OpenStackOperations.robot
csit/suites/openstack/connectivity/03_external_network_tests.robot

index fa71cffc052d5447b426891546a2511b6d905663..9c15799e36b88cc7d127cf8b59fe742bcccb98c0 100644 (file)
@@ -348,7 +348,6 @@ Exit From Vm Console
     [Documentation]    Check if the session has been able to login to the VM instance and exit the instance
     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance    cirros
     Run Keyword If    ${rcode}    Write Commands Until Prompt    exit
-    Get OvsDebugInfo
 
 Check Ping
     [Arguments]    ${ip_address}
@@ -400,6 +399,35 @@ Test Operations From Vm Instance
     Run Keyword If    ${rcode}    Check Metadata Access
     [Teardown]    Exit From Vm Console
 
+Install Netcat On Controller
+    [Documentation]    Installs Netcat on the controller - this probably shouldn't be here
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    ${output}=    Write Commands Until Prompt    sudo yum install -y nc
+    Log    ${output}
+    Close Connection
+
+Test Netcat Operations From Vm Instance
+    [Arguments]    ${net_name}    ${vm_ip}    ${dest_ip}    ${additional_args}=${EMPTY}    ${port}=12345    ${user}=cirros
+    ...    ${password}=cubswin:)
+    [Documentation]    Use Netcat to test TCP/UDP connections to the controller
+    ${client_data}    Set Variable    Test Client Data
+    ${server_data}    Set Variable    Test Server Data
+    ${devstack_conn_id}=    Get ControlNode Connection
+    Switch Connection    ${devstack_conn_id}
+    Log    ${vm_ip}
+    ${output}=    Write Commands Until Prompt    ( ( echo "${server_data}" | sudo timeout 60 nc -w 1 -l ${additional_args} ${port} ) & )
+    Log    ${output}
+    ${output}=    Write Commands Until Prompt    sudo netstat -nlap | grep ${port}
+    Log    ${output}
+    ${nc_output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo echo "${client_data}" | nc -v -w 1 ${additional_args} ${dest_ip} ${port}
+    Log    ${nc_output}
+    ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo route -n
+    Log    ${output}
+    ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo arp -an
+    Log    ${output}
+    Should Match Regexp    ${nc_output}    ${server_data}
+
 Ping Other Instances
     [Arguments]    ${list_of_external_dst_ips}
     [Documentation]    Check reachability with other network's instances.
index d4194122450b8dc038774262cfea080c0a122e8b..a43876c25ddaab7f6b107389519f6be20d43570f 100644 (file)
@@ -13,7 +13,8 @@ Resource          ../../../libraries/Utils.robot
 *** Variables ***
 @{NETWORKS_NAME}    l3_net
 @{SUBNETS_NAME}    l3_subnet
-@{VM_INSTANCES}    VmInstance1_net    VmInstance2_net
+@{VM_INSTANCES_FLOATING}    VmInstanceFloating1    VmInstanceFloating2
+@{VM_INSTANCES_SNAT}    VmInstanceSnat3    VmInstanceSnat4
 @{SUBNETS_RANGE}    90.0.0.0/24
 ${external_gateway}    10.10.10.250
 ${external_subnet}    10.10.10.0/24
@@ -35,6 +36,37 @@ Create Subnet For Private Network
     [Documentation]    Create Sub Nets for the Networks with neutron request.
     OpenStackOperations.Create SubNet    @{NETWORKS_NAME}[0]    @{SUBNETS_NAME}[0]    @{SUBNETS_RANGE}[0]
 
+Create Vm Instances
+    [Documentation]    Create VM instances using flavor and image names for a network.
+    OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_FLOATING}    sg=csit
+    OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES_SNAT}    sg=csit
+
+Check Vm Instances Have Ip Address
+    [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
+    ...    We are polling first and longest on the last VM created assuming that if it's received it's address
+    ...    already the other instances should have theirs already or at least shortly thereafter.
+    # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
+    # for dhcp addresses
+    : FOR    ${vm}    IN    @{VM_INSTANCES_FLOATING}    @{VM_INSTANCES_SNAT}
+    \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
+    ${FLOATING_VM_COUNT}    Get Length    ${VM_INSTANCES_FLOATING}
+    ${SNAT_VM_COUNT}    Get Length    ${VM_INSTANCES_SNAT}
+    ${LOOP_COUNT}    Evaluate    ${FLOATING_VM_COUNT}+${SNAT_VM_COUNT}
+    : FOR    ${index}    IN RANGE    1    ${LOOP_COUNT}
+    \    ${FLOATING_VM_IPS}    ${FLOATING_DHCP_IP}    Wait Until Keyword Succeeds    180s    10s    Verify VMs Received DHCP Lease
+    \    ...    @{VM_INSTANCES_FLOATING}
+    \    ${SNAT_VM_IPS}    ${SNAT_DHCP_IP}    Wait Until Keyword Succeeds    180s    10s    Verify VMs Received DHCP Lease
+    \    ...    @{VM_INSTANCES_SNAT}
+    \    ${FLOATING_VM_LIST_LENGTH}=    Get Length    ${FLOATING_VM_IPS}
+    \    ${SNAT_VM_LIST_LENGTH}=    Get Length    ${SNAT_VM_IPS}
+    \    Exit For Loop If    ${FLOATING_VM_LIST_LENGTH}==${FLOATING_VM_COUNT} and ${SNAT_VM_LIST_LENGTH}==${SNAT_VM_COUNT}
+    Append To List    ${FLOATING_VM_IPS}    ${FLOATING_DHCP_IP}
+    Set Suite Variable    ${FLOATING_VM_IPS}
+    Append To List    ${SNAT_VM_IPS}    ${SNAT_DHCP_IP}
+    Set Suite Variable    ${SNAT_VM_IPS}
+    [Teardown]    Run Keywords    Show Debugs    ${VM_INSTANCES_FLOATING}    ${VM_INSTANCES_SNAT}
+    ...    AND    Get Test Teardown Debugs
+
 Create External Network And Subnet
     Create Network    ${external_net_name} --router:external --provider:network_type=flat --provider:physical_network=${external_physical_network}
     Create Subnet    ${external_net_name}    ${external_subnet_name}    ${external_subnet}    --gateway ${external_gateway}
@@ -58,27 +90,11 @@ Verify Created Routers
     Log    ${data}
     Should Contain    ${data}    router1
 
-Create Vm Instances
-    [Documentation]    Create VM instances using flavor and image names for a network.
-    OpenStackOperations.Create Vm Instances    @{NETWORKS_NAME}[0]    ${VM_INSTANCES}    sg=csit
-
-Check Vm Instances Have Ip Address
-    [Documentation]    Test case to verify that all created VMs are ready and have received their ip addresses.
-    ...    We are polling first and longest on the last VM created assuming that if it's received it's address
-    ...    already the other instances should have theirs already or at least shortly thereafter.
-    # first, ensure all VMs are in ACTIVE state.    if not, we can just fail the test case and not waste time polling
-    # for dhcp addresses
-    : FOR    ${vm}    IN    @{VM_INSTANCES}
-    \    Wait Until Keyword Succeeds    15s    5s    Verify VM Is ACTIVE    ${vm}
-    Wait Until Keyword Succeeds    180s    10s    Verify VMs Received DHCP Lease    @{VM_INSTANCES}
-    [Teardown]    Run Keywords    Show Debugs    ${VM_INSTANCES}
-    ...    AND    Get Test Teardown Debugs
-
 Create And Associate Floating IPs for VMs
     [Documentation]    Create and associate a floating IP for the VM
-    ${VM_FLOATING_IPS}    OpenStackOperations.Create And Associate Floating IPs    ${external_net_name}    @{VM_INSTANCES}
+    ${VM_FLOATING_IPS}    OpenStackOperations.Create And Associate Floating IPs    ${external_net_name}    @{VM_INSTANCES_FLOATING}
     Set Suite Variable    ${VM_FLOATING_IPS}
-    [Teardown]    Run Keywords    Show Debugs    ${VM_INSTANCES}
+    [Teardown]    Run Keywords    Show Debugs    ${VM_INSTANCES_FLOATING}
     ...    AND    Get Test Teardown Debugs
 
 Ping External Gateway From Control Node
@@ -93,9 +109,30 @@ Ping Vm Instance2 Floating IP From Control Node
     [Documentation]    Check reachability of VM instance through floating IP by pinging them.
     OpenStackOperations.Ping Vm From Control Node    @{VM_FLOATING_IPS}[1]
 
+Prepare SNAT - Install Netcat On Controller
+    Install Netcat On Controller
+
+SNAT - TCP connection to External Gateway From SNAT VM Instance1
+    [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
+    Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}
+
+SNAT - UDP connection to External Gateway From SNAT VM Instance1
+    [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
+    Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[0]    ${external_gateway}    -u
+
+SNAT - TCP connection to External Gateway From SNAT VM Instance2
+    [Documentation]    Login to the VM instance and test TCP connection to the controller via SNAT
+    Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}
+
+SNAT - UDP connection to External Gateway From SNAT VM Instance2
+    [Documentation]    Login to the VM instance and test UDP connection to the controller via SNAT
+    Test Netcat Operations From Vm Instance    @{NETWORKS_NAME}[0]    @{SNAT_VM_IPS}[1]    ${external_gateway}    -u
+
 Delete Vm Instances
     [Documentation]    Delete Vm instances using instance names.
-    : FOR    ${VmElement}    IN    @{VM_INSTANCES}
+    : FOR    ${VmElement}    IN    @{VM_INSTANCES_FLOATING}
+    \    OpenStackOperations.Delete Vm Instance    ${VmElement}
+    : FOR    ${VmElement}    IN    @{VM_INSTANCES_SNAT}
     \    OpenStackOperations.Delete Vm Instance    ${VmElement}
 
 Delete Router Interfaces