From 4d2ea49519a6a4414513df1b9a6fa47fa3a3bcaf Mon Sep 17 00:00:00 2001 From: Artem Panchenko Date: Thu, 10 Sep 2015 01:43:32 +0300 Subject: [PATCH] Test adding nodes to cloud with network template Cover case with adding nodes to operational environment which uses networking template. It should be possible to update network template after deployment in order to specify nics mapping for new nodes. Related blueprint templates-for-networking Related-bug: #1493391 Change-Id: Ib4d13b31b4b92a30d2dc86ae78c2447522edf415 --- .../network_templates/cinder_add_nodes.yaml | 333 ++++++++++++++++++ fuelweb_test/tests/base_test_case.py | 28 ++ fuelweb_test/tests/test_net_templates.py | 81 ++++- 3 files changed, 441 insertions(+), 1 deletion(-) create mode 100644 fuelweb_test/network_templates/cinder_add_nodes.yaml diff --git a/fuelweb_test/network_templates/cinder_add_nodes.yaml b/fuelweb_test/network_templates/cinder_add_nodes.yaml new file mode 100644 index 000000000..c789a004e --- /dev/null +++ b/fuelweb_test/network_templates/cinder_add_nodes.yaml @@ -0,0 +1,333 @@ +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 + node-4: + if1: eth0 # admin + if2: eth2 # public + if3: eth4 # management (vlan 101) storage (vlan 102) & private (vlan 103) + if4: eth3 # other networks (vlan 201-299) + if5: eth1 # 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 + 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 + unused: + transformations: + - 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-cephrepl + - br-cephrados + roles: + ceph/replication: br-cephrepl + ceph/radosgw: br-cephrados \ No newline at end of file diff --git a/fuelweb_test/tests/base_test_case.py b/fuelweb_test/tests/base_test_case.py index 5cbe6592b..2e85336b4 100644 --- a/fuelweb_test/tests/base_test_case.py +++ b/fuelweb_test/tests/base_test_case.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from proboscis import TestProgram from proboscis import SkipTest from proboscis import test @@ -33,6 +34,7 @@ class TestBasic(object): def __init__(self): self.env = EnvironmentModel() self.fuel_web = self.env.fuel_web + self.test_program = TestProgram() def check_run(self, snapshot_name): """Checks if run of current test is required. @@ -68,6 +70,32 @@ class TestBasic(object): logger.info("\n" + " " * 55 + "<<< {0}. (no step description " "in scenario) {1}>>>".format(str(step), details_msg)) + def is_make_snapshot(self): + """Check if the test 'test_name' is a dependency for other planned + tests (snapshot is required). If yes return True, if no - False. + + :rtype: bool + """ + test_name = get_test_method_name() + tests = self.test_program.plan.tests + test_cases = [t for t in tests if t.entry.method.__name__ == test_name] + if len(test_cases) != 1: + logger.warning("Method 'is_make_snapshot' is called from function " + "which is not a test case: {0}".format(test_name)) + return False + test_groups = set(test_cases[0].entry.info.groups) + dependent_tests = set() + dependent_groups = set() + for t in tests: + for func in t.entry.info.depends_on: + dependent_tests.add(func.__name__) + for group in t.entry.info.depends_on_groups: + dependent_groups.add(group) + if test_name in dependent_tests or \ + test_groups & dependent_groups: + return True + return False + @test class SetupEnvironment(TestBasic): diff --git a/fuelweb_test/tests/test_net_templates.py b/fuelweb_test/tests/test_net_templates.py index 46bbe1fda..3fc71a607 100644 --- a/fuelweb_test/tests/test_net_templates.py +++ b/fuelweb_test/tests/test_net_templates.py @@ -108,7 +108,8 @@ class TestNetworkTemplates(TestNetworkTemplatesBase): self.check_services_networks(cluster_id, network_template) - self.env.make_snapshot("deploy_cinder_net_tmpl") + self.env.make_snapshot("deploy_cinder_net_tmpl", + is_make=self.is_make_snapshot()) @test(depends_on=[SetupEnvironment.prepare_slaves_5], groups=["deploy_ceph_net_tmpl"]) @@ -195,3 +196,81 @@ class TestNetworkTemplates(TestNetworkTemplatesBase): self.check_services_networks(cluster_id, network_template) self.env.make_snapshot("deploy_ceph_net_tmpl") + + @test(depends_on_groups=["deploy_cinder_net_tmpl"], + groups=["add_nodes_net_tmpl"]) + @log_snapshot_after_test + def add_nodes_net_tmpl(self): + """Add nodes to operational environment with network template + + Scenario: + 1. Revert snapshot with deployed environment + 2. Bootstrap 2 more slave nodes + 3. Add 1 controller + cinder and 1 compute + cinder nodes + 4. Upload 'cinder_add_nodes' network template with broken + network mapping for new nodes + 5. Run network verification. Check it failed. + 6. Upload 'cinder' network template' + 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 + + Duration 60m + Snapshot add_nodes_net_tmpl + """ + + self.env.revert_snapshot("deploy_cinder_net_tmpl") + + self.env.bootstrap_nodes(self.env.d_env.nodes().slaves[3:5]) + + cluster_id = self.fuel_web.get_last_created_cluster() + + self.fuel_web.update_nodes( + cluster_id, + { + 'slave-04': ['controller', 'cinder'], + 'slave-05': ['compute', 'cinder'], + }, + update_interfaces=False + ) + + network_template = get_network_template('cinder_add_nodes') + self.fuel_web.client.upload_network_template( + cluster_id=cluster_id, network_template=network_template) + self.fuel_web.verify_network(cluster_id, success=False) + + network_template = get_network_template('cinder') + self.fuel_web.client.upload_network_template( + cluster_id=cluster_id, network_template=network_template) + networks = self.generate_networks_for_template( + template=network_template, + ip_network='10.200.0.0/16', + ip_prefixlen='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.fuel_web.verify_network(cluster_id) + + self.fuel_web.deploy_cluster_wait(cluster_id) + + self.fuel_web.verify_network(cluster_id) + + self.check_ipconfig_for_template(cluster_id, network_template, + networks) + self.check_services_networks(cluster_id, network_template) + + self.fuel_web.run_ostf(cluster_id=cluster_id, + test_sets=['smoke', 'sanity', + 'ha', 'tests_platform']) + self.check_ipconfig_for_template(cluster_id, network_template, + networks) + + self.check_services_networks(cluster_id, network_template) + + self.env.make_snapshot("add_nodes_net_tmpl")