diff --git a/doc/base_tests.rst b/doc/base_tests.rst index 943b4f7ea..d34586cb5 100644 --- a/doc/base_tests.rst +++ b/doc/base_tests.rst @@ -674,6 +674,11 @@ Test Data-Driven Upgrade .. automodule:: fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade :members: +Test Data-Driven Upgrade - Network templates +-------------------------------------------- +.. automodule:: fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade_net_tmpl + :members: + Upgrade Master tool ------------------- .. automodule:: fuelweb_test.tests.tests_upgrade.upgrader_tool diff --git a/fuelweb_test/network_templates/upgrades.yaml b/fuelweb_test/network_templates/upgrades.yaml new file mode 100644 index 000000000..e06677941 --- /dev/null +++ b/fuelweb_test/network_templates/upgrades.yaml @@ -0,0 +1,313 @@ +adv_net_template: + default: + nic_mapping: + default: + if1: enp0s3 # admin + if2: enp0s4 # public + if3: enp0s5 # management (vlan 101) storage (vlan 102) & private (vlan 103) + if4: enp0s6 # other networks (vlan 201-299) + 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 + 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 + endpoints: + - br-fw-admin + - br-mgmt + 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/tests/tests_upgrade/__init__.py b/fuelweb_test/tests/tests_upgrade/__init__.py index 84a271d63..6b4514888 100644 --- a/fuelweb_test/tests/tests_upgrade/__init__.py +++ b/fuelweb_test/tests/tests_upgrade/__init__.py @@ -12,5 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +# pylint: disable=line-too-long + from fuelweb_test.tests.tests_upgrade import test_data_driven_upgrade # noqa +from fuelweb_test.tests.tests_upgrade import test_data_driven_upgrade_net_tmpl # noqa from fuelweb_test.tests.tests_upgrade import upgrader_tool # noqa diff --git a/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py b/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py index 913e7a6f1..b35a31ec6 100644 --- a/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py +++ b/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_base.py @@ -43,7 +43,10 @@ class DataDrivenUpgradeBase(TestBasic): self.tarball_remote_dir = None self.backup_name = None self.repos_backup_name = None - + # pylint: disable=no-member + if hasattr(self.env, "reinstall_master_node"): + self.reinstall_master_node = self.env.reinstall_master_node + # pylint: enable=no-member self.__admin_remote = None @property diff --git a/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_net_tmpl.py b/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_net_tmpl.py new file mode 100644 index 000000000..dce893142 --- /dev/null +++ b/fuelweb_test/tests/tests_upgrade/test_data_driven_upgrade_net_tmpl.py @@ -0,0 +1,199 @@ +# 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 +# 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 os + +from proboscis import test +from proboscis.asserts import assert_not_equal, assert_true + +from fuelweb_test import logger +from fuelweb_test import settings +from fuelweb_test.helpers.decorators import log_snapshot_after_test +from fuelweb_test.helpers.utils import get_network_template +from fuelweb_test.tests.base_test_case import SetupEnvironment +from fuelweb_test.tests.test_net_templates_base import TestNetworkTemplatesBase +from fuelweb_test.tests.tests_upgrade.test_data_driven_upgrade_base import \ + DataDrivenUpgradeBase + + +@test +class TestUpgradeNetworkTemplates(TestNetworkTemplatesBase, + DataDrivenUpgradeBase): + """Test upgrade of master node with cluster deployed with net template.""" + + def __init__(self): + super(self.__class__, self).__init__() + self.backup_name = "backup_net_tmpl.tar.gz" + self.repos_backup_name = "repos_backup_net_tmpl.tar.gz" + self.source_snapshot_name = "upgrade_net_tmpl_backup" + self.backup_snapshot_name = self.source_snapshot_name + self.snapshot_name = "upgrade_net_tmpl_restore" + assert_not_equal( + settings.KEYSTONE_CREDS['password'], 'admin', + "Admin password was not changed, aborting execution") + + @test(depends_on=[SetupEnvironment.prepare_slaves_9], + groups=["upgrade_net_tmpl_backup"]) + @log_snapshot_after_test + def upgrade_net_tmpl_backup(self): + """Deploy HA environment with Ceph, Neutron and network template + + Scenario: + 1. Revert snapshot with 9 slaves + 2. Create cluster (HA) with Neutron VLAN/VXLAN/GRE + 3. Add 3 controller + ceph nodes + 4. Add 2 compute + ceph nodes + 5. Upload 'upgrades' network template + 6. Create custom network groups basing + on template endpoints assignments + 7. Run network verification + 8. Deploy cluster + 9. Run network verification + 10. Run health checks (OSTF) + 11. Check L3 network configuration on slaves + 12. Check that services are listening on their networks only + 13. Install fuel-octane package + 14. Create backups for upgrade procedure + + Duration 180m + Snapshot upgrade_net_tmpl_backup + """ + self.check_run(self.source_snapshot_name) + + intermediate_snapshot = "prepare_upgrade_tmpl_before_backup" + if not self.env.d_env.has_snapshot(intermediate_snapshot): + self.show_step(1) + self.env.revert_snapshot("ready_with_9_slaves") + self.show_step(2) + cluster_settings = { + 'volumes_ceph': True, 'images_ceph': True, + 'volumes_lvm': False, 'ephemeral_ceph': True, + 'objects_ceph': True, + 'net_provider': 'neutron', + 'net_segment_type': + settings.NEUTRON_SEGMENT[settings.NEUTRON_SEGMENT_TYPE]} + cluster_settings.update(self.cluster_creds) + + cluster_id = self.fuel_web.create_cluster( + name=self.__class__.__name__, + settings=cluster_settings) + + self.show_step(3) + self.show_step(4) + self.fuel_web.update_nodes( + cluster_id, + {'slave-01': ['controller'], + 'slave-02': ['controller'], + 'slave-03': ['controller'], + 'slave-04': ['ceph-osd'], + 'slave-05': ['ceph-osd'], + 'slave-06': ['ceph-osd'], + 'slave-07': ['compute'], + 'slave-08': ['compute']}, + update_interfaces=False) + + self.show_step(5) + network_template = get_network_template("upgrades") + self.fuel_web.client.upload_network_template( + cluster_id=cluster_id, network_template=network_template) + self.show_step(6) + # pylint: disable=redefined-variable-type + if settings.UPGRADE_FUEL_FROM == "7.0": + network = '10.200.0.0/16' + else: + network = {'default': '10.200.0.0/16'} + # pylint: enable=redefined-variable-type + networks = self.generate_networks_for_template( + network_template, network, '24') + existing_networks = self.fuel_web.client.get_network_groups() + networks = self.create_custom_networks(networks, existing_networks) + + logger.debug('Networks: {0}'.format( + self.fuel_web.client.get_network_groups())) + + self.show_step(7) + self.fuel_web.verify_network(cluster_id) + + self.show_step(8) + self.fuel_web.deploy_cluster_wait(cluster_id, timeout=180 * 60) + + self.show_step(9) + self.fuel_web.verify_network(cluster_id) + self.show_step(10) + # Live migration test could fail + # https://bugs.launchpad.net/fuel/+bug/1471172 + # https://bugs.launchpad.net/fuel/+bug/1604749 + self.fuel_web.run_ostf(cluster_id=cluster_id, + test_sets=['smoke', 'sanity', 'ha'], + should_fail=1) + self.show_step(11) + self.check_ipconfig_for_template(cluster_id, network_template, + networks) + + self.show_step(12) + self.check_services_networks(cluster_id, network_template) + + self.env.make_snapshot(intermediate_snapshot) + + # revert_snapshot will do nothing if there is no snapshot + self.env.revert_snapshot(intermediate_snapshot) + + self.show_step(13) + self.show_step(14) + self.do_backup(self.backup_path, self.local_path, + self.repos_backup_path, self.repos_local_path) + self.env.make_snapshot(self.source_snapshot_name, is_make=True) + + @test(groups=["upgrade_net_tmpl_restore"]) + def upgrade_net_tmpl_restore(self): + """Restore Fuel master - network templates + + Scenario: + 1. Revert "upgrade_net_tmpl_backup" snapshot + 2. Reinstall Fuel master using iso given in ISO_PATH + 3. Install fuel-octane package + 4. Upload the backup back to reinstalled Fuel maser node + 5. Restore master node using 'octane fuel-restore' + 6. Check that network template is still available + 7. Verify networks + 8. Run OSTF + + Snapshot: upgrade_net_tmpl_restore + """ + + self.check_run(self.snapshot_name) + assert_true(os.path.exists(self.repos_local_path)) + assert_true(os.path.exists(self.local_path)) + + self.show_step(1) + self.revert_backup() + self.show_step(2) + self.reinstall_master_node() + self.show_step(3) + self.show_step(4) + self.show_step(5) + self.do_restore(self.backup_path, self.local_path, + self.repos_backup_path, self.repos_local_path) + self.show_step(6) + cluster_id = self.fuel_web.get_last_created_cluster() + # get_network_template will raise en exception if there is no template + self.fuel_web.client.get_network_template(cluster_id) + # TODO(vkhlyunev): ensure that the template wasn't changed + + self.show_step(7) + self.fuel_web.verify_network(cluster_id) + self.show_step(8) + self.fuel_web.run_ostf(cluster_id=cluster_id, + test_sets=['smoke', 'sanity', 'ha']) + self.env.make_snapshot("upgrade_net_tmpl_restore", is_make=True)