Test to Verify Instance Live Migration 75/70275/38
authorbalakrishnan <balakrishnan.ka@hcl.com>
Tue, 3 Apr 2018 22:56:40 +0000 (04:26 +0530)
committerSam Hague <shague@redhat.com>
Wed, 20 Jun 2018 20:08:08 +0000 (20:08 +0000)
Change-Id: I5effcb2ef1f0ad30a88d8413d1748c2314cd914b
Signed-off-by: balakrishnan <balakrishnan.ka@hcl.com>
Signed-off-by: Sam Hague <shague@redhat.com>
Signed-off-by: Jamo Luhrsen <jluhrsen@redhat.com>
csit/libraries/LiveMigration.robot [new file with mode: 0644]
csit/libraries/OpenStackOperations.robot
csit/suites/openstack/connectivity/live_migration.robot [new file with mode: 0644]
csit/testplans/netvirt-1node-openstack.txt
csit/testplans/netvirt-3node-openstack.txt

diff --git a/csit/libraries/LiveMigration.robot b/csit/libraries/LiveMigration.robot
new file mode 100644 (file)
index 0000000..7d295f0
--- /dev/null
@@ -0,0 +1,37 @@
+*** Settings ***
+Documentation     Live Migration Library, This can be used by Live Migration tests.
+Library           SSHLibrary
+Resource          DevstackUtils.robot
+Resource          OpenStackOperations.robot
+Resource          SSHKeywords.robot
+Resource          ../variables/Variables.robot
+
+*** Variables ***
+${NOVA_CPU_CONF}    /etc/nova/nova-cpu.conf
+${NOVA_COMPUTE_SERVICE}    n-cpu
+${CMP_INSTANCES_DEFAULT_PATH}    /opt/stack/data/nova/instances
+
+*** Keywords ***
+Live Migration Suite Setup
+    [Documentation]    Suite Setup For Live Migration Tests
+    OpenStackOperations.OpenStack Suite Setup
+    LiveMigration.Setup Live Migration In Compute Nodes
+
+Live Migration Suite Teardown
+    [Documentation]    Suite Teardown for Live Migration Tests
+    LiveMigration.UnSet Live Migration In Compute Nodes
+    OpenStackOperations.OpenStack Suite Teardown
+
+Setup Live Migration In Compute Nodes
+    [Documentation]    Set instances to be created in the shared directory.
+    OpenStackOperations.Modify OpenStack Configuration File    ${OS_CMP1_CONN_ID}    ${NOVA_CPU_CONF}    DEFAULT    instances_path    ${CMP_INSTANCES_SHARED_PATH}
+    OpenStackOperations.Modify OpenStack Configuration File    ${OS_CMP2_CONN_ID}    ${NOVA_CPU_CONF}    DEFAULT    instances_path    ${CMP_INSTANCES_SHARED_PATH}
+    OpenStackOperations.Restart DevStack Service    ${OS_CMP1_CONN_ID}    ${NOVA_COMPUTE_SERVICE}
+    OpenStackOperations.Restart DevStack Service    ${OS_CMP2_CONN_ID}    ${NOVA_COMPUTE_SERVICE}
+
+UnSet Live Migration In Compute Nodes
+    [Documentation]    Clear settings done for Live Migration
+    OpenStackOperations.Modify OpenStack Configuration File    ${OS_CMP1_CONN_ID}    ${NOVA_CPU_CONF}    DEFAULT    instances_path    ${CMP_INSTANCES_DEFAULT_PATH}
+    OpenStackOperations.Modify OpenStack Configuration File    ${OS_CMP2_CONN_ID}    ${NOVA_CPU_CONF}    DEFAULT    instances_path    ${CMP_INSTANCES_DEFAULT_PATH}
+    OpenStackOperations.Restart DevStack Service    ${OS_CMP1_CONN_ID}    ${NOVA_COMPUTE_SERVICE}
+    OpenStackOperations.Restart DevStack Service    ${OS_CMP2_CONN_ID}    ${NOVA_COMPUTE_SERVICE}
index cc0d9b1b3b52034bca538e888d0ba90cdc3e3c52..f216a158ad9983959f33b47683912f2a495256fd 100644 (file)
@@ -1085,3 +1085,38 @@ Start Packet Capture On Nodes
 Stop Packet Capture On Nodes
     [Arguments]    ${conn_ids}=@{EMPTY}
     Tcpdump.Stop Packet Capture on Nodes    ${conn_ids}
