Openstack Verify Connectivity from instances 55/37255/10
authorpriya.ramasubbu <priya.ramasubbu@hcl.com>
Thu, 7 Apr 2016 17:44:48 +0000 (23:14 +0530)
committerJamo Luhrsen <jluhrsen@redhat.com>
Tue, 19 Apr 2016 23:41:57 +0000 (23:41 +0000)
    * Ping from dhcp NS to instance
    * Ping from instance to instance
    * Ping from instance to dhcp server
    * Ping from instance to metadata server

Change-Id: Ia725a1f9d1159df9db50f791e5c7b9ae1276f93a
Signed-off-by: priya.ramasubbu <priya.ramasubbu@hcl.com>
csit/libraries/OpenStackOperations.robot
csit/libraries/Utils.robot
csit/suites/ovsdb/Devstack_Tempest_Tests/01__single_node_devstack_tempest_tests.robot
csit/suites/ovsdb/Devstack_Tempest_Tests/02__additional_flows_verification_tests.robot [new file with mode: 0644]

index d604015f9580ba6d7e268478aaaae3058a829fcd..9d5a809b8b78e81fdc775e09277d6b8cf812bd17 100644 (file)
@@ -1,5 +1,5 @@
 *** Settings ***
-Documentation     Netvirt library. This library is useful for tests to create network, subnet, router and vm instances
+Documentation     Openstack library. This library is useful for tests to create network, subnet, router and vm instances
 Library           SSHLibrary
 Resource          Utils.robot
 Variables         ../variables/Variables.py
@@ -24,10 +24,8 @@ Delete Network
     Should Contain    ${output}    Deleted network: ${network_name}
 
 Create SubNet
-    [Arguments]    ${network_name}
+    [Arguments]    ${network_name}    ${subnet}    ${range_ip}
     [Documentation]    Create SubNet for the Network with neutron request.
-    ${subnet}=    Set Variable If    "${network_name}"=="net1_network"    subnet1    subnet2
-    ${range_ip}=    Set Variable If    "${network_name}"=="net1_network"    10.0.0.0/24    20.0.0.0/24
     ${output}=    Write Commands Until Prompt    neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet}
     Log    ${output}
     Should Contain    ${output}    Created a new subnet
@@ -54,9 +52,9 @@ Verify No Dhcp Ips
     \    Should Not Contain    ${output}    ${DhcpIpElement}
 
 Delete SubNet
-    [Arguments]    ${network_name}
+    [Arguments]    ${subnet}
     [Documentation]    Delete SubNet for the Network with neutron request.
-    ${subnet}=    Set Variable If    "${network_name}"=="net1_network"    subnet1    subnet2
+    Log    ${subnet}
     ${output}=    Write Commands Until Prompt    neutron -v subnet-delete ${subnet}
     Log    ${output}
     Should Contain    ${output}    Deleted subnet: ${subnet}
@@ -91,6 +89,61 @@ Get Net Id
     Log    ${net_id}
     [Return]    ${net_id}
 
