summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnastasiya <atolochkova@mirantis.com>2016-08-01 15:47:13 +0300
committerAnastasiya <atolochkova@mirantis.com>2016-08-24 17:53:59 +0300
commitb3ce0d348cc20ed988b5adf66474836f631eb12d (patch)
tree51eb5d54babb88e4c1d5b9cfca7291891a0b546c
parent8573c98921d308b23d76b0b0bf48ef5f78fca459 (diff)
Add tests for assign_node_to_cluster
Notes
Notes (review): Code-Review+2: Ilya Kharin <akscram@gmail.com> Code-Review+2: Yuriy Taraday <yorik.sar@gmail.com> Workflow+1: Yuriy Taraday <yorik.sar@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 24 Aug 2016 18:13:28 +0000 Reviewed-on: https://review.openstack.org/349489 Project: openstack/fuel-nailgun-extension-cluster-upgrade Branch: refs/heads/master
-rw-r--r--cluster_upgrade/objects/adapters.py14
-rw-r--r--cluster_upgrade/tests/test_upgrade.py42
2 files changed, 53 insertions, 3 deletions
diff --git a/cluster_upgrade/objects/adapters.py b/cluster_upgrade/objects/adapters.py
index 3348229..41970bc 100644
--- a/cluster_upgrade/objects/adapters.py
+++ b/cluster_upgrade/objects/adapters.py
@@ -58,13 +58,17 @@ class NailgunClusterAdapter(object):
58 def editable_attrs(self): 58 def editable_attrs(self):
59 return self.cluster.attributes.editable 59 return self.cluster.attributes.editable
60 60
61 @editable_attrs.setter
62 def editable_attrs(self, attrs):
63 self.cluster.attributes.editable = attrs
64
61 @property 65 @property
62 def network_template(self): 66 def network_template(self):
63 return self.cluster.network_config.configuration_template 67 return self.cluster.network_config.configuration_template
64 68
65 @editable_attrs.setter 69 @network_template.setter
66 def editable_attrs(self, attrs): 70 def network_template(self, template):
67 self.cluster.attributes.editable = attrs 71 self.cluster.network_config.configuration_template = template
68 72
69 def get_create_data(self): 73 def get_create_data(self):
70 return objects.Cluster.get_create_data(self.cluster) 74 return objects.Cluster.get_create_data(self.cluster)
@@ -178,6 +182,10 @@ class NailgunNodeAdapter(object):
178 return self.node.status 182 return self.node.status
179 183
180 @property 184 @property
185 def nic_interfaces(self):
186 return self.node.nic_interfaces
187
188 @property
181 def error_type(self): 189 def error_type(self):
182 return self.node.error_type 190 return self.node.error_type
183 191
diff --git a/cluster_upgrade/tests/test_upgrade.py b/cluster_upgrade/tests/test_upgrade.py
index 8b6c7b2..7189c35 100644
--- a/cluster_upgrade/tests/test_upgrade.py
+++ b/cluster_upgrade/tests/test_upgrade.py
@@ -20,6 +20,7 @@ import six
20from nailgun import consts 20from nailgun import consts
21from nailgun.extensions.network_manager.objects.serializers import \ 21from nailgun.extensions.network_manager.objects.serializers import \
22 network_configuration 22 network_configuration
23from nailgun.test.base import fake_tasks
23 24
24from .. import upgrade 25from .. import upgrade
25from . import base as base_tests 26from . import base as base_tests
@@ -239,3 +240,44 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
239 self.helper.change_env_settings(self.src_cluster, new_cluster) 240 self.helper.change_env_settings(self.src_cluster, new_cluster)
240 self.assertEqual('image', 241 self.assertEqual('image',
241 attrs['editable']['provision']['method']['value']) 242 attrs['editable']['provision']['method']['value'])
243
244 def get_assigned_nets(self, node):
245 assigned_nets = {}
246 for iface in node.nic_interfaces:
247 nets = [net.name for net in iface.assigned_networks_list]
248 assigned_nets[iface.name] = nets
249 return assigned_nets
250
251 @fake_tasks()
252 def assign_node_to_cluster(self, template=None):
253 new_cluster = self.helper.clone_cluster(self.src_cluster, self.data)
254 node = adapters.NailgunNodeAdapter(self.src_cluster.cluster.nodes[0])
255
256 orig_assigned_nets = self.get_assigned_nets(node)
257
258 if template:
259 net_template = self.env.read_fixtures(['network_template_80'])[0]
260 new_cluster.network_template = net_template
261 orig_assigned_nets = {
262 'eth0': ['fuelweb_admin'], 'eth1': ['public', 'management']
263 }
264
265 self.helper.assign_node_to_cluster(node, new_cluster, node.roles, [])
266 self.db.refresh(new_cluster.cluster)
267
268 self.assertEqual(node.cluster_id, new_cluster.id)
269
270 self.env.clusters.append(new_cluster.cluster)
271 task = self.env.launch_provisioning_selected(cluster_id=new_cluster.id)
272 self.assertEqual(task.status, consts.TASK_STATUSES.ready)
273 for n in new_cluster.cluster.nodes:
274 self.assertEqual(consts.NODE_STATUSES.provisioned, n.status)
275
276 new_assigned_nets = self.get_assigned_nets(node)
277 self.assertEqual(orig_assigned_nets, new_assigned_nets)
278
279 def test_assign_node_to_cluster(self):
280 self.assign_node_to_cluster()
281
282 def test_assign_node_to_cluster_with_template(self):
283 self.assign_node_to_cluster(template=True)