+
+Server Live Migrate
+    [Arguments]    ${vm_instance_name}
+    [Documentation]    Keyword for live migration of VM instance
+    ...    additional_agrs is to select particular migration(live/shared-migration/block-migration)
+    ...    if the additional_agrs is not given default migration(shared-migration) will happen
+    ${output} =    OpenStackOperations.OpenStack CLI    nova live-migration ${vm_instance_name}
+
+Get Hypervisor Host Of Vm
+    [Arguments]    ${vm_name}
+    [Documentation]    Show server with neutron request.
+    ${output} =    OpenStackOperations.OpenStack CLI    openstack server show -f value -c OS-EXT-SRV-ATTR:host ${vm_name}
+    [Return]    ${output}
+
+Check If Migration Is Complete
+    [Arguments]    ${vm_name}
+    [Documentation]    Show server and verify if task_state is not migrating
+    ${output} =    OpenStackOperations.OpenStack CLI    openstack server show ${vm_name} | grep "OS-EXT-STS:task_state"
+    BuiltIn.Should Not Contain    ${output}    migrating
+
+Modify OpenStack Configuration File
+    [Arguments]    ${conn_id}    ${file_name}    ${section}    ${key}    ${value}
+    [Documentation]    Use crudini to modify any parameter in any Openstack configuration File
+    SSHLibrary.Switch Connection    ${conn_id}
+    ${output}    ${rc} =    SSHLibrary.Execute Command    sudo crudini --verbose --set --inplace ${file_name} ${section} ${key} ${value}    return_rc=True    return_stdout=True
+    BuiltIn.Log    ${output}
+    BuiltIn.Should Be True    '${rc}' == '0'
+
+Restart DevStack Service
+    [Arguments]    ${conn_id}    ${service_name}
+    [Documentation]    Restart the Openstack Service
+    SSHLibrary.Switch Connection    ${conn_id}
+    ${output}    ${rc} =    SSHLibrary.Execute Command    sudo systemctl restart devstack@${service_name}.service    return_rc=True    return_stdout=True
+    BuiltIn.Log    ${output}
+    BuiltIn.Should Be True    '${rc}' == '0'
diff --git a/csit/suites/openstack/connectivity/live_migration.robot b/csit/suites/openstack/connectivity/live_migration.robot
new file mode 100644 (file)
index 0000000..9e9af8f
--- /dev/null
@@ -0,0 +1,90 @@
+*** Settings ***
+Documentation     Test suite to verify live Migaration of VM instance also verify the connectivity
+...               of VM instance while Migrating the instance,
+Suite Setup       LiveMigration.Live Migration Suite Setup
+Suite Teardown    LiveMigration.Live Migration Suite Teardown
+Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
+Test Teardown     OpenStackOperations.Get Test Teardown Debugs
+Library           OperatingSystem
+Library           RequestsLibrary
+Library           SSHLibrary
+Resource          ../../../libraries/DevstackUtils.robot
+Resource          ../../../libraries/KarafKeywords.robot
+Resource          ../../../libraries/LiveMigration.robot
+Resource          ../../../libraries/OpenStackOperations.robot
+Resource          ../../../libraries/RemoteBash.robot
+Resource          ../../../libraries/SetupUtils.robot
+Resource          ../../../libraries/Utils.robot
+
+*** Variables ***
+${SECURITY_GROUP}    migration_sg
+@{NETWORKS}       migration_net_1
+@{SUBNETS}        migration_sub_1
+@{NET_1_VMS}      migration_net_1_vm_1    migration_net_1_vm_2
+@{SUBNETS_RANGE}    130.0.0.0/24
+
+*** Test Cases ***
+Create VXLAN Network migration_net_1
+    [Documentation]    Create Network with neutron request.
+    OpenstackOperations.Create Network    @{NETWORKS}[0]
+
+Create Subnets For migration_net_1
+    [Documentation]    Create Sub Nets for the Networks with neutron request.
+    OpenStackOperations.Create SubNet    @{NETWORKS}[0]    @{SUBNETS}[0]    @{SUBNETS_RANGE}[0]
+
+Add Ssh Allow Rule
+    [Documentation]    Allow all TCP/UDP/ICMP packets for this suite
+    OpenStackOperations.Create Allow All SecurityGroup    ${SECURITY_GROUP}
+
+Create Vm Instances For migration_net_1
+    [Documentation]    Create Four Vm instances using flavor and image names for a network.
+    OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[0]    ${OS_CMP1_HOSTNAME}    sg=${SECURITY_GROUP}
+    OpenStackOperations.Create Vm Instance On Compute Node    @{NETWORKS}[0]    @{NET_1_VMS}[1]    ${OS_CMP2_HOSTNAME}    sg=${SECURITY_GROUP}
+
+Check Vm Instances Have Ip Address
+    @{NET_1_VM_IPS}    ${NET_1_DHCP_IP} =    OpenStackOperations.Get VM IPs    @{NET_1_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
+    [Teardown]    BuiltIn.Run Keywords    OpenStackOperations.Show Debugs    @{NET_1_VMS}
+    ...    AND    OpenStackOperations.Get Test Teardown Debugs
+
+Migrate Instance And Verify Connectivity While Migration And After
+    [Documentation]    migrate the server to different host.
+    ...    and check the connectivity during Migration
+    ...    with a ping test from DHCP NS.
+    ${net_id} =    OpenStackOperations.Get Net Id    @{NETWORKS}[0]
+    ${devstack_conn_id} =    OpenStackOperations.Get ControlNode Connection
+    SSHLibrary.Switch Connection    ${devstack_conn_id}
+    ${output} =    SSHLibrary.Write    sudo ip netns exec qdhcp-${net_id} ping @{NET1_VM_IPS}[0]
+    ${vm_host_before_migration} =    OpenStackOperations.Get Hypervisor Host Of Vm    @{NET_1_VMS}[0]
+    OpenStackOperations.Server Live Migrate    @{NET_1_VMS}[0]
+    ${vm_list} =    BuiltIn.Create List    @{NET_1_VMS}[0]
+    : FOR    ${vm}    IN    @{vm_list}
+    \    BuiltIn.Wait Until Keyword Succeeds    6x    20s    OpenStackOperations.Check If Migration Is Complete    ${vm}
+    ${vm_host_after_migration} =    OpenStackOperations.Get Hypervisor Host Of Vm    @{NET_1_VMS}[0]
+    BuiltIn.Should Not Match    ${vm_host_after_migration}    ${vm_host_before_migration}
+    SSHLibrary.Switch Connection    ${devstack_conn_id}
+    RemoteBash.Write_Bare_Ctrl_C
+    ${output} =    SSHLibrary.Read Until    packet loss
+    BuiltIn.Should Contain    ${output}    64 bytes
+    ${output} =    DevstackUtils.Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 10 @{NET1_VM_IPS}[0]
+    BuiltIn.Should Contain    ${output}    64 bytes
+
+Delete Vm Instances In migration_net_1
+    [Documentation]    Delete Vm instances using instance names in network_1.
+    : FOR    ${vm}    IN    @{NET_1_VMS}
+    \    OpenStackOperations.Delete Vm Instance    ${vm}
+
+Delete Sub Networks In migration_net_1
+    [Documentation]    Delete Sub Nets for the Networks with neutron request.
+    OpenStackOperations.Delete SubNet    @{SUBNETS}[0]
+
+Delete Networks
+    [Documentation]    Delete Networks with neutron request.
+    : FOR    ${NetworkElement}    IN    @{NETWORKS}
+    \    OpenStackOperations.Delete Network    ${NetworkElement}
+
+Delete SecurityGroup
+    [Documentation]    Delete SecurityGroup with neutron request.
+    OpenStackOperations.Delete SecurityGroup    ${SECURITY_GROUP}
index ff9a64a8efb6784f5f860f6432bf13e2d71300ce..568012370a4b24b439e737e703022c97fd095557 100644 (file)
@@ -2,6 +2,7 @@ integration/test/csit/suites/openstack/connectivity/l2.robot
 integration/test/csit/suites/openstack/connectivity/l3.robot
 integration/test/csit/suites/openstack/connectivity/external_network.robot
 integration/test/csit/suites/openstack/connectivity/security_group.robot
+integration/test/csit/suites/openstack/connectivity/live_migration.robot
 integration/test/csit/suites/openstack/tempest/tempest.robot
 integration/test/csit/suites/openstack/securitygroup/neutron_security_group.robot
 integration/test/csit/suites/netvirt/vpnservice/vpn_basic.robot
index ceb7e6b952957f13b784811f28e9eabab1794442..c69b95d34ccab1ed09098f31c77d3816b8dc3263 100644 (file)
@@ -2,6 +2,7 @@ integration/test/csit/suites/openstack/connectivity/l2.robot
 integration/test/csit/suites/openstack/connectivity/l3.robot
 integration/test/csit/suites/openstack/connectivity/external_network.robot
 integration/test/csit/suites/openstack/connectivity/security_group.robot
+integration/test/csit/suites/openstack/connectivity/live_migration.robot
 integration/test/csit/suites/openstack/clustering/ha_l2.robot
 integration/test/csit/suites/openstack/clustering/ha_l3.robot
 # Disable this test until https://bugzilla.redhat.com/show_bug.cgi?id=1488907 gets resolved and then reflect changes in healthcheck in haproxy