+Create Vm Instances
+    [Arguments]    ${net_id}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.tiny
+    [Documentation]    Create Four Vm Instance with the net id of the Netowrk.
+    : FOR    ${VmElement}    IN    @{vm_instance_names}
+    \    ${output}=    Write Commands Until Prompt     nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement}
+    \    Log    ${output}
+
+View Vm Console
+    [Arguments]    ${vm_instance_names}
+    [Documentation]    View Console log of the created vm instances using nova show.
+    : FOR    ${VmElement}    IN    @{vm_instance_names}
+    \    ${output}=   Write Commands Until Prompt     nova show ${VmElement}
+    \    Log    ${output}
+    \    ${output}=   Write Commands Until Prompt     nova console-log ${VmElement}
+    \    Log    ${output}
+
+Ping Vm From DHCP Namespace
+    [Arguments]    ${net_id}    ${vm_ip}
+    [Documentation]    Reach all Vm Instance with the net id of the Netowrk.
+    Log    ${vm_ip}
+    ${output}=    Write Commands Until Prompt     sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
+    Log    ${output}
+    [Return]    ${output}
+
+Ping From Instance
+    [Arguments]    ${dest_vm}
+    [Documentation]    Ping to the expected destination ip.
+    ${output}=   Write Commands Until Expected Prompt    ping -c 3 ${dest_vm}    $
+    Log    ${output}
+    [Return]    ${output}
+
+Curl Metadata Server
+    [Documentation]    Ping to the expected destination ip.
+    ${output}=   Write Commands Until Expected Prompt    curl http://169.254.169.254    $
+    Log    ${output}
+
+Close Vm Instance
+    [Documentation]    Exit the vm instance.
+    ${output}=   Write Commands Until Prompt    exit
+    Log    ${output}
+
+Ssh Vm Instance
+    [Arguments]    ${net_id}    ${vm_ip}    ${user}=cirros    ${password}=cubswin:)
+    [Documentation]    Login to the vm instance using ssh in the network.
+    ${output}=   Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh -i test.pem ${user}@${vm_ip}    (yes/no)?
+    Log    ${output}
+    ${output}=   Write Commands Until Expected Prompt    yes    d:
+    Log    ${output}
+    ${output}=   Write Commands Until Expected Prompt    ${password}    $
+    Log    ${output}
+    ${output}=   Write Commands Until Expected Prompt    ifconfig    $
+    Log    ${output}
+    ${output}=   Write Commands Until Expected Prompt    route    $
+    Log    ${output}
+
 Create Router
     [Documentation]    Create Router and Add Interface to the subnets.
     ${output}=    Write Commands Until Prompt    neutron -v router-create router_1
index c48a39605d2dff1bd429dea872dd80d37077c6fe..7afb4781cd18392cc2b65626435b082ad6cae01e 100644 (file)
@@ -480,3 +480,11 @@ Convert_To_Minutes
     ${seconds}=    DateTime.Convert_Time    ${time}    result_format=number
     ${minutes}=    BuiltIn.Evaluate    int(math.ceil(${seconds}/60.0))    modules=math
     [Return]    ${minutes}
+
+Write Commands Until Expected Prompt
+    [Arguments]    ${cmd}    ${prompt}    ${timeout}=${DEFAULT_TIMEOUT}
+    [Documentation]    quick wrapper for Write and Read Until Prompt Keywords to make test cases more readable
+    SSHLibrary.Set Client Configuration    timeout=${timeout}
+    SSHLibrary.Write    ${cmd}
+    ${output}=    SSHLibrary.Read Until    ${prompt}
+    [Return]    ${output}
index 4cc9dd23fbb0944b353fe1e1950fcf9bdf3cde78..a90a3a51821a0d63ecd1447eab47e1ed82533fa9 100644 (file)
@@ -42,10 +42,13 @@ Create Networks
     : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
     \    Create Network    ${NetworkElement}
 
-Create Subnets
+Create Subnets For net1_network
     [Documentation]    Create Sub Nets for the Networks with neutron request.
-    : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
-    \    Create SubNet    ${NetworkElement}
+    Create SubNet    net1_network    subnet1    10.0.0.0/24
+
+Create Subnets For net2_network
+    [Documentation]    Create Sub Nets for the Networks with neutron request.
+    Create SubNet    net2_network    subnet2    20.0.0.0/24
 
 List Ports
     ${output}=    Write Commands Until Prompt    neutron -v port-list
@@ -128,10 +131,13 @@ Verify Deleted Routers
     [Documentation]    Verify Deleted Routers for the Networks with dump flow.
     Verify No Gateway Ips
 
-Delete Sub Networks
+Delete Sub Networks In net1_network
     [Documentation]    Delete Sub Nets for the Networks with neutron request.
-    : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
-    \    Delete SubNet    ${NetworkElement}
+    Delete SubNet    subnet1
+
+Delete Sub Networks In net2_network
+    [Documentation]    Delete Sub Nets for the Networks with neutron request.
+    Delete SubNet    subnet2
 
 Delete Networks
     [Documentation]    Delete Networks with neutron request.
