From 03c91eb052f65bd39df48da80207f3a9d052f0fc Mon Sep 17 00:00:00 2001 From: otsvigun Date: Thu, 3 Mar 2016 17:08:33 +0200 Subject: [PATCH] Add test dvs_different_networks and doc fix. -add test dvs_different_networks -update test dvs_different_networks in Test Plan -update doc strings -update test dvs_regression -fix rally heat -fix flake8 H306, I100 Change-Id: I41c4d9f8de2356540a7974c55c8cf74c2859a6e2 --- docs/test_plan/conf.py | 3 - docs/test_plan/source/test_suite_system.rst | 31 +- plugin_test/helpers/openstack.py | 104 ++-- plugin_test/helpers/plugin.py | 46 +- .../create-and-delete-stack_with_neutron.yaml | 2 + .../templates/server_with_ports.yml.template | 3 +- plugin_test/run_tests.py | 59 +- .../test_plugin_vmware_dvs_destructive.py | 98 ++-- .../test_plugin_vmware_dvs_maintenance.py | 173 ++++-- .../tests/test_plugin_vmware_dvs_smoke.py | 54 +- .../tests/test_plugin_vmware_dvs_system.py | 503 ++++++++++++------ .../tests/test_plugin_vmware_dvs_templates.py | 68 ++- 12 files changed, 729 insertions(+), 415 deletions(-) diff --git a/docs/test_plan/conf.py b/docs/test_plan/conf.py index 59c794c..df47ffe 100644 --- a/docs/test_plan/conf.py +++ b/docs/test_plan/conf.py @@ -12,9 +12,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys -import os - # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. diff --git a/docs/test_plan/source/test_suite_system.rst b/docs/test_plan/source/test_suite_system.rst index 4e73213..d4fb094 100644 --- a/docs/test_plan/source/test_suite_system.rst +++ b/docs/test_plan/source/test_suite_system.rst @@ -305,7 +305,7 @@ Check connectivity between instances attached to different networks with and wit ID ## -dvs_connectivity_diff_networks +dvs_different_networks Description @@ -324,20 +324,21 @@ Steps ##### 1. Setup for system tests. - 2. Log in to Horizon Dashboard. - 3. Add two private networks (net01, and net02). - 4. Add one subnet (net01_subnet01: 192.168.101.0/24, net02_subnet01, 192.168.102.0/24) to each network. - 5. Navigate to Project -> Compute -> Instances - 6. Launch instances VM_1 and VM_2 in the network 192.168.101.0/24 with image TestVM and flavor m1.micro in nova availability zone. - 7. Launch instances VM_3 and VM_4 in the 192.168.102.0/24 with image TestVM-VMDK and flavor m1.micro in vcenter availability zone. - 8. Verify that instances of same networks should communicate between each other. Send icmp ping from VM_1 to VM_2, VM_3 to VM_4 and vice versa. - 9. Verify that instances of different networks should not communicate between each other. Send icmp ping from VM_1 to VM_3, VM_4 to VM_2 and vice versa. - 10. Create Router_01, set gateway and add interface to external network. - 11. Attach private networks to Router_01. - 12. Verify that instances of different networks should communicate between each other. Send icmp ping from VM_1 to VM_3, VM_4 to VM_2) and vice versa. - 13. Add new Router_02, set gateway and add interface to external network. - 14. Delete net_02 from Router_01 and add it to the Router_02. - 15. Verify that instances of different networks should not communicate between each other. Send icmp ping from VM_1 to VM_3, VM_4 to VM_2 and vice versa. + 2. Create private networks net01 and net02 with subnets. + 3. Create Router_01, set gateway and add interface to external network. + 4. Create Router_02, set gateway and add interface to external network. + 5. Attach private networks to Router_01. + 6. Attach private networks to Router_02. + 7. Launch instances in the net01 with image TestVM and flavor m1.micro in nova az. + 8. Launch instances in the net01 with image TestVM-VMDK and flavor m1.micro in vcenter az. + 9. Launch instances in the net02 with image TestVM and flavor m1.micro in nova az. + 10. Launch instances in the net02 with image TestVM-VMDK and flavor m1.micro in vcenter az. + 11. Verify that instances of same networks should communicate between each other via private ip. + Send icmp ping between instances. + 12. Verify that instances of different networks should not communicate between each other via private ip. + 13. Delete net_02 from Router_02 and add it to the Router_01. + 14. Verify that instances of different networks should communicate between each other via private ip. + Send icmp ping between instances. Expected result diff --git a/plugin_test/helpers/openstack.py b/plugin_test/helpers/openstack.py index 782bbc1..268babf 100644 --- a/plugin_test/helpers/openstack.py +++ b/plugin_test/helpers/openstack.py @@ -1,27 +1,31 @@ -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -import paramiko -import yaml +"""Copyright 2016 Mirantis, Inc. +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" -from proboscis.asserts import assert_true -from devops.helpers.helpers import wait from devops.error import TimeoutError +from devops.helpers.helpers import wait + +from fuelweb_test import logger from fuelweb_test.settings import SERVTEST_TENANT -from fuelweb_test import logger + +import paramiko + +from proboscis.asserts import assert_true + +import yaml def get_defaults(): @@ -40,7 +44,8 @@ instance_creds = ( def verify_instance_state(os_conn, instances=None, expected_state='ACTIVE', boot_timeout=300): - """Verify that current state of each instance/s is expected + """Verify that current state of each instance/s is expected. + :param os_conn: type object, openstack :param instances: type list, list of created instances :param expected_state: type string, expected state of instance @@ -66,7 +71,8 @@ def verify_instance_state(os_conn, instances=None, expected_state='ACTIVE', def create_instances(os_conn, nics, vm_count=1, security_groups=None, available_hosts=None): - """Create Vms on available hypervisors + """Create Vms on available hypervisors. + :param os_conn: type object, openstack :param vm_count: type interger, count of VMs to create :param nics: type dictionary, neutron networks @@ -74,8 +80,8 @@ def create_instances(os_conn, nics, vm_count=1, :param security_groups: A list of security group names :param available_hosts: available hosts for creating instances """ - # Get list of available images,flavors and hipervisors + instances = [] images_list = os_conn.nova.images.list() flavors = os_conn.nova.flavors.list() flavor = [f for f in flavors if f.name == 'm1.micro'][0] @@ -85,20 +91,22 @@ def create_instances(os_conn, nics, vm_count=1, image = [image for image in images_list if image.name == zone_image_maps[host.zone]][0] - os_conn.nova.servers.create( + instance = os_conn.nova.servers.create( flavor=flavor, name='test_{0}'.format(image.name), image=image, min_count=vm_count, availability_zone='{0}:{1}'.format(host.zone, host.host), nics=nics, security_groups=security_groups ) + instances.append(instance) + return instances def check_connection_vms(os_conn, srv_list, remote, command='pingv4', result_of_command=0, destination_ip=None): - """Check network connectivity between instancea and destination ip - with ping + """Check network connectivity between instances. + :param os_conn: type object, openstack :param srv_list: type list, instances :param packets: type int, packets count of icmp reply @@ -106,7 +114,6 @@ def check_connection_vms(os_conn, srv_list, remote, command='pingv4', :param destination_ip: type list, remote destination ip to check by ping """ - commands = { "pingv4": "ping -c 5 {}", "pingv6": "ping6 -c 5 {}", @@ -156,11 +163,11 @@ def get_ssh_connection(ip, username, userpassword, timeout=30, port=22): def check_ssh_between_instances(instance1_ip, instance2_ip): - """Check ssh conection between instances + """Check ssh conection between instances. + :param instance1: string, instance ip connect from :param instance2: string, instance ip connect to """ - ssh = get_ssh_connection(instance1_ip, instance_creds[0], instance_creds[1], timeout=30) @@ -184,7 +191,8 @@ def check_ssh_between_instances(instance1_ip, instance2_ip): def remote_execute_command(instance1_ip, instance2_ip, command): - """Check execute remote command + """Check execute remote command. + :param instance1: string, instance ip connect from :param instance2: string, instance ip connect to :param command: string, remote command @@ -230,13 +238,13 @@ def remote_execute_command(instance1_ip, instance2_ip, command): def create_and_assign_floating_ip(os_conn, srv_list=None, ext_net=None, tenant_id=None): - """Create Vms on available hypervisors + """Create Vms on available hypervisors. + :param os_conn: type object, openstack :param srv_list: type list, objects of created instances :param ext_net: type object, neutron external network :param tenant_id: type string, tenant id """ - if not ext_net: ext_net = [net for net in os_conn.neutron.list_networks()["networks"] @@ -258,12 +266,12 @@ def create_and_assign_floating_ip(os_conn, srv_list=None, def add_router(os_conn, router_name, ext_net_name=external_net_name, tenant_name=SERVTEST_TENANT): - """Create router with gateway + """Create router with gateway. + :param router_name: type string :param ext_net_name: type string :param tenant_name: type string """ - ext_net = [net for net in os_conn.neutron.list_networks()["networks"] if net['name'] == ext_net_name][0] @@ -329,7 +337,8 @@ def add_role_to_user(os_conn, user_name, role_name, tenant_name): def check_service(ssh, commands): - """Check that required nova services are running on controller + """Check that required nova services are running on controller. + :param ssh: SSHClient :param commands: type list, nova commands to execute on controller, example of commands: @@ -345,7 +354,8 @@ def check_service(ssh, commands): def create_volume(os_conn, availability_zone, size=1, expected_state="available"): - """Verify that current state of each instance/s is expected + """Create volume. + :param os_conn: type object, openstack :param availability_zone: type string, availability_zone where volume will be created @@ -368,9 +378,12 @@ def create_volume(os_conn, availability_zone, size=1, return volume -def create_access_point(os_conn, nics, security_groups, vm_count=1): - """Creating instance with floating ip as access point to instances - with private ip in the same network. +def create_access_point(os_conn, nics, security_groups): + """Create access point. + + Creating instance with floating ip as access point to instances + with private ip in the same network. + :param os_conn: type object, openstack :param vm_count: type interger, count of VMs to create :param nics: type dictionary, neutron networks @@ -380,21 +393,14 @@ def create_access_point(os_conn, nics, security_groups, vm_count=1): # get any available host host = os_conn.nova.services.list(binary='nova-compute')[0] # create access point server - create_instances( + access_point = create_instances( os_conn=os_conn, nics=nics, vm_count=1, security_groups=security_groups, - available_hosts=[host]) + available_hosts=[host]).pop() + verify_instance_state(os_conn) - create_and_assign_floating_ip( - os_conn=os_conn, - srv_list=os_conn.get_servers()) - - access_point = os_conn.get_servers()[0] - access_point_ip = [ - add['addr'] - for add in access_point.addresses[ - access_point.addresses.keys()[0]] - if add['OS-EXT-IPS:type'] == 'floating'][0] + access_point_ip = os_conn.assign_floating_ip( + access_point, use_neutron=True)['floating_ip_address'] return access_point, access_point_ip diff --git a/plugin_test/helpers/plugin.py b/plugin_test/helpers/plugin.py index 449878c..92e9ba1 100644 --- a/plugin_test/helpers/plugin.py +++ b/plugin_test/helpers/plugin.py @@ -1,26 +1,25 @@ -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +"""Copyright 2016 Mirantis, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" import os - -from proboscis.asserts import assert_true - - -from fuelweb_test.helpers import checkers from fuelweb_test import logger +from fuelweb_test.helpers import checkers + +from proboscis.asserts import assert_true # constants DVS_PLUGIN_PATH = os.environ.get('DVS_PLUGIN_PATH') @@ -32,9 +31,7 @@ plugin_name = "fuel-plugin-vmware-dvs" def install_dvs_plugin(master_node): - """Download and instal DVS plugin on master node. - - """ + """Download and instal DVS plugin on master node.""" # copy plugins to the master node checkers.upload_tarball( master_node, @@ -46,11 +43,8 @@ def install_dvs_plugin(master_node): plugin=os.path.basename(DVS_PLUGIN_PATH)) -def enable_plugin( - cluster_id, fuel_web_client, multiclusters=True): - """Enable DVS plugin on cluster - - """ +def enable_plugin(cluster_id, fuel_web_client, multiclusters=True): + """Enable DVS plugin on cluster.""" assert_true( fuel_web_client.check_plugin_exists( cluster_id, plugin_name), diff --git a/plugin_test/rally-scenarios/heat/create-and-delete-stack_with_neutron.yaml b/plugin_test/rally-scenarios/heat/create-and-delete-stack_with_neutron.yaml index f271550..b06b425 100644 --- a/plugin_test/rally-scenarios/heat/create-and-delete-stack_with_neutron.yaml +++ b/plugin_test/rally-scenarios/heat/create-and-delete-stack_with_neutron.yaml @@ -3,6 +3,8 @@ - args: template_path: "{{ current_path }}/templates/server_with_ports.yml.template" + parameters: + public_net: "{{ floating_net }}" runner: type: "constant" times: {{ compute }} diff --git a/plugin_test/rally-scenarios/heat/templates/server_with_ports.yml.template b/plugin_test/rally-scenarios/heat/templates/server_with_ports.yml.template index bf3b906..921abdc 100644 --- a/plugin_test/rally-scenarios/heat/templates/server_with_ports.yml.template +++ b/plugin_test/rally-scenarios/heat/templates/server_with_ports.yml.template @@ -4,13 +4,12 @@ parameters: # set all correct defaults for parameters before launch test public_net: type: string - default: net04_ext image: type: string default: TestVM-VMDK flavor: type: string - default: m1.tiny + default: m1.nano cidr: type: string default: 11.11.11.0/24 diff --git a/plugin_test/run_tests.py b/plugin_test/run_tests.py index 7b1f0d7..58eaec6 100644 --- a/plugin_test/run_tests.py +++ b/plugin_test/run_tests.py @@ -1,54 +1,65 @@ -# Copyright 2015 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +#!/usr/bin/env python +"""Copyright 2016 Mirantis, Inc. -import sys +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" import os import re +import sys + from nose.plugins import Plugin + from paramiko.transport import _join_lingering_threads class CloseSSHConnectionsPlugin(Plugin): - """Closes all paramiko's ssh connections after each test case + """Closes all paramiko's ssh connections after each test case. Plugin fixes proboscis disability to run cleanup of any kind. - 'afterTest' calls _join_lingering_threads function from paramiko, - which stops all threads (set the state to inactive and joins for 10s) """ + name = 'closesshconnections' def options(self, parser, env=os.environ): + """Options.""" super(CloseSSHConnectionsPlugin, self).options(parser, env=env) def configure(self, options, conf): + """Configure env.""" super(CloseSSHConnectionsPlugin, self).configure(options, conf) self.enabled = True - def afterTest(self, *args, **kwargs): + def after_test(self, *args, **kwargs): + """After_Test. + + After_Test calls _join_lingering_threads function from paramiko, + which stops all threads (set the state to inactive and joins for 10s). + """ _join_lingering_threads() def import_tests(): - from tests import test_plugin_vmware_dvs_destructive - from tests import test_plugin_vmware_dvs_maintenance - from tests import test_plugin_vmware_dvs_smoke - from tests import test_plugin_vmware_dvs_system - from tests import test_plugin_vmware_dvs_templates + """Import test suite of project.""" + from tests import test_plugin_vmware_dvs_destructive # noqa + from tests import test_plugin_vmware_dvs_maintenance # noqa + from tests import test_plugin_vmware_dvs_smoke # noqa + from tests import test_plugin_vmware_dvs_system # noqa + from tests import test_plugin_vmware_dvs_templates # noqa + def run_tests(): + """Run test cases.""" from proboscis import TestProgram # noqa # Check if the specified test group starts any test case @@ -64,7 +75,7 @@ def run_tests(): if __name__ == '__main__': - sys.path.append(sys.path[0]+"/fuel-qa") + sys.path.append(sys.path[0] + "/fuel-qa") import_tests() from fuelweb_test.helpers.patching import map_test if any(re.search(r'--group=patching_master_tests', arg) diff --git a/plugin_test/tests/test_plugin_vmware_dvs_destructive.py b/plugin_test/tests/test_plugin_vmware_dvs_destructive.py index e081732..f862223 100644 --- a/plugin_test/tests/test_plugin_vmware_dvs_destructive.py +++ b/plugin_test/tests/test_plugin_vmware_dvs_destructive.py @@ -1,46 +1,58 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +"""Copyright 2016 Mirantis, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" + import time - -from proboscis import test -from proboscis.asserts import assert_true from devops.helpers.helpers import wait - -from fuelweb_test.helpers.decorators import log_snapshot_after_test from fuelweb_test import logger -from fuelweb_test.settings import DEPLOYMENT_MODE -from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE -from fuelweb_test.settings import SERVTEST_USERNAME -from fuelweb_test.settings import SERVTEST_PASSWORD -from fuelweb_test.settings import SERVTEST_TENANT -from fuelweb_test.tests.base_test_case import SetupEnvironment -from fuelweb_test.tests.base_test_case import TestBasic + from fuelweb_test.helpers import os_actions +from fuelweb_test.helpers.decorators import log_snapshot_after_test + +from fuelweb_test.settings import DEPLOYMENT_MODE +from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE +from fuelweb_test.settings import SERVTEST_PASSWORD +from fuelweb_test.settings import SERVTEST_TENANT +from fuelweb_test.settings import SERVTEST_USERNAME + +from fuelweb_test.tests.base_test_case import SetupEnvironment +from fuelweb_test.tests.base_test_case import TestBasic -from helpers import plugin from helpers import openstack +from helpers import plugin + +from proboscis import test + +from proboscis.asserts import assert_true @test(groups=["plugins", 'dvs_vcenter_plugin', 'dvs_vcenter_system']) -class TestDVSPlugin(TestBasic): +class TestDVSDestructive(TestBasic): + """Failover test suite. - # constants - node_name = lambda self, name_node: self.fuel_web. \ - get_nailgun_node_by_name(name_node)['hostname'] + Destructive(Failover) and recovery testing ensures that the + target-of-test can successfully failover and recover from a variety of + hardware, software, or network malfunctions with undue loss of data or + data integrity. + """ + + def node_name(self, name_node): + """Get node by name.""" + return self.fuel_web.get_nailgun_node_by_name(name_node)['hostname'] # defaults inter_net_name = openstack.get_defaults()['networks']['internal']['name'] @@ -49,7 +61,7 @@ class TestDVSPlugin(TestBasic): groups=["dvs_vcenter_destructive_setup", "dvs_vcenter_plugin"]) @log_snapshot_after_test def dvs_vcenter_destructive_setup(self): - """Deploy cluster with plugin and vmware datastore backend + """Deploy cluster with plugin and vmware datastore backend. Scenario: 1. Upload plugins to the master node @@ -61,7 +73,7 @@ class TestDVSPlugin(TestBasic): 7. Deploy the cluster. 8. Run OSTF. - Duration 1.8 hours + Duration: 1.8 hours """ self.env.revert_snapshot("ready_with_5_slaves") @@ -110,24 +122,20 @@ class TestDVSPlugin(TestBasic): groups=["dvs_vcenter_uninstall", 'dvs_vcenter_system']) @log_snapshot_after_test def dvs_vcenter_uninstall(self): - """Verify that it is not possibility to uninstall - of Fuel DVS plugin with deployed environment. + """Negative uninstall of Fuel DVS plugin with deployed environment. Scenario: - 1. Revert snapshot to dvs_vcenter_destructive_setup + 1. Revert snapshot to dvs_vcenter_destructive_setup. 2. Try to uninstall dvs plugin. - Duration 1.8 hours + Duration: 1.8 hours """ - - plugin_name = "fuel-plugin-vmware-dvs" - self.env.revert_snapshot("dvs_vcenter_destructive_setup") # Try to uninstall dvs plugin cmd = 'fuel plugins --remove {0}=={1}'.format( - plugin_name, plugin.DVS_PLUGIN_VERSION) + plugin.plugin_name, plugin.DVS_PLUGIN_VERSION) self.env.d_env.get_admin_remote().execute(cmd)['exit_code'] == 1 @@ -144,8 +152,7 @@ class TestDVSPlugin(TestBasic): groups=["dvs_vcenter_bind_port", "dvs_vcenter_destructive_setup"]) @log_snapshot_after_test def dvs_vcenter_bind_port(self): - """Check abilities to bind port on DVS to VM, - disable and enable this port. + """Check abilities to bind port on DVS to VM, disable/enable this port. Scenario: 1. Revert snapshot to dvs_vcenter_destructive_setup @@ -161,10 +168,9 @@ class TestDVSPlugin(TestBasic): Send icmp ping between instances. - Duration 1,5 hours + Duration: 1,5 hours """ - self.env.revert_snapshot("dvs_vcenter_destructive_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -264,7 +270,7 @@ class TestDVSPlugin(TestBasic): 11. Verify connection between instances. Send ping, check that ping get reply - Duration 1.8 hours + Duration: 1.8 hours """ self.env.revert_snapshot("ready_with_5_slaves") @@ -373,7 +379,7 @@ class TestDVSPlugin(TestBasic): 11. Verify connection between instances. Send ping, check that ping get reply - Duration 1.8 hours + Duration: 1.8 hours """ self.env.revert_snapshot("ready_with_5_slaves") diff --git a/plugin_test/tests/test_plugin_vmware_dvs_maintenance.py b/plugin_test/tests/test_plugin_vmware_dvs_maintenance.py index d3ed8d9..cabc626 100644 --- a/plugin_test/tests/test_plugin_vmware_dvs_maintenance.py +++ b/plugin_test/tests/test_plugin_vmware_dvs_maintenance.py @@ -1,39 +1,64 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from proboscis import test +"""Copyright 2016 Mirantis, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" + +import time + +from fuelweb_test import logger + +from fuelweb_test.helpers import os_actions from fuelweb_test.helpers.decorators import log_snapshot_after_test + from fuelweb_test.settings import DEPLOYMENT_MODE from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE +from fuelweb_test.settings import SERVTEST_PASSWORD +from fuelweb_test.settings import SERVTEST_TENANT +from fuelweb_test.settings import SERVTEST_USERNAME + from fuelweb_test.tests.base_test_case import SetupEnvironment from fuelweb_test.tests.base_test_case import TestBasic +from helpers import openstack from helpers import plugin +from proboscis import test + +from proboscis.asserts import assert_true + @test(groups=["plugins"]) -class TestDVSPlugin(TestBasic): +class TestDVSMaintenance(TestBasic): + """Test suite for check functional of DVS plugin after FUEL/MOS updates.""" # constants - node_name = lambda self, name_node: self.fuel_web. \ - get_nailgun_node_by_name(name_node)['hostname'] + net_data = [{'net_1': '192.168.112.0/24'}, + {'net_2': '192.168.113.0/24'}] + + # defaults + ext_net_name = openstack.get_defaults()['networks']['floating']['name'] + inter_net_name = openstack.get_defaults()['networks']['internal']['name'] + + def node_name(self, name_node): + """Get node by name.""" + return self.fuel_web.get_nailgun_node_by_name(name_node)['hostname'] @test(depends_on=[SetupEnvironment.prepare_slaves_9], - groups=["dvs_vcenter_maintenance"]) + groups=["dvs_regression"]) @log_snapshot_after_test - def dvs_vcenter_maintenance(self): - """Deploy cluster with plugin and vmware datastore backend + def dvs_regression(self): + """Deploy cluster with plugin and vmware datastore backend. Scenario: 1. Upload plugins to the master node @@ -44,15 +69,16 @@ class TestDVSPlugin(TestBasic): 6. Add 1 node with compute-vmware role. 7. Deploy the cluster. 8. Run OSTF. + 9. Create non default network. + 10. Create Security groups + 11. Launch instances with created network in nova and vcenter az. + 12. Attached created security groups to instances. + 13. Check connection between instances from different az. - Duration 1.8 hours - + Duration: 1.8 hours """ self.env.revert_snapshot("ready_with_9_slaves") - - plugin.install_dvs_plugin( - self.env.d_env.get_admin_remote()) - + plugin.install_dvs_plugin(self.env.d_env.get_admin_remote()) # Configure cluster with 2 vcenter clusters and vcenter glance cluster_id = self.fuel_web.create_cluster( name=self.__class__.__name__, @@ -60,11 +86,10 @@ class TestDVSPlugin(TestBasic): settings={ "net_provider": 'neutron', "net_segment_type": NEUTRON_SEGMENT_TYPE, - 'images_vcenter': True + "images_vcenter": True } ) plugin.enable_plugin(cluster_id, self.fuel_web) - # Assign role to node self.fuel_web.update_nodes( cluster_id, @@ -75,7 +100,6 @@ class TestDVSPlugin(TestBasic): 'slave-05': ['compute'], 'slave-06': ['compute-vmware']} ) - # Configure VMWare vCenter settings target_node_2 = self.node_name('slave-06') self.fuel_web.vcenter_configure( @@ -84,8 +108,95 @@ class TestDVSPlugin(TestBasic): multiclusters=True, vc_glance=True ) - self.fuel_web.deploy_cluster_wait(cluster_id) - self.fuel_web.run_ostf( cluster_id=cluster_id, test_sets=['smoke', 'tests_platform']) + + os_ip = self.fuel_web.get_public_vip(cluster_id) + os_conn = os_actions.OpenStackActions( + os_ip, SERVTEST_USERNAME, + SERVTEST_PASSWORD, + SERVTEST_TENANT) + # Create non default network with subnet. + logger.info('Create network {}'.format(self.net_data[0].keys()[0])) + network = openstack.create_network( + os_conn, + self.net_data[0].keys()[0], + tenant_name=SERVTEST_TENANT + ) + logger.info('Create subnet {}'.format(self.net_data[0].keys()[0])) + subnet = openstack.create_subnet( + os_conn, + network, + self.net_data[0][self.net_data[0].keys()[0]], + tenant_name=SERVTEST_TENANT + ) + # Check that network are created. + assert_true( + os_conn.get_network(network['name'])['id'] == network['id'] + ) + # Add net_1 to default router + router = os_conn.get_router(os_conn.get_network(self.ext_net_name)) + openstack.add_subnet_to_router( + os_conn, + router['id'], subnet['id']) + # Launch instance 2 VMs of vcenter and 2 VMs of nova + # in the tenant network net_01 + openstack.create_instances( + os_conn=os_conn, vm_count=1, + nics=[{'net-id': network['id']}] + ) + # Launch instance 2 VMs of vcenter and 2 VMs of nova + # in the default network + network = os_conn.nova.networks.find(label=self.inter_net_name) + openstack.create_instances( + os_conn=os_conn, vm_count=1, + nics=[{'net-id': network.id}]) + openstack.verify_instance_state(os_conn) + openstack.create_and_assign_floating_ip(os_conn=os_conn) + # Create security groups SG_1 to allow ICMP traffic. + # Add Ingress rule for ICMP protocol to SG_1 + # Create security groups SG_2 to allow TCP traffic 22 port. + # Add Ingress rule for TCP protocol to SG_2 + sec_name = ['SG1', 'SG2'] + sg1 = os_conn.nova.security_groups.create( + sec_name[0], "descr") + sg2 = os_conn.nova.security_groups.create( + sec_name[1], "descr") + rulesets = [ + { + # ssh + 'ip_protocol': 'tcp', + 'from_port': 22, + 'to_port': 22, + 'cidr': '0.0.0.0/0', + }, + { + # ping + 'ip_protocol': 'icmp', + 'from_port': -1, + 'to_port': -1, + 'cidr': '0.0.0.0/0', + } + ] + os_conn.nova.security_group_rules.create( + sg1.id, **rulesets[0] + ) + os_conn.nova.security_group_rules.create( + sg2.id, **rulesets[1] + ) + # Remove default security group and attach SG_1 and SG2 to VMs + srv_list = os_conn.get_servers() + for srv in srv_list: + srv.remove_security_group(srv.security_groups[0]['name']) + srv.add_security_group(sg1.id) + srv.add_security_group(sg2.id) + time.sleep(20) # need wait to update rules on dvs + # Check ping between VMs + controller = self.fuel_web.get_nailgun_primary_node( + self.env.d_env.nodes().slaves[0] + ) + with self.fuel_web.get_ssh_for_node(controller.name) as ssh_controller: + openstack.check_connection_vms( + os_conn=os_conn, srv_list=srv_list, + remote=ssh_controller) diff --git a/plugin_test/tests/test_plugin_vmware_dvs_smoke.py b/plugin_test/tests/test_plugin_vmware_dvs_smoke.py index 3fcd505..e0ad9cf 100644 --- a/plugin_test/tests/test_plugin_vmware_dvs_smoke.py +++ b/plugin_test/tests/test_plugin_vmware_dvs_smoke.py @@ -1,35 +1,45 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -from proboscis import test +"""Copyright 2016 Mirantis, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" from fuelweb_test.helpers.decorators import log_snapshot_after_test + from fuelweb_test.settings import DEPLOYMENT_MODE from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE + from fuelweb_test.tests.base_test_case import SetupEnvironment from fuelweb_test.tests.base_test_case import TestBasic from helpers import plugin +from proboscis import test + @test(groups=["plugins", 'dvs_vcenter_plugin']) -class TestDVSPlugin(TestBasic): +class TestDVSSmoke(TestBasic): + """Smoke test suite. - # constants - node_name = lambda self, name_node: self.fuel_web. \ - get_nailgun_node_by_name(name_node)['hostname'] + The goal of smoke testing is to ensure that the most critical features + of Fuel VMware DVS plugin work after new build delivery. Smoke tests + will be used by QA to accept software builds from Development team. + """ - @test(depends_on=[SetupEnvironment.prepare_slaves_3], + def node_name(self, name_node): + """Get node by name.""" + return self.fuel_web.get_nailgun_node_by_name(name_node)['hostname'] + + @test(depends_on=[SetupEnvironment.prepare_slaves_1], groups=["dvs_vcenter_smoke", "dvs_vcenter_plugin"]) @log_snapshot_after_test def dvs_vcenter_smoke(self): @@ -54,10 +64,10 @@ class TestDVSPlugin(TestBasic): 10. Deploy the cluster. 11. Run OSTF. - Duration 1.8 hours + Duration: 1.8 hours """ - self.env.revert_snapshot("ready_with_3_slaves") + self.env.revert_snapshot("ready_with_1_slaves") plugin.install_dvs_plugin( self.env.d_env.get_admin_remote()) @@ -122,7 +132,7 @@ class TestDVSPlugin(TestBasic): 9. Deploy the cluster. 10. Run OSTF. - Duration 1.8 hours + Duration: 1.8 hours """ self.env.revert_snapshot("ready_with_9_slaves") diff --git a/plugin_test/tests/test_plugin_vmware_dvs_system.py b/plugin_test/tests/test_plugin_vmware_dvs_system.py index 826fc83..0ba3580 100644 --- a/plugin_test/tests/test_plugin_vmware_dvs_system.py +++ b/plugin_test/tests/test_plugin_vmware_dvs_system.py @@ -1,46 +1,58 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +"""Copyright 2016 Mirantis, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" + import time +from fuelweb_test import logger + +from fuelweb_test.helpers import os_actions + +from fuelweb_test.helpers.decorators import log_snapshot_after_test + +from fuelweb_test.settings import DEPLOYMENT_MODE +from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE +from fuelweb_test.settings import SERVTEST_PASSWORD +from fuelweb_test.settings import SERVTEST_TENANT +from fuelweb_test.settings import SERVTEST_USERNAME + +from fuelweb_test.tests.base_test_case import SetupEnvironment +from fuelweb_test.tests.base_test_case import TestBasic + +from helpers import openstack +from helpers import plugin + from proboscis import test + from proboscis.asserts import assert_true -from fuelweb_test.helpers.decorators import log_snapshot_after_test -from fuelweb_test import logger -from fuelweb_test.settings import DEPLOYMENT_MODE -from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE -from fuelweb_test.settings import SERVTEST_USERNAME -from fuelweb_test.settings import SERVTEST_PASSWORD -from fuelweb_test.settings import SERVTEST_TENANT -from fuelweb_test.tests.base_test_case import SetupEnvironment -from fuelweb_test.tests.base_test_case import TestBasic -from fuelweb_test.helpers import os_actions - - -from helpers import plugin -from helpers import openstack - - @test(groups=["plugins", 'dvs_vcenter_system']) -class TestDVSPlugin(TestBasic): +class TestDVSSystem(TestBasic): + """System test suite. + + The goal of integration and system testing is to ensure that new or + modified components of Fuel and MOS work effectively with Fuel VMware + DVS plugin without gaps in dataflow. + """ + + def node_name(self, name_node): + """Get node by name.""" + return self.fuel_web.get_nailgun_node_by_name(name_node)['hostname'] # constants - node_name = lambda self, name_node: self.fuel_web. \ - get_nailgun_node_by_name(name_node)['hostname'] - net_data = [{'net_1': '192.168.112.0/24'}, {'net_2': '192.168.113.0/24'}] @@ -55,10 +67,10 @@ class TestDVSPlugin(TestBasic): groups=["dvs_vcenter_systest_setup", 'dvs_vcenter_system']) @log_snapshot_after_test def dvs_vcenter_systest_setup(self): - """Deploy cluster with plugin and vmware datastore backend + """Deploy cluster with plugin and vmware datastore backend. Scenario: - 1. Upload plugins to the master node + 1. Upload plugins to the master node. 2. Install plugin. 3. Create cluster with vcenter. 4. Add 1 node with controller role. @@ -68,8 +80,8 @@ class TestDVSPlugin(TestBasic): 8. Run OSTF. 9. Create snapshot. - Duration 1.8 hours - Snapshot dvs_vcenter_systest_setup + Duration: 1.8 hours + Snapshot: dvs_vcenter_systest_setup """ self.env.revert_snapshot("ready_with_5_slaves") @@ -129,7 +141,7 @@ class TestDVSPlugin(TestBasic): 5. Check that net_1 is deleted. 6. Add net_1 again. - Duration 15 min + Duration: 15 min """ self.env.revert_snapshot("dvs_vcenter_systest_setup") @@ -212,10 +224,9 @@ class TestDVSPlugin(TestBasic): 7. Send ping from instances to 8.8.8.8 or other outside ip. - Duration 15 min + Duration: 15 min """ - self.env.revert_snapshot("dvs_vcenter_systest_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -286,7 +297,7 @@ class TestDVSPlugin(TestBasic): groups=["dvs_instances_one_group", 'dvs_vcenter_system']) @log_snapshot_after_test def dvs_instances_one_group(self): - """Check creation instance in the one group simultaneously + """Check creation instance in the one group simultaneously. Scenario: 1. Revert snapshot to dvs_vcenter_systest_setup. @@ -299,7 +310,7 @@ class TestDVSPlugin(TestBasic): 4. Check connection between instances (ping, ssh). 5. Delete all instances from horizon simultaneously. - Duration 15 min + Duration: 15 min """ self.env.revert_snapshot("dvs_vcenter_systest_setup") @@ -412,10 +423,9 @@ class TestDVSPlugin(TestBasic): 23. Check ping is available between instances. 24. Check ssh is available between instances. - Duration 30 min + Duration: 30 min """ - # security group rules tcp = { "security_group_rule": @@ -442,21 +452,19 @@ class TestDVSPlugin(TestBasic): SERVTEST_PASSWORD, SERVTEST_TENANT) + tenant = os_conn.get_tenant(SERVTEST_TENANT) + logger.info("Create non default network with subnet.") logger.info('Create network {}'.format(self.net_data[0].keys()[0])) - network = openstack.create_network( - os_conn, - self.net_data[0].keys()[0], - tenant_name=SERVTEST_TENANT - ) + network = os_conn.create_network( + network_name=self.net_data[0].keys()[0], + tenant_id=tenant.id)['network'] - logger.info('Create subnet {}'.format(self.net_data[0].keys()[0])) - subnet = openstack.create_subnet( - os_conn, - network, - self.net_data[0][self.net_data[0].keys()[0]], - tenant_name=SERVTEST_TENANT - ) + subnet = os_conn.create_subnet( + subnet_name=network['name'], + network_id=network['id'], + cidr=self.net_data[0][self.net_data[0].keys()[0]], + ip_version=4) logger.info("Check that network are created.") assert_true( @@ -465,9 +473,9 @@ class TestDVSPlugin(TestBasic): logger.info("Add net_1 to default router") router = os_conn.get_router(os_conn.get_network(self.ext_net_name)) - openstack.add_subnet_to_router( - os_conn, - router['id'], subnet['id']) + os_conn.add_router_interface( + router_id=router["id"], + subnet_id=subnet["id"]) logger.info("""Launch 2 instances of vcenter and 2 instances of nova in the tenant network net_01.""") @@ -489,7 +497,12 @@ class TestDVSPlugin(TestBasic): ) openstack.verify_instance_state(os_conn) - openstack.create_and_assign_floating_ip(os_conn=os_conn) + srv_list = os_conn.get_servers() + floating_ip = [] + for srv in srv_list: + floating_ip.append( + os_conn.assign_floating_ip( + srv, use_neutron=True)['floating_ip_address']) logger.info("""Create security groups SG_1 to allow ICMP traffic. Add Ingress rule for ICMP protocol to SG_1 @@ -529,13 +542,6 @@ class TestDVSPlugin(TestBasic): command='pingv4', remote=ssh_controller) logger.info("Check ssh connection is available between instances.") - floating_ip = [] - for srv in srv_list: - floating_ip.append( - [add['addr'] - for add in srv.addresses[srv.addresses.keys()[0]] - if add['OS-EXT-IPS:type'] == 'floating'][0]) - ip_pair = [(ip_1, ip_2) for ip_1 in floating_ip for ip_2 in floating_ip @@ -626,9 +632,7 @@ class TestDVSPlugin(TestBasic): groups=["dvs_vcenter_tenants_isolation", 'dvs_vcenter_system']) @log_snapshot_after_test def dvs_vcenter_tenants_isolation(self): - """Verify that instances on different tenants should not communicate - between each other. Send icmp ping from instances - of admin tenant to instances of test_tenant and vice versa. + """Connectivity between instances in different tenants. Scenario: 1. Revert snapshot to dvs_vcenter_systest_setup. @@ -641,14 +645,13 @@ class TestDVSPlugin(TestBasic): 6. Launch 2 instances in the default internal admin network in nova and vcenter az. 7. Verify that instances on different tenants should not - communicate between each other via no floating ip. - Send icmp ping from VM_3, - VM_4 of admin tenant to VM_3 VM_4 of test_tenant and vice versa. + communicate between each other via no floating ip. + Send icmp ping from VM_3, VM_4 of admin tenant to VM_3 VM_4 + of test_tenant and vice versa. - Duration 30 min + Duration: 30 min """ - self.env.revert_snapshot("dvs_vcenter_systest_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -751,8 +754,7 @@ class TestDVSPlugin(TestBasic): groups=["dvs_vcenter_same_ip", 'dvs_vcenter_system']) @log_snapshot_after_test def dvs_vcenter_same_ip(self): - """Check connectivity between instances with same ip - in different tenants. + """Connectivity between instances with same ip in different tenants. Scenario: 1. Revert snapshot to dvs_vcenter_systest_setup. @@ -779,10 +781,9 @@ class TestDVSPlugin(TestBasic): 12. Verify that VM_5, VM_6, VM_7 and VM_8 should communicate between each other via no floating ip. - Duration 30 min + Duration: 30 min """ - self.env.revert_snapshot("dvs_vcenter_systest_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -911,7 +912,7 @@ class TestDVSPlugin(TestBasic): groups=["dvs_volume", 'dvs_vcenter_system']) @log_snapshot_after_test def dvs_volume(self): - """Deploy cluster with plugin and vmware datastore backend + """Deploy cluster with plugin and vmware datastore backend. Scenario: 1. Upload plugins to the master node @@ -941,13 +942,15 @@ class TestDVSPlugin(TestBasic): 14. Check that each volume is attached to its instance. - Duration 1.8 hours + Duration: 1.8 hours """ + self.show_step(1) + self.show_step(2) self.env.revert_snapshot("ready_with_5_slaves") - plugin.install_dvs_plugin(self.env.d_env.get_admin_remote()) + self.show_step(3) cluster_id = self.fuel_web.create_cluster( name=self.__class__.__name__, mode=DEPLOYMENT_MODE, @@ -958,7 +961,9 @@ class TestDVSPlugin(TestBasic): ) plugin.enable_plugin(cluster_id, self.fuel_web) - # Assign role to node + self.show_step(4) + self.show_step(5) + self.show_step(6) self.fuel_web.update_nodes( cluster_id, {'slave-01': ['controller'], @@ -969,6 +974,7 @@ class TestDVSPlugin(TestBasic): } ) + self.show_step(8) logger.info('Configure VMware vCenter Settings.') target_node_2 = self.node_name('slave-05') self.fuel_web.vcenter_configure( @@ -977,6 +983,7 @@ class TestDVSPlugin(TestBasic): multiclusters=True ) + self.show_step(10) self.fuel_web.deploy_cluster_wait(cluster_id) self.fuel_web.run_ostf( @@ -996,14 +1003,14 @@ class TestDVSPlugin(TestBasic): if sg['tenant_id'] == admin.get_tenant(SERVTEST_TENANT).id if sg['name'] == 'default'][0] - logger.info("Create instances for each of hypervisor's type") + self.show_step(11) network = admin.nova.networks.find(label=self.inter_net_name) openstack.create_instances( os_conn=admin, nics=[{'net-id': network.id}], vm_count=1, security_groups=[default_sg['name']]) openstack.verify_instance_state(admin) - logger.info("Create 2 volumes each in his own availability zone.") + self.show_step(12) volume_vcenter = openstack.create_volume(admin, 'vcenter-cinder') volume_nova = openstack.create_volume(admin, 'nova') instances = admin.nova.servers.list() @@ -1016,10 +1023,11 @@ class TestDVSPlugin(TestBasic): for inst in instances if inst.to_dict()['OS-EXT-AZ:availability_zone'] == 'nova'][0] + self.show_step(13) admin.attach_volume(volume_vcenter, instance_vcenter) admin.attach_volume(volume_nova, instance_nova) - logger.info('Check that each volume is attached.') + self.show_step(14) assert_true( admin.cinder.volumes.get(volume_nova.id).status == 'in-use') @@ -1036,17 +1044,17 @@ class TestDVSPlugin(TestBasic): 1. Revert snapshot to dvs_vcenter_systest_setup. 2. Launch instances with image TestVM and flavor m1.micro in nova availability zone. - 4. Launch instances with image TestVM-VMDK + 3. Launch instances with image TestVM-VMDK and flavor m1.micro in vcenter availability zone. - 5. Verify that instances on different hypervisors + 4. Verify that instances on different hypervisors should communicate between each other. Send icmp ping from VM_1 instances of vCenter to instances from Qemu/KVM and vice versa. - Duration 15 min + Duration: 15 min """ - + self.show_step(1) self.env.revert_snapshot("dvs_vcenter_systest_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -1069,14 +1077,11 @@ class TestDVSPlugin(TestBasic): # create access point server access_point, access_point_ip = openstack.create_access_point( - os_conn=admin, nics=[{'net-id': network['id']}], + os_conn=admin, nics=[{'net-id': network.id}], security_groups=[security_group.name, default_sg['name']]) - logger.info("""Launch instances with image TestVM and flavor m1.micro - in nova az. - Launch instances with image TestVM-VMDK and flavor m1.micro - in vcenter az.""") - + self.show_step(2) + self.show_step(3) openstack.create_instances( os_conn=admin, nics=[{'net-id': network.id}], vm_count=1, @@ -1089,11 +1094,9 @@ class TestDVSPlugin(TestBasic): if instance.id != access_point.id] ips = [] for instance in instances: - ips.append([add['addr'] - for add - in instance.addresses[instance.addresses.keys()[0]] - if add['OS-EXT-IPS:type'] == 'fixed'][0]) - + ips.append(admin.get_nova_instance_ip( + instance, net_name=self.inter_net_name)) + self.show_step(4) for ip in ips: for ip_2 in ips: if ip_2 != ip: @@ -1102,7 +1105,7 @@ class TestDVSPlugin(TestBasic): assert_true( ping_result['exit_code'] == 0, "Ping isn't available from {0} to {1}".format(ip, ip_2) - ) + ) @test(depends_on=[dvs_vcenter_systest_setup], groups=["dvs_connect_nodefault_net"]) @@ -1110,7 +1113,7 @@ class TestDVSPlugin(TestBasic): def dvs_connect_nodefault_net(self): """Check connectivity between VMs with same ip in different tenants. - Scenario: + Scenario: 1. Revert snapshot to dvs_vcenter_systest_setup. 2. Create tenant net_01 with subnet. 3. Launch instances with image TestVM @@ -1123,7 +1126,7 @@ class TestDVSPlugin(TestBasic): from Qemu/KVM and vice versa. """ - + self.show_step(1) self.env.revert_snapshot("dvs_vcenter_systest_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -1133,6 +1136,8 @@ class TestDVSPlugin(TestBasic): SERVTEST_PASSWORD, SERVTEST_TENANT) + tenant = admin.get_tenant(SERVTEST_TENANT) + # create security group with rules for ssh and ping security_group = admin.create_sec_group_for_ssh() @@ -1142,20 +1147,16 @@ class TestDVSPlugin(TestBasic): if sg['tenant_id'] == admin.get_tenant(SERVTEST_TENANT).id if sg['name'] == 'default'][0] - # Create non default network with subnet. - logger.info('Create network {}'.format(self.net_data[0].keys()[0])) - network = openstack.create_network( - admin, - self.net_data[0].keys()[0], tenant_name=SERVTEST_TENANT - ) + self.show_step(2) + network = admin.create_network( + network_name=self.net_data[0].keys()[0], + tenant_id=tenant.id)['network'] - logger.info('Create subnet {}'.format(self.net_data[0].keys()[0])) - subnet = openstack.create_subnet( - admin, - network, - self.net_data[0][self.net_data[0].keys()[0]], - tenant_name=SERVTEST_TENANT - ) + subnet = admin.create_subnet( + subnet_name=network['name'], + network_id=network['id'], + cidr=self.net_data[0][self.net_data[0].keys()[0]], + ip_version=4) # Check that network are created. assert_true( @@ -1163,23 +1164,21 @@ class TestDVSPlugin(TestBasic): ) # Create Router_01, set gateway and add interface # to external network. - router_1 = openstack.add_router( - admin, - 'router_1') + router_1 = admin.create_router( + 'router_1', + tenant=tenant) # Add net_1 to router_1 - openstack.add_subnet_to_router( - admin, - router_1['id'], subnet['id']) + admin.add_router_interface( + router_id=router_1["id"], + subnet_id=subnet["id"]) access_point, access_point_ip = openstack.create_access_point( os_conn=admin, nics=[{'net-id': network['id']}], security_groups=[security_group.name, default_sg['name']]) - logger.info("""Launch instances with image TestVM and flavor m1.micro - in nova az. Launch instances with image TestVM-VMDK and flavor - m1.micro in vcenter az.""") - + self.show_step(3) + self.show_step(4) openstack.create_instances( os_conn=admin, nics=[{'net-id': network['id']}], vm_count=1, @@ -1192,13 +1191,10 @@ class TestDVSPlugin(TestBasic): if instance.id != access_point.id] ips = [] for instance in instances: - ips.append([add['addr'] - for add - in instance.addresses[instance.addresses.keys()[0]] - if add['OS-EXT-IPS:type'] == 'fixed'][0]) + ips.append(admin.get_nova_instance_ip( + instance, net_name=network['name'])) - logger.info("""Verify that instances on different hypervisors - should communicate between each other.""") + self.show_step(5) for ip in ips: for ip_2 in ips: if ip_2 != ip: @@ -1207,7 +1203,7 @@ class TestDVSPlugin(TestBasic): assert_true( ping_result['exit_code'] == 0, "Ping isn't available from {0} to {1}".format(ip, ip_2) - ) + ) @test(depends_on=[dvs_vcenter_systest_setup], groups=["dvs_ping_without_fip"]) @@ -1219,8 +1215,7 @@ class TestDVSPlugin(TestBasic): 1. Revert snapshot to dvs_vcenter_systest_setup. 2. Create private networks net01 with subnet. 3. Add one subnet (net01_subnet01: 192.168.101.0/24 - 4. Create Router_01, set gateway and add interface - to external network. + 4. Create Router_01, set gateway and add interface to external net. 5. Launch instances VM_1 and VM_2 in the net01 with image TestVM and flavor m1.micro in nova az. 6. Launch instances VM_3 and VM_4 in the net01 @@ -1228,10 +1223,10 @@ class TestDVSPlugin(TestBasic): 7. Send ping from instances to 8.8.8.8 or other outside ip. - Duration 15 min + Duration: 15 min """ - + self.show_step(1) self.env.revert_snapshot("dvs_vcenter_systest_setup") cluster_id = self.fuel_web.get_last_created_cluster() @@ -1241,6 +1236,8 @@ class TestDVSPlugin(TestBasic): SERVTEST_PASSWORD, SERVTEST_TENANT) + tenant = admin.get_tenant(SERVTEST_TENANT) + # create security group with rules for ssh and ping security_group = admin.create_sec_group_for_ssh() @@ -1250,20 +1247,18 @@ class TestDVSPlugin(TestBasic): if sg['tenant_id'] == admin.get_tenant(SERVTEST_TENANT).id if sg['name'] == 'default'][0] - # Create non default network with subnet. + self.show_step(2) logger.info('Create network {}'.format(self.net_data[0].keys()[0])) - network = openstack.create_network( - admin, - self.net_data[0].keys()[0], tenant_name=SERVTEST_TENANT - ) + network = admin.create_network( + network_name=self.net_data[0].keys()[0], + tenant_id=tenant.id)['network'] - logger.info('Create subnet {}'.format(self.net_data[0].keys()[0])) - subnet = openstack.create_subnet( - admin, - network, - self.net_data[0][self.net_data[0].keys()[0]], - tenant_name=SERVTEST_TENANT - ) + self.show_step(3) + subnet = admin.create_subnet( + subnet_name=network['name'], + network_id=network['id'], + cidr=self.net_data[0][self.net_data[0].keys()[0]], + ip_version=4) # Check that network are created. assert_true( @@ -1271,24 +1266,21 @@ class TestDVSPlugin(TestBasic): ) # Create Router_01, set gateway and add interface # to external network. - router_1 = openstack.add_router( - admin, - 'router_1') + router_1 = admin.create_router( + 'router_1', + tenant=tenant) - # Add net_1 to router_1 - openstack.add_subnet_to_router( - admin, - router_1['id'], subnet['id']) + self.show_step(4) + admin.add_router_interface( + router_id=router_1["id"], + subnet_id=subnet["id"]) access_point, access_point_ip = openstack.create_access_point( os_conn=admin, nics=[{'net-id': network['id']}], security_groups=[security_group.name, default_sg['name']]) - logger.info("""Launch instances with image TestVM and flavor - m1.micro in nova az. - Launch instances with image TestVM-VMDK and - flavor m1.micro in vcenter az.""") - + self.show_step(5) + self.show_step(6) openstack.create_instances( os_conn=admin, nics=[{'net-id': network['id']}], vm_count=1, @@ -1301,13 +1293,10 @@ class TestDVSPlugin(TestBasic): if instance.id != access_point.id] ips = [] for instance in instances: - ips.append([add['addr'] - for add - in instance.addresses[instance.addresses.keys()[0]] - if add['OS-EXT-IPS:type'] == 'fixed'][0]) + ips.append(admin.get_nova_instance_ip( + instance, net_name=network['name'])) - logger.info("""Send ping from instances to 8.8.8.8 - or other outside ip.""") + self.show_step(7) ip_2 = '8.8.8.8' for ip in ips: ping_result = openstack.remote_execute_command( @@ -1315,4 +1304,182 @@ class TestDVSPlugin(TestBasic): assert_true( ping_result['exit_code'] == 0, "Ping isn't available from {0} to {1}".format(ip, ip_2) + ) + + @test(depends_on=[dvs_vcenter_systest_setup], + groups=["dvs_different_networks"]) + @log_snapshot_after_test + def dvs_different_networks(self): + """Check connectivity between instances from different networks. + + Scenario: + 1. Revert snapshot to dvs_vcenter_systest_setup. + 2. Create private networks net01 and net02 with subnets. + 3. Create Router_01, set gateway and add interface to + external network. + 4. Create Router_02, set gateway and add interface to + external network. + 5. Attach private networks to Router_01. + 6. Attach private networks to Router_02. + 7. Launch instances in the net01 + with image TestVM and flavor m1.micro in nova az. + 8. Launch instances in the net01 + with image TestVM-VMDK and flavor m1.micro in vcenter az. + 9. Launch instances in the net02 + with image TestVM and flavor m1.micro in nova az. + 10. Launch instances in the net02 + with image TestVM-VMDK and flavor m1.micro in vcenter az. + 11. Verify that instances of same networks should communicate + between each other via private ip. + Send icmp ping between instances. + 12. Verify that instances of different networks should not + communicate between each other via private ip. + 13. Delete net_02 from Router_02 and add it to the Router_01. + 14. Verify that instances of different networks should communicate + between each other via private ip. + Send icmp ping between instances. + + Duration: 15 min + + """ + self.show_step(1) + self.env.revert_snapshot("dvs_vcenter_systest_setup") + + cluster_id = self.fuel_web.get_last_created_cluster() + + os_ip = self.fuel_web.get_public_vip(cluster_id) + admin = os_actions.OpenStackActions( + os_ip, SERVTEST_USERNAME, + SERVTEST_PASSWORD, + SERVTEST_TENANT) + + tenant = admin.get_tenant(SERVTEST_TENANT) + + # create security group with rules for ssh and ping + security_group = admin.create_sec_group_for_ssh() + + default_sg = [ + sg + for sg in admin.neutron.list_security_groups()['security_groups'] + if sg['tenant_id'] == admin.get_tenant(SERVTEST_TENANT).id + if sg['name'] == 'default'][0] + + instances_group = [] + networks = [] + map_router_subnet = [] + step = 2 + self.show_step(step) + for net in self.net_data: + network = admin.create_network( + network_name=net.keys()[0], + tenant_id=tenant.id)['network'] + + logger.info('Create subnet {}'.format(net.keys()[0])) + subnet = admin.create_subnet( + subnet_name=net.keys()[0], + network_id=network['id'], + cidr=net[net.keys()[0]], + ip_version=4) + + # Check that network are created. + assert_true( + admin.get_network(network['name'])['id'] == network['id'] + ) + self.show_step(step + 1) + router = admin.create_router( + 'router_0{}'.format(self.net_data.index(net) + 1), + tenant=tenant) + + self.show_step(step + 3) + admin.add_router_interface( + router_id=router["id"], + subnet_id=subnet["id"]) + + access_point, access_point_ip = openstack.create_access_point( + admin, [{'net-id': network['id']}], + [security_group.name, default_sg['name']]) + if step == 3: + step += 1 + self.show_step(step + 5) + self.show_step(step + 6) + openstack.create_instances( + os_conn=admin, nics=[{'net-id': network['id']}], + vm_count=1, + security_groups=[default_sg['name']]) + openstack.verify_instance_state(admin) + + instances = [ + instance for instance in admin.get_servers() + if network['name'] == instance.networks.keys()[0] + if instance.id != access_point.id] + + private_ips = [] + for instance in instances: + private_ips.append(admin.get_nova_instance_ip( + instance, net_name=network['name'])) + + instances_group.append( + {'access_point': access_point, + 'access_point_ip': access_point_ip, + 'private_ips': private_ips} + ) + + networks.append(network) + map_router_subnet.append( + {'subnet': subnet['id'], 'router': router['id']}) + step = 3 + self.show_step(11) + + for group in instances_group: + for ip in group['private_ips']: + for ip_2 in group['private_ips']: + if ip_2 != ip: + ping_result = openstack.remote_execute_command( + group['access_point_ip'], + ip, "ping -c 5 {}".format(ip_2)) + assert_true( + ping_result['exit_code'] == 0, + "Ping isn't available from {0} to {1}".format( + ip, ip_2) + ) + + self.show_step(12) + for ip in instances_group[0]['private_ips']: + for ip_2 in instances_group[1]['private_ips']: + ping_result = openstack.remote_execute_command( + instances_group[0]['access_point_ip'], + ip, "ping -c 5 {}".format(ip_2)) + assert_true( + ping_result['exit_code'] == 1, + "Ping isn't available from {0} to {1}".format(ip, ip_2) + ) + + self.show_step(13) + + access_point_fip = instances_group[1]['access_point_ip'] + fip_id = [ + fip['id'] + for fip in admin.neutron.list_floatingips()['floatingips'] + if fip['floating_ip_address'] == access_point_fip][0] + + admin.neutron.delete_floatingip(fip_id) + + admin.neutron.remove_interface_router( + map_router_subnet[1]['router'], + {"subnet_id": map_router_subnet[1]['subnet']}) + + openstack.add_subnet_to_router( + admin, + map_router_subnet[0]['router'], + map_router_subnet[1]['subnet']) + time.sleep(20) # need wait to port state update + self.show_step(14) + for ip in instances_group[1]['private_ips']: + for ip_2 in instances_group[0]['private_ips']: + ping_result = openstack.remote_execute_command( + instances_group[0]['access_point_ip'], + ip, "ping -c 5 {}".format(ip_2)) + assert_true( + ping_result['exit_code'] == 0, + "Ping isn't available from {0} to {1}".format(ip, ip_2) ) diff --git a/plugin_test/tests/test_plugin_vmware_dvs_templates.py b/plugin_test/tests/test_plugin_vmware_dvs_templates.py index 69e1255..c0d4271 100644 --- a/plugin_test/tests/test_plugin_vmware_dvs_templates.py +++ b/plugin_test/tests/test_plugin_vmware_dvs_templates.py @@ -1,41 +1,52 @@ -# Copyright 2014 Mirantis, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +"""Copyright 2016 Mirantis, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); you may +not use this file except in compliance with the License. You may obtain +copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations +under the License. +""" + import os -import yaml + +from fuelweb_test import logger + +from fuelweb_test.helpers.decorators import log_snapshot_after_test + +from fuelweb_test.settings import DEPLOYMENT_MODE +from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE + +from fuelweb_test.tests.base_test_case import SetupEnvironment +from fuelweb_test.tests.base_test_case import TestBasic + +from fuelweb_test.tests.test_net_templates_base import TestNetworkTemplatesBase + +from helpers import plugin from proboscis import test -from fuelweb_test import logger -from fuelweb_test.helpers.decorators import log_snapshot_after_test -from fuelweb_test.settings import DEPLOYMENT_MODE -from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE -from fuelweb_test.tests.base_test_case import SetupEnvironment -from fuelweb_test.tests.test_net_templates_base import TestNetworkTemplatesBase -from fuelweb_test.tests.base_test_case import TestBasic - -from helpers import plugin +import yaml @test(groups=["dvs_vcenter_net_template"]) class TestNetworkTemplates(TestNetworkTemplatesBase, TestBasic): - """TestNetworkTemplates.""" # TODO documentation + """TestNetworkTemplates.""" - # constants - node_name = lambda self, name_node: self.fuel_web. \ - get_nailgun_node_by_name(name_node)['hostname'] + def node_name(self, name_node): + """Get node by name.""" + return self.fuel_web.get_nailgun_node_by_name(name_node)['hostname'] def get_network_template(self, template_name): + """Get netwok template. + + param: template_name: type string, name of file + """ template = 'plugin_test/templates/{0}.yaml'.format(template_name) logger.info('{0}'.format(template)) if os.path.exists(template): @@ -46,7 +57,7 @@ class TestNetworkTemplates(TestNetworkTemplatesBase, TestBasic): groups=["dvs_vcenter_net_template"]) @log_snapshot_after_test def dvs_vcenter_net_template(self): - """Deploy cluster with DVS plugin, Neutron, Ceph and network template + """Deploy cluster with DVS plugin, Neutron, Ceph and network template. Scenario: 1. Upload plugins to the master node. @@ -69,7 +80,6 @@ class TestNetworkTemplates(TestNetworkTemplatesBase, TestBasic): Duration 180m Snapshot deploy_cinder_net_tmpl """ - self.env.revert_snapshot("ready_with_9_slaves") plugin.install_dvs_plugin(