From 720f40f41817d4e3b5fce2edd6fd5779dd9ac0f5 Mon Sep 17 00:00:00 2001 From: Artem Panchenko Date: Fri, 3 Jul 2015 18:44:41 +0300 Subject: [PATCH] Add test cases with network templates Add two tests with network templates: * multiroles (controller/compute + cinder) and network template with almost default configuration (only interfaces mapping is changed); * multiroles (controller/compute + ceph) and network template with changed network roles assignment ('ceph/public', 'mgmt/memcache' and 'mgmt/database' roles are moved to 'storage' network) and bonding. Related blueprint templates-for-networking Change-Id: If8fcabde52755f69a848051ebc2e2812851a08db --- fuelweb_test/helpers/http.py | 1 - fuelweb_test/helpers/utils.py | 10 + fuelweb_test/models/fuel_web_client.py | 5 +- fuelweb_test/models/nailgun_client.py | 36 +++ fuelweb_test/network_templates/ceph.yaml | 327 +++++++++++++++++++ fuelweb_test/network_templates/cinder.yaml | 315 ++++++++++++++++++ fuelweb_test/network_templates/default.yaml | 136 ++++++++ fuelweb_test/run_tests.py | 1 + fuelweb_test/tests/test_net_templates.py | 338 ++++++++++++++++++++ 9 files changed, 1166 insertions(+), 3 deletions(-) create mode 100644 fuelweb_test/network_templates/ceph.yaml create mode 100644 fuelweb_test/network_templates/cinder.yaml create mode 100644 fuelweb_test/network_templates/default.yaml create mode 100644 fuelweb_test/tests/test_net_templates.py diff --git a/fuelweb_test/helpers/http.py b/fuelweb_test/helpers/http.py index a6d4ef43d..ecb7ed569 100644 --- a/fuelweb_test/helpers/http.py +++ b/fuelweb_test/helpers/http.py @@ -70,7 +70,6 @@ class HTTPClient(object): def post(self, endpoint, data=None, content_type="application/json"): if not data: data = {} - logger.info('self url is %s' % self.url) req = urllib2.Request(self.url + endpoint, data=json.dumps(data)) req.add_header('Content-Type', content_type) return self._open(req) diff --git a/fuelweb_test/helpers/utils.py b/fuelweb_test/helpers/utils.py index 6670ff19a..2db16ee12 100644 --- a/fuelweb_test/helpers/utils.py +++ b/fuelweb_test/helpers/utils.py @@ -369,3 +369,13 @@ def check_distribution(): settings.OPENSTACK_RELEASE)) logger.error(error_msg) raise Exception(error_msg) + + +@logwrap +def get_network_template(template_name): + templates_path = ('{0}/fuelweb_test/network_templates/'.format( + os.environ.get("WORKSPACE", "./"))) + template = os.path.join(templates_path, '{}.yaml'.format(template_name)) + if os.path.exists(template): + with open(template) as template_file: + return yaml.load(template_file) diff --git a/fuelweb_test/models/fuel_web_client.py b/fuelweb_test/models/fuel_web_client.py index 1ae829884..22564026a 100644 --- a/fuelweb_test/models/fuel_web_client.py +++ b/fuelweb_test/models/fuel_web_client.py @@ -1125,7 +1125,8 @@ class FuelWebClient(object): @logwrap def update_nodes(self, cluster_id, nodes_dict, pending_addition=True, pending_deletion=False, - update_nodegroups=False, custom_names=None): + update_nodegroups=False, custom_names=None, + update_interfaces=True): # update nodes in cluster nodes_data = [] @@ -1180,7 +1181,7 @@ class FuelWebClient(object): assert_true( all([node_id in cluster_node_ids for node_id in node_ids])) - if not pending_deletion: + if update_interfaces and not pending_deletion: self.update_nodes_interfaces(cluster_id, updated_nodes) if update_nodegroups: self.update_nodegroups(cluster_id=cluster_id, diff --git a/fuelweb_test/models/nailgun_client.py b/fuelweb_test/models/nailgun_client.py index c37e3e200..7c8810977 100644 --- a/fuelweb_test/models/nailgun_client.py +++ b/fuelweb_test/models/nailgun_client.py @@ -452,3 +452,39 @@ class NailgunClient(object): """ Set a new hostname for the node""" data = dict(hostname=new_hostname) return self.client.put('/api/nodes/{0}/'.format(node_id), data) + + @logwrap + @json_parse + def get_network_template(self, cluster_id): + return self.client.get( + '/api/clusters/{}/network_configuration/template'.format( + cluster_id)) + + @logwrap + @json_parse + def upload_network_template(self, cluster_id, network_template): + return self.client.put( + '/api/clusters/{}/network_configuration/template'.format( + cluster_id), network_template) + + @logwrap + @json_parse + def delete_network_template(self, cluster_id): + return self.client.delete( + '/api/clusters/{}/network_configuration/template'.format( + cluster_id)) + + @logwrap + @json_parse + def get_network_groups(self): + return self.client.get('/api/networks/') + + @logwrap + @json_parse + def get_network_group(self, network_id): + return self.client.get('/api/networks/{0}/'.format(network_id)) + + @logwrap + @json_parse + def add_network_group(self, network_data): + return self.client.post('/api/networks/', data=network_data) diff --git a/fuelweb_test/network_templates/ceph.yaml b/fuelweb_test/network_templates/ceph.yaml new file mode 100644 index 000000000..6ffcfe7d0 --- /dev/null +++ b/fuelweb_test/network_templates/ceph.yaml @@ -0,0 +1,327 @@ +adv_net_template: + default: + nic_mapping: + default: + if1: eth0 # admin + if2: eth1 # public + if3: eth3 # management (vlan 101) storage (vlan 102) & private (vlan 103) + if4: eth4 # other networks (vlan 201-299) + if5: eth2 # fake bond + templates_for_node_role: + controller: + - public + - private + - storage + - common + - custom + compute: + - common + - private + - storage + - custom + ceph-osd: + - common + - storage + - custom + network_assignments: + storage: + ep: br-storage + private: + ep: br-prv + public: + ep: br-ex + management: + ep: br-mgmt + fuelweb_admin: + ep: br-fw-admin + fake: + ep: br-fake + mongo: + ep: br-mongo + keystone: + ep: br-keystone + neutron-api: + ep: br-neutronapi + neutron-mesh: + ep: br-neutronmesh + swift: + ep: br-swift + sahara: + ep: br-sahara + ceilometer: + ep: br-ceilometer + cinder: + ep: br-cinder + glance: + ep: br-glance + heat: + ep: br-heat + nova: + ep: br-nova + nova-migration: + ep: br-novamigr + murano: + ep: br-murano + horizon: + ep: br-horizon + messaging: + ep: br-messaging + corosync: + ep: br-corosync + memcache: + ep: br-memcache + database: + ep: br-database + cinder-iscsi: + ep: br-cinderiscsi + swift-replication: + ep: br-swiftrepl + ceph-replication: + ep: br-cephrepl + ceph-radosgw: + ep: br-cephrados + network_scheme: + storage: + transformations: + - action: add-br + name: br-storage + - action: add-port + bridge: br-storage + name: <% if3 %>.102 + endpoints: + - br-storage + roles: + storage: br-storage + ceph/public: br-storage + private: + transformations: + - action: add-br + name: br-prv + provider: ovs + - action: add-br + name: br-aux + - action: add-patch + bridges: + - br-prv + - br-aux + provider: ovs + mtu: 65000 + - action: add-port + bridge: br-aux + name: <% if3 %>.103 + endpoints: + - br-prv + roles: + neutron/private: br-prv + public: + transformations: + - action: add-br + name: br-ex + - action: add-br + name: br-floating + provider: ovs + - action: add-patch + bridges: + - br-floating + - br-ex + provider: ovs + mtu: 65000 + - action: add-port + bridge: br-ex + name: <% if2 %> + endpoints: + - br-ex + roles: + public/vip: br-ex + neutron/floating: br-floating + ex: br-ex + common: + transformations: + - action: add-br + name: br-fw-admin + - action: add-port + bridge: br-fw-admin + name: <% if1 %> + - action: add-br + name: br-mgmt + - action: add-port + bridge: br-mgmt + name: <% if3 %>.101 + - action: add-br + name: br-fake + - action: add-bond + bridge: br-fake + name: lnx-bond0 + interfaces: + - <% if5 %> + bond_properties: + mode: active-backup + interface_properties: {} + endpoints: + - br-fw-admin + - br-mgmt + - br-fake + roles: + admin/pxe: br-fw-admin + fw-admin: br-fw-admin + management: br-mgmt + mgmt/vip: br-mgmt + mgmt/api: br-mgmt + custom: + transformations: + - action: add-br + name: br-mongo + - action: add-port + bridge: br-mongo + name: <% if4 %>.201 + - action: add-br + name: br-keystone + - action: add-port + bridge: br-keystone + name: <% if4 %>.202 + - action: add-br + name: br-neutronapi + - action: add-port + bridge: br-neutronapi + name: <% if4 %>.203 + - action: add-br + name: br-neutronmesh + - action: add-port + bridge: br-neutronmesh + name: <% if4 %>.204 + - action: add-br + name: br-swift + - action: add-port + bridge: br-swift + name: <% if4 %>.205 + - action: add-br + name: br-sahara + - action: add-port + bridge: br-sahara + name: <% if4 %>.206 + - action: add-br + name: br-ceilometer + - action: add-port + bridge: br-ceilometer + name: <% if4 %>.207 + - action: add-br + name: br-cinder + - action: add-port + bridge: br-cinder + name: <% if4 %>.208 + - action: add-br + name: br-glance + - action: add-port + bridge: br-glance + name: <% if4 %>.209 + - action: add-br + name: br-heat + - action: add-port + bridge: br-heat + name: <% if4 %>.210 + - action: add-br + name: br-nova + - action: add-port + bridge: br-nova + name: <% if4 %>.211 + - action: add-br + name: br-novamigr + - action: add-port + bridge: br-novamigr + name: <% if4 %>.212 + - action: add-br + name: br-murano + - action: add-port + bridge: br-murano + name: <% if4 %>.213 + - action: add-br + name: br-horizon + - action: add-port + bridge: br-horizon + name: <% if4 %>.214 + - action: add-br + name: br-messaging + - action: add-port + bridge: br-messaging + name: <% if4 %>.215 + - action: add-br + name: br-corosync + - action: add-port + bridge: br-corosync + name: <% if4 %>.216 + - action: add-br + name: br-memcache + - action: add-port + bridge: br-memcache + name: <% if4 %>.217 + - action: add-br + name: br-database + - action: add-port + bridge: br-database + name: <% if4 %>.218 + - action: add-br + name: br-cinderiscsi + - action: add-port + bridge: br-cinderiscsi + name: <% if4 %>.219 + - action: add-br + name: br-swiftrepl + - action: add-port + bridge: br-swiftrepl + name: <% if4 %>.220 + - action: add-br + name: br-cephrepl + - action: add-port + bridge: br-cephrepl + name: <% if4 %>.221 + - action: add-br + name: br-cephrados + - action: add-port + bridge: br-cephrados + name: <% if4 %>.222 + endpoints: + - br-mongo + - br-keystone + - br-neutronapi + - br-neutronmesh + - br-swift + - br-sahara + - br-ceilometer + - br-cinder + - br-glance + - br-heat + - br-nova + - br-novamigr + - br-murano + - br-horizon + - br-messaging + - br-corosync + - br-memcache + - br-database + - br-cinderiscsi + - br-swiftrepl + - br-cephrepl + - br-cephrados + roles: + mongo/db: br-mongo + keystone/api: br-keystone + neutron/api: br-neutronapi + neutron/mesh: br-neutronmesh + swift/api: br-swift + sahara/api: br-sahara + ceilometer/api: br-ceilometer + cinder/api: br-cinder + glance/api: br-glance + heat/api: br-heat + nova/api: br-nova + nova/migration: br-novamigr + murano/api: br-murano + horizon: br-horizon + mgmt/messaging: br-messaging + mgmt/corosync: br-corosync + mgmt/memcache: br-memcache + mgmt/database: br-database + cinder/iscsi: br-cinderiscsi + swift/replication: br-swiftrepl + ceph/replication: br-cephrepl + ceph/radosgw: br-cephrados diff --git a/fuelweb_test/network_templates/cinder.yaml b/fuelweb_test/network_templates/cinder.yaml new file mode 100644 index 000000000..f4e0458a6 --- /dev/null +++ b/fuelweb_test/network_templates/cinder.yaml @@ -0,0 +1,315 @@ +adv_net_template: + default: + nic_mapping: + default: + if1: eth0 # admin + if2: eth1 # public + if3: eth3 # management (vlan 101) storage (vlan 102) & private (vlan 103) + if4: eth4 # other networks (vlan 201-299) + if5: eth2 # fake bond + templates_for_node_role: + controller: + - public + - private + - storage + - common + - custom + compute: + - common + - private + - storage + - custom + cinder: + - common + - storage + - custom + network_assignments: + storage: + ep: br-storage + private: + ep: br-prv + public: + ep: br-ex + management: + ep: br-mgmt + fuelweb_admin: + ep: br-fw-admin + fake: + ep: br-fake + mongo: + ep: br-mongo + keystone: + ep: br-keystone + neutron-api: + ep: br-neutronapi + neutron-mesh: + ep: br-neutronmesh + swift: + ep: br-swift + sahara: + ep: br-sahara + ceilometer: + ep: br-ceilometer + cinder: + ep: br-cinder + glance: + ep: br-glance + heat: + ep: br-heat + nova: + ep: br-nova + nova-migration: + ep: br-novamigr + murano: + ep: br-murano + horizon: + ep: br-horizon + messaging: + ep: br-messaging + corosync: + ep: br-corosync + memcache: + ep: br-memcache + database: + ep: br-database + cinder-iscsi: + ep: br-cinderiscsi + swift-replication: + ep: br-swiftrepl + ceph-replication: + ep: br-cephrepl + ceph-radosgw: + ep: br-cephrados + network_scheme: + storage: + transformations: + - action: add-br + name: br-storage + - action: add-port + bridge: br-storage + name: <% if3 %>.102 + endpoints: + - br-storage + roles: + storage: br-storage + ceph/public: br-storage + private: + transformations: + - action: add-br + name: br-prv + provider: ovs + - action: add-br + name: br-aux + - action: add-patch + bridges: + - br-prv + - br-aux + provider: ovs + mtu: 65000 + - action: add-port + bridge: br-aux + name: <% if3 %>.103 + endpoints: + - br-prv + roles: + neutron/private: br-prv + public: + transformations: + - action: add-br + name: br-ex + - action: add-br + name: br-floating + provider: ovs + - action: add-patch + bridges: + - br-floating + - br-ex + provider: ovs + mtu: 65000 + - action: add-port + bridge: br-ex + name: <% if2 %> + endpoints: + - br-ex + roles: + public/vip: br-ex + neutron/floating: br-floating + ex: br-ex + common: + transformations: + - action: add-br + name: br-fw-admin + - action: add-port + bridge: br-fw-admin + name: <% if1 %> + - action: add-br + name: br-mgmt + - action: add-port + bridge: br-mgmt + name: <% if3 %>.101 + - action: add-br + name: br-fake + - action: add-bond + bridge: br-fake + name: lnx-bond0 + interfaces: + - <% if5 %> + bond_properties: + mode: active-backup + interface_properties: {} + endpoints: + - br-fw-admin + - br-mgmt + - br-fake + roles: + admin/pxe: br-fw-admin + fw-admin: br-fw-admin + management: br-mgmt + mgmt/vip: br-mgmt + mgmt/api: br-mgmt + custom: + transformations: + - action: add-br + name: br-mongo + - action: add-port + bridge: br-mongo + name: <% if4 %>.201 + - action: add-br + name: br-keystone + - action: add-port + bridge: br-keystone + name: <% if4 %>.202 + - action: add-br + name: br-neutronapi + - action: add-port + bridge: br-neutronapi + name: <% if4 %>.203 + - action: add-br + name: br-neutronmesh + - action: add-port + bridge: br-neutronmesh + name: <% if4 %>.204 + - action: add-br + name: br-swift + - action: add-port + bridge: br-swift + name: <% if4 %>.205 + - action: add-br + name: br-sahara + - action: add-port + bridge: br-sahara + name: <% if4 %>.206 + - action: add-br + name: br-ceilometer + - action: add-port + bridge: br-ceilometer + name: <% if4 %>.207 + - action: add-br + name: br-cinder + - action: add-port + bridge: br-cinder + name: <% if4 %>.208 + - action: add-br + name: br-glance + - action: add-port + bridge: br-glance + name: <% if4 %>.209 + - action: add-br + name: br-heat + - action: add-port + bridge: br-heat + name: <% if4 %>.210 + - action: add-br + name: br-nova + - action: add-port + bridge: br-nova + name: <% if4 %>.211 + - action: add-br + name: br-novamigr + - action: add-port + bridge: br-novamigr + name: <% if4 %>.212 + - action: add-br + name: br-murano + - action: add-port + bridge: br-murano + name: <% if4 %>.213 + - action: add-br + name: br-horizon + - action: add-port + bridge: br-horizon + name: <% if4 %>.214 + - action: add-br + name: br-messaging + - action: add-port + bridge: br-messaging + name: <% if4 %>.215 + - action: add-br + name: br-corosync + - action: add-port + bridge: br-corosync + name: <% if4 %>.216 + - action: add-br + name: br-memcache + - action: add-port + bridge: br-memcache + name: <% if4 %>.217 + - action: add-br + name: br-database + - action: add-port + bridge: br-database + name: <% if4 %>.218 + - action: add-br + name: br-cinderiscsi + - action: add-port + bridge: br-cinderiscsi + name: <% if4 %>.219 + - action: add-br + name: br-swiftrepl + - action: add-port + bridge: br-swiftrepl + name: <% if4 %>.220 + endpoints: + - br-mongo + - br-keystone + - br-neutronapi + - br-neutronmesh + - br-swift + - br-sahara + - br-ceilometer + - br-cinder + - br-glance + - br-heat + - br-nova + - br-novamigr + - br-murano + - br-horizon + - br-messaging + - br-corosync + - br-memcache + - br-database + - br-cinderiscsi + - br-swiftrepl + roles: + mongo/db: br-mongo + keystone/api: br-keystone + neutron/api: br-neutronapi + neutron/mesh: br-neutronmesh + swift/api: br-swift + sahara/api: br-sahara + ceilometer/api: br-ceilometer + cinder/api: br-cinder + glance/api: br-glance + heat/api: br-heat + nova/api: br-nova + nova/migration: br-novamigr + murano/api: br-murano + horizon: br-horizon + mgmt/messaging: br-messaging + mgmt/corosync: br-corosync + mgmt/memcache: br-memcache + mgmt/database: br-database + cinder/iscsi: br-cinderiscsi + swift/replication: br-swiftrepl + ceph/replication: br-cephrepl + ceph/radosgw: br-cephrados \ No newline at end of file diff --git a/fuelweb_test/network_templates/default.yaml b/fuelweb_test/network_templates/default.yaml new file mode 100644 index 000000000..90699c99a --- /dev/null +++ b/fuelweb_test/network_templates/default.yaml @@ -0,0 +1,136 @@ +adv_net_template: + default: + nic_mapping: + default: + if1: eth0 # admin + if2: eth1 # public + if3: eth4 # management + if4: eth2 # private + if5: eth3 # storage + templates_for_node_role: + controller: + - public + - private + - storage + - common + compute: + - common + - private + - storage + cinder: + - common + - storage + ceph-osd: + - common + - storage + network_assignments: + storage: + ep: br-storage + private: + ep: br-prv + public: + ep: br-ex + management: + ep: br-mgmt + fuelweb_admin: + ep: br-fw-admin + network_scheme: + storage: + transformations: + - action: add-br + name: br-storage + - action: add-port + bridge: br-storage + name: <% if5 %> + endpoints: + - br-storage + roles: + cinder/iscsi: br-storage + swift/replication: br-storage + ceph/replication: br-storage + storage: br-storage + private: + transformations: + - action: add-br + name: br-prv + provider: ovs + - action: add-br + name: br-aux + - action: add-patch + bridges: + - br-prv + - br-aux + provider: ovs + mtu: 65000 + - action: add-port + bridge: br-aux + name: <% if4 %> + endpoints: + - br-prv + roles: + neutron/private: br-prv + public: + transformations: + - action: add-br + name: br-ex + - action: add-br + name: br-floating + provider: ovs + - action: add-patch + bridges: + - br-floating + - br-ex + provider: ovs + mtu: 65000 + - action: add-port + bridge: br-ex + name: <% if2 %> + endpoints: + - br-ex + roles: + public/vip: br-ex + neutron/floating: br-floating + ceph/radosgw: br-ex + ex: br-ex + common: + transformations: + - action: add-br + name: br-fw-admin + - action: add-port + bridge: br-fw-admin + name: <% if1 %> + - action: add-br + name: br-mgmt + - action: add-port + bridge: br-mgmt + name: <% if3 %> + endpoints: + - br-fw-admin + - br-mgmt + roles: + admin/pxe: br-fw-admin + fw-admin: br-fw-admin + mongo/db: br-mgmt + management: br-mgmt + keystone/api: br-mgmt + neutron/api: br-mgmt + neutron/mesh: br-mgmt + swift/api: br-mgmt + sahara/api: br-mgmt + ceilometer/api: br-mgmt + cinder/api: br-mgmt + glance/api: br-mgmt + heat/api: br-mgmt + nova/api: br-mgmt + nova/migration: br-mgmt + murano/api: br-mgmt + horizon: br-mgmt + mgmt/api: br-mgmt + mgmt/memcache: br-mgmt + mgmt/database: br-mgmt + mgmt/messaging: br-mgmt + mgmt/corosync: br-mgmt + mgmt/vip: br-mgmt + mgmt/api: br-mgmt + ceph/public: br-mgmt + diff --git a/fuelweb_test/run_tests.py b/fuelweb_test/run_tests.py index 5862dc7a6..cc2778feb 100644 --- a/fuelweb_test/run_tests.py +++ b/fuelweb_test/run_tests.py @@ -91,6 +91,7 @@ def import_tests(): from tests import test_jumbo_frames # noqa from tests import test_node_reinstallation # noqa from tests import test_ubuntu_bootstrap # noqa + from tests import test_net_templates # noqa def run_tests(): diff --git a/fuelweb_test/tests/test_net_templates.py b/fuelweb_test/tests/test_net_templates.py new file mode 100644 index 000000000..d3021f9b1 --- /dev/null +++ b/fuelweb_test/tests/test_net_templates.py @@ -0,0 +1,338 @@ +# 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. + +from copy import deepcopy + +from ipaddr import IPAddress +from ipaddr import IPNetwork +from proboscis import test +from proboscis.asserts import assert_equal +from proboscis.asserts import assert_true + +from fuelweb_test import logger +from fuelweb_test.helpers.decorators import log_snapshot_after_test +from fuelweb_test.helpers.utils import get_network_template +from fuelweb_test.settings import DEPLOYMENT_MODE_HA +from fuelweb_test.settings import NEUTRON_SEGMENT +from fuelweb_test.settings import NEUTRON_SEGMENT_TYPE +from fuelweb_test.tests.base_test_case import TestBasic +from fuelweb_test.tests.base_test_case import SetupEnvironment + + +@test(groups=["network_templates"]) +class TestNetworkTemplates(TestBasic): + """TestNetworkTemplates.""" # TODO documentation + def __init__(self): + self.fake_network = { + 'name': 'fake', + 'group_id': 1, + 'cidr': '10.110.0.0/24', + 'gateway': None, + "meta": { + "notation": "ip_ranges", + "render_type": None, + "map_priority": 0, + "configurable": True, + "unmovable": False, + "use_gateway": False, + "render_addr_mask": None, + "ip_range": ['10.110.0.1', '10.110.0.254'] + } + } + self.custom_networks = [ + { + 'name': 'mongo', + 'cidr': '10.200.1.0/24', + 'meta': {'ip_range': ['10.200.1.1', '10.200.1.254']} + }, + { + 'name': 'keystone', + 'cidr': '10.200.2.0/24', + 'meta': {'ip_range': ['10.200.2.1', '10.200.2.254']} + }, + { + 'name': 'neutron-api', + 'cidr': '10.200.3.0/24', + 'meta': {'ip_range': ['10.200.3.1', '10.200.3.254']} + }, + { + 'name': 'neutron-mesh', + 'cidr': '10.200.4.0/24', + 'meta': {'ip_range': ['10.200.4.1', '10.200.4.254']} + }, + { + 'name': 'swift', + 'cidr': '10.200.5.0/24', + 'meta': {'ip_range': ['10.200.5.1', '10.200.5.254']} + }, + { + 'name': 'sahara', + 'cidr': '10.200.6.0/24', + 'meta': {'ip_range': ['10.200.6.1', '10.200.6.254']} + }, + { + 'name': 'ceilometer', + 'cidr': '10.200.7.0/24', + 'meta': {'ip_range': ['10.200.7.1', '10.200.7.254']} + }, + { + 'name': 'cinder', + 'cidr': '10.200.8.0/24', + 'meta': {'ip_range': ['10.200.8.1', '10.200.8.254']} + }, + { + 'name': 'glance', + 'cidr': '10.200.9.0/24', + 'meta': {'ip_range': ['10.200.9.1', '10.200.9.254']} + }, + { + 'name': 'heat', + 'cidr': '10.200.10.0/24', + 'meta': {'ip_range': ['10.200.10.1', '10.200.10.254']} + }, + { + 'name': 'nova', + 'cidr': '10.200.11.0/24', + 'meta': {'ip_range': ['10.200.11.1', '10.200.11.254']} + }, + { + 'name': 'nova-migration', + 'cidr': '10.200.12.0/24', + 'meta': {'ip_range': ['10.200.12.1', '10.200.12.254']} + }, + { + 'name': 'murano', + 'cidr': '10.200.13.0/24', + 'meta': {'ip_range': ['10.200.13.1', '10.200.13.254']} + }, + { + 'name': 'horizon', + 'cidr': '10.200.14.0/24', + 'meta': {'ip_range': ['10.200.14.1', '10.200.14.254']} + }, + { + 'name': 'messaging', + 'cidr': '10.200.15.0/24', + 'meta': {'ip_range': ['10.200.15.1', '10.200.15.254']} + }, + { + 'name': 'corosync', + 'cidr': '10.200.16.0/24', + 'meta': {'ip_range': ['10.200.16.1', '10.200.16.254']} + }, + { + 'name': 'memcache', + 'cidr': '10.200.17.0/24', + 'meta': {'ip_range': ['10.200.17.1', '10.200.17.254']} + }, + { + 'name': 'database', + 'cidr': '10.200.18.0/24', + 'meta': {'ip_range': ['10.200.18.1', '10.200.18.254']} + }, + { + 'name': 'cinder-iscsi', + 'cidr': '10.200.19.0/24', + 'meta': {'ip_range': ['10.200.19.1', '10.200.19.254']} + }, + { + 'name': 'swift-replication', + 'cidr': '10.200.20.0/24', + 'meta': {'ip_range': ['10.200.20.1', '10.200.20.254']} + }, + { + 'name': 'ceph-replication', + 'cidr': '10.200.21.0/24', + 'meta': {'ip_range': ['10.200.21.1', '10.200.21.254']} + }, + { + 'name': 'ceph-radosgw', + 'cidr': '10.200.22.0/24', + 'meta': {'ip_range': ['10.200.22.1', '10.200.22.254']} + }, + ] + super(TestNetworkTemplates, self).__init__() + + def check_interface_exists(self, remote, iface_name, cidr): + cmd = ("set -o pipefail; " + "ip -o -4 address show dev {0} | sed -rn " + "'s/^.*\sinet\s+([0-9\.]+\/[0-9]{{1,2}})\s.*$/\\1/p'").format( + iface_name) + result = remote.execute(cmd) + logger.debug("Checking interface IP result: {0}".format(result)) + assert_equal(result['exit_code'], 0, + "Device {0} not found on remote node!".format(iface_name)) + raw_addr = ''.join([line.strip() for line in result['stdout']]) + raw_ip = raw_addr.split('/')[0] + try: + ip = IPAddress(raw_ip) + except ValueError: + assert_equal(raw_ip, '0.0.0.0', + 'Device {0} on remote node does not have a valid ' + 'IPv4 address assigned!'.format(iface_name)) + actual_network = IPNetwork(raw_addr) + network = IPNetwork(cidr) + assert_equal(actual_network, network, + 'Network on {0} device differs than {1}: {2}'.format( + iface_name, cidr, raw_addr)) + assert_true(ip in network, + 'IP address on {0} device is not from {1} network!'.format( + iface_name, cidr)) + + @test(depends_on=[SetupEnvironment.prepare_slaves_5], + groups=["deploy_cinder_net_tmpl"]) + @log_snapshot_after_test + def deploy_cinder_net_tmpl(self): + """Deploy HA environment with Neutron and network template + + Scenario: + 1. Revert snapshot with 5 slaves + 2. Create cluster (HA) with Neutron VLAN/VXLAN/GRE + 3. Add 3 controller + cinder nodes + 4. Add 2 compute + cinder nodes + 5. Upload 'cinder' network template' + 6. Deploy cluster + 7. Run health checks (OSTF) + + Duration 110m + Snapshot deploy_cinder_net_tmpl + """ + + self.env.revert_snapshot("ready_with_5_slaves") + + cluster_id = self.fuel_web.create_cluster( + name=self.__class__.__name__, + mode=DEPLOYMENT_MODE_HA, + settings={ + "net_provider": 'neutron', + "net_segment_type": NEUTRON_SEGMENT[NEUTRON_SEGMENT_TYPE], + 'tenant': 'netTemplate', + 'user': 'netTemplate', + 'password': 'netTemplate', + } + ) + + self.fuel_web.update_nodes( + cluster_id, + { + 'slave-01': ['controller', 'cinder'], + 'slave-02': ['controller', 'cinder'], + 'slave-03': ['controller', 'cinder'], + 'slave-04': ['compute', 'cinder'], + 'slave-05': ['compute', 'cinder'], + }, + update_interfaces=False + ) + + network_template = get_network_template('cinder') + self.fuel_web.client.upload_network_template( + cluster_id=cluster_id, network_template=network_template) + self.fuel_web.client.add_network_group(network_data=self.fake_network) + for custom_network in self.custom_networks: + network = dict() + network.update(deepcopy(self.fake_network)) + network.update(deepcopy(custom_network)) + network['meta'].update(deepcopy(self.fake_network['meta'])) + network['meta'].update(deepcopy(custom_network['meta'])) + self.fuel_web.client.add_network_group(network_data=network) + logger.debug('Networks: {0}'.format( + self.fuel_web.client.get_network_groups())) + self.fuel_web.deploy_cluster_wait(cluster_id) + # (TODO): Network verification should be enabled after templates + # (TODO): support is added to the network checker + # self.fuel_web.verify_network(cluster_id) + for node in self.fuel_web.client.list_cluster_nodes(cluster_id): + with self.env.d_env.get_ssh_to_remote(node['ip']) as remote: + self.check_interface_exists(remote, 'br-fake', + self.fake_network['cidr']) + self.fuel_web.run_ostf(cluster_id=cluster_id, + test_sets=['smoke', 'sanity', + 'ha', 'tests_platform']) + self.env.make_snapshot("deploy_cinder_net_tmpl") + + @test(depends_on=[SetupEnvironment.prepare_slaves_5], + groups=["deploy_ceph_net_tmpl"]) + @log_snapshot_after_test + def deploy_ceph_net_tmpl(self): + """Deploy HA environment with Ceph, Neutron and network template + + Scenario: + 1. Revert snapshot with 5 slaves + 2. Create cluster (HA) with Neutron VLAN/VXLAN/GRE + 3. Add 3 controller + ceph nodes + 4. Add 2 compute + ceph nodes + 5. Upload 'ceph' network template + 6. Deploy cluster + 7. Run health checks (OSTF) + + Duration 110m + Snapshot deploy_ceph_net_tmpl + """ + + self.env.revert_snapshot("ready_with_5_slaves") + + cluster_id = self.fuel_web.create_cluster( + name=self.__class__.__name__, + mode=DEPLOYMENT_MODE_HA, + settings={ + 'volumes_ceph': True, + 'images_ceph': True, + 'volumes_lvm': False, + 'ephemeral_ceph': True, + 'objects_ceph': True, + 'net_provider': 'neutron', + 'net_segment_type': NEUTRON_SEGMENT[NEUTRON_SEGMENT_TYPE], + 'tenant': 'netTemplate', + 'user': 'netTemplate', + 'password': 'netTemplate', + } + ) + + self.fuel_web.update_nodes( + cluster_id, + { + 'slave-01': ['controller', 'ceph-osd'], + 'slave-02': ['controller', 'ceph-osd'], + 'slave-03': ['controller', 'ceph-osd'], + 'slave-04': ['compute', 'ceph-osd'], + 'slave-05': ['compute', 'ceph-osd'], + }, + update_interfaces=False + ) + + network_template = get_network_template('ceph') + self.fuel_web.client.upload_network_template( + cluster_id=cluster_id, network_template=network_template) + self.fuel_web.client.add_network_group(network_data=self.fake_network) + for custom_network in self.custom_networks: + network = dict() + network.update(deepcopy(self.fake_network)) + network.update(deepcopy(custom_network)) + network['meta'].update(deepcopy(self.fake_network['meta'])) + network['meta'].update(deepcopy(custom_network['meta'])) + self.fuel_web.client.add_network_group(network_data=network) + logger.debug('Networks: {0}'.format( + self.fuel_web.client.get_network_groups())) + self.fuel_web.deploy_cluster_wait(cluster_id) + # (TODO): Network verification should be enabled after templates + # (TODO): support is added to the network checker + # self.fuel_web.verify_network(cluster_id) + for node in self.fuel_web.client.list_cluster_nodes(cluster_id): + with self.env.d_env.get_ssh_to_remote(node['ip']) as remote: + self.check_interface_exists(remote, 'br-fake', + self.fake_network['cidr']) + self.fuel_web.run_ostf(cluster_id=cluster_id, + test_sets=['smoke', 'sanity', + 'ha', 'tests_platform']) + self.env.make_snapshot("deploy_ceph_net_tmpl")