diff --git a/csit/suites/ovsdb/Devstack_Tempest_Tests/02__additional_flows_verification_tests.robot b/csit/suites/ovsdb/Devstack_Tempest_Tests/02__additional_flows_verification_tests.robot
new file mode 100644 (file)
index 0000000..5ec2346
--- /dev/null
@@ -0,0 +1,174 @@
+*** Settings ***
+Documentation     Test suite to verify packet flows between vm instances.
+Suite Setup       Devstack Suite Setup
+Library           SSHLibrary
+Library           OperatingSystem
+Library           RequestsLibrary
+Resource          ../../../libraries/Utils.robot
+Resource          ../../../libraries/OpenStackOperations.robot
+Resource          ../../../libraries/DevstackUtils.robot
+
+*** Variables ***
+@{NETWORKS_NAME}    network_1    network_2
+@{SUBNETS_NAME}    subnet_1    subnet_2
+@{NET_1_VM_INSTANCES}    MyFirstInstance_1    MySecondInstance_1
+@{NET_2_VM_INSTANCES}    MyFirstInstance_2    MySecondInstance_2
+@{NET_1_VM_IPS}    30.0.0.3    30.0.0.4
+@{NET_2_VM_IPS}    40.0.0.3    40.0.0.4
+@{VM_IPS_NOT_DELETED}    30.0.0.4
+@{GATEWAY_IPS}    30.0.0.1    40.0.0.1
+@{DHCP_IPS}    30.0.0.2    40.0.0.2
+
+*** Test Cases ***
+Create Networks
+    [Documentation]    Create Network with neutron request.
+    : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
+    \    Create Network    ${NetworkElement}
+
+Create Subnets For network_1
+    [Documentation]    Create Sub Nets for the Networks with neutron request.
+    Create SubNet    network_1    subnet_1    30.0.0.0/24
+
+Create Subnets For network_2
+    [Documentation]    Create Sub Nets for the Networks with neutron request.
+    Create SubNet    network_2    subnet_2    40.0.0.0/24
+
+Create Vm Instances For network_1
+    [Documentation]    Create Four Vm instances using flavor and image names for a network.
+    ${net_id}=    Get Net Id    network_1
+    Create Vm Instances    ${net_id}    ${NET_1_VM_INSTANCES}
+    View Vm Console    ${NET_1_VM_INSTANCES}
+
+Create Vm Instances For network_2
+    [Documentation]    Create Four Vm instances using flavor and image names for a network.
+    ${net_id}=    Get Net Id    network_2
+    Set Suite Variable    ${net_id}
+    Create Vm Instances    ${net_id}    ${NET_2_VM_INSTANCES}
+    View Vm Console    ${NET_2_VM_INSTANCES}
+
+List Networks With Namespaces
+    ${output}=   Write Commands Until Prompt     sudo ip netns list
+    Log    ${output}
+
+Show Details of Created Vm Instance In network_1
+    [Documentation]    View Details of the created vm instances using nova show.
+    : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
+    \    ${output}=   Write Commands Until Prompt     nova show ${VmElement}
+    \    Log    ${output}
+
+Ping All Vm Instances In network_1
+    [Documentation]    Check reachability of vm instances by pinging to them.
+    ${net_id}=    Get Net Id    network_1
+    : FOR    ${VmIpElement}    IN    @{NET_1_VM_IPS}
+    \    ${output}    Ping Vm From DHCP Namespace    ${net_id}    ${VmIpElement}
+    \    Should Contain    ${output}    64 bytes
+
+Show Details of Created Vm Instance In network_2
+    [Documentation]    View Details of the created vm instances using nova show.
+    : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
+    \    ${output}=   Write Commands Until Prompt     nova show ${VmElement}
+    \    Log    ${output}
+
+Ping All Vm Instances In network_2
+    [Documentation]    Check reachability of vm instances by pinging to them.
+    ${net_id}=    Get Net Id    network_2
+    : FOR    ${VmIpElement}    IN    @{NET_2_VM_IPS}
+    \    ${output}    Ping Vm From DHCP Namespace    ${net_id}    ${VmIpElement}
+    \    Should Contain    ${output}    64 bytes
+
+Add Key-Pair For Vm Instance
+    [Documentation]    Creates key pair to ssh to the vm instance.
+    ${output}=   Write Commands Until Prompt    nova keypair-add test > test.pem
+    Log    ${output}
+    ${output}=   Write Commands Until Prompt    chmod 600 test.pem
+    Log    ${output}
+
+List The Availalbe Key Pair List
+    [Documentation]    Check the existing key pairs available.
+    ${output}=   Write Commands Until Prompt    nova keypair-list
+    Log    ${output}
+
+Login to Vm Instances In network_1 Using Ssh
+    [Documentation]    Logging to the vm instance using generated key pair.
+    ${net_id}=    Get Net Id    network_1
+    Ssh Vm Instance    ${net_id}    30.0.0.3
+
+Ping Vm Instance From Instance In network_1
+    [Documentation]    Check reachability of vm instances by pinging.
+    ${output}=    Ping From Instance    30.0.0.4
+    Should Contain    ${output}    64 bytes
+
+Ping Dhcp Server From Instance In network_1
+    [Documentation]    ping the dhcp server from instance.
+    ${output}=    Ping From Instance    30.0.0.2
+    Should Contain    ${output}    64 bytes
+
+Ping Metadata Server From Instance In network_1
+    [Documentation]    ping the metadata server from instance.
+    Curl Metadata Server
+
+Close Vm Instance In network_1
+    [Documentation]    Close the connection with Vm Instance in a network.
+    Close Vm Instance
+
+Login to Vm Instances In network_2 Using Ssh
+    [Documentation]    Logging to the vm instance using generated key pair.
+    ${net_id}=    Get Net Id    network_2
+    Ssh Vm Instance    ${net_id}    40.0.0.3
+
+Ping Vm Instance From Instance In network_2
+    [Documentation]    Check reachability of vm instances by pinging.
+    ${output}=    Ping From Instance    40.0.0.4
+    Should Contain    ${output}    64 bytes
+
+Ping Dhcp Server From Instance In network_2
+    [Documentation]    ping the dhcp server from instance.
+    ${output}=    Ping From Instance    40.0.0.2
+    Should Contain    ${output}    64 bytes
+
+Ping Metadata Server From Instance In network_2
+    [Documentation]    ping the metadata server from instance.
+    Curl Metadata Server
+
+Close Vm Instance In network_2
+    [Documentation]    Close the connection with Vm Instance in a network.
+    Close Vm Instance
+
+Delete Vm Instance
+    [Documentation]    Delete Vm instances using instance names.
+    Delete Vm Instance    MyFirstInstance_1
+
+Ping All Vm Instances
+    [Documentation]    Check reachability of vm instances by pinging to them.
+    ${net_id}=    Get Net Id    network_1
+    : FOR    ${VmIpElement}    IN    @{VM_IPS_NOT_DELETED}
+    \    ${output}=    Ping Vm From DHCP Namespace    ${net_id}    ${VmIpElement}
+    \    Should Contain    ${output}    64 bytes
+
+No Ping For Deleted Vm
+    [Documentation]    Check non reachability of deleted vm instances by pinging to them.
+    ${output}=    Ping Vm From DHCP Namespace    ${net_id}    30.0.0.3
+    Should Contain    ${output}    Destination Host Unreachable
+
+Delete Vm Instances In network_1
+    [Documentation]    Delete Vm instances using instance names in network_1.
+    : FOR    ${VmElement}    IN    @{NET_1_VM_INSTANCES}
+    \    Delete Vm Instance    ${VmElement}
+
+Delete Vm Instances In network_2
+    [Documentation]    Delete Vm instances using instance names in network_2.
+    : FOR    ${VmElement}    IN    @{NET_2_VM_INSTANCES}
+    \    Delete Vm Instance    ${VmElement}
+
+Delete Sub Networks In network_1
+    [Documentation]    Delete Sub Nets for the Networks with neutron request.
+    Delete SubNet    subnet_1
+
+Delete Sub Networks In network_2
+    [Documentation]    Delete Sub Nets for the Networks with neutron request.
+    Delete SubNet    subnet_2
+
+Delete Networks
+    [Documentation]    Delete Networks with neutron request.
+    : FOR    ${NetworkElement}    IN    @{NETWORKS_NAME}
+    \    Delete Network    ${NetworkElement}