summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-08-24 18:13:28 +0000
committerGerrit Code Review <review@openstack.org>2016-08-24 18:13:28 +0000
commit72df55c1850617873e552204a1209000ce537cf6 (patch)
tree0839049065e98d51f98a31f075b143035e3f0c6e
parent1b63629862beae83fe421a395412fe0f31cfe0fd (diff)
parentb3ce0d348cc20ed988b5adf66474836f631eb12d (diff)
Merge "Add tests for assign_node_to_cluster"
-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 7a00c0c..e2b3eb0 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)
@@ -182,6 +186,10 @@ class NailgunNodeAdapter(object):
182 return self.node.status 186 return self.node.status
183 187
184 @property 188 @property
189 def nic_interfaces(self):
190 return self.node.nic_interfaces
191
192 @property
185 def error_type(self): 193 def error_type(self):
186 return self.node.error_type 194 return self.node.error_type
187 195
diff --git a/cluster_upgrade/tests/test_upgrade.py b/cluster_upgrade/tests/test_upgrade.py
index 2f9ff98..15bb61c 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
@@ -236,3 +237,44 @@ class TestUpgradeHelperCloneCluster(base_tests.BaseCloneClusterTest):
236 self.helper.change_env_settings(self.src_cluster, new_cluster) 237 self.helper.change_env_settings(self.src_cluster, new_cluster)
237 self.assertEqual('image', 238 self.assertEqual('image',
238 attrs['editable']['provision']['method']['value']) 239 attrs['editable']['provision']['method']['value'])
240
241 def get_assigned_nets(self, node):
242 assigned_nets = {}
243 for iface in node.nic_interfaces:
244 nets = [net.name for net in iface.assigned_networks_list]
245 assigned_nets[iface.name] = nets
246 return assigned_nets
247
248 @fake_tasks()
249 def assign_node_to_cluster(self, template=None):
250 new_cluster = self.helper.clone_cluster(self.src_cluster, self.data)
251 node = adapters.NailgunNodeAdapter(self.src_cluster.cluster.nodes[0])
252
253 orig_assigned_nets = self.get_assigned_nets(node)
254
255 if template:
256 net_template = self.env.read_fixtures(['network_template_80'])[0]
257 new_cluster.network_template = net_template
258 orig_assigned_nets = {
259 'eth0': ['fuelweb_admin'], 'eth1': ['public', 'management']
260 }
261
262 self.helper.assign_node_to_cluster(node, new_cluster, node.roles, [])
263 self.db.refresh(new_cluster.cluster)
264
265 self.assertEqual(node.cluster_id, new_cluster.id)
266
267 self.env.clusters.append(new_cluster.cluster)
268 task = self.env.launch_provisioning_selected(cluster_id=new_cluster.id)
269 self.assertEqual(task.status, consts.TASK_STATUSES.ready)
270 for n in new_cluster.cluster.nodes:
271 self.assertEqual(consts.NODE_STATUSES.provisioned, n.status)
272
273 new_assigned_nets = self.get_assigned_nets(node)
274 self.assertEqual(orig_assigned_nets, new_assigned_nets)
275
276 def test_assign_node_to_cluster(self):
277 self.assign_node_to_cluster()
278
279 def test_assign_node_to_cluster_with_template(self):
280 self.assign_node_to_cluster(template=True)