summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Kharin <akscram@gmail.com>2016-08-28 15:14:12 +0300
committerIlya Kharin <akscram@gmail.com>2016-08-29 19:45:26 +0300
commit5ead3bf1b7957c3e3d9e42be6a31e82ea4e17cfc (patch)
treec06e9eab2c018564465414500de2fbe5f2306547
parent8147718cf776dc287b4952cb24f067f0c47991ac (diff)
Return VIPs on the clone operation
The test was also fixed and returned to the integrational manner. Change-Id: Iea2301c95ec84e10cda8e1437f85f10c0c3e5437 Closes-Bug: #1617943
Notes
Notes (review): Code-Review+1: Nikita Zubkov <nzubkov@mirantis.com> Code-Review+2: Yuriy Taraday <yorik.sar@gmail.com> Code-Review+2: Ilya Kharin <akscram@gmail.com> Workflow+1: Ilya Kharin <akscram@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Mon, 29 Aug 2016 19:01:07 +0000 Reviewed-on: https://review.openstack.org/362004 Project: openstack/fuel-nailgun-extension-cluster-upgrade Branch: refs/heads/master
-rw-r--r--cluster_upgrade/handlers.py5
-rw-r--r--cluster_upgrade/tests/test_handlers.py37
2 files changed, 25 insertions, 17 deletions
diff --git a/cluster_upgrade/handlers.py b/cluster_upgrade/handlers.py
index 9e79952..4e7f96d 100644
--- a/cluster_upgrade/handlers.py
+++ b/cluster_upgrade/handlers.py
@@ -113,6 +113,7 @@ class CopyVIPsHandler(base.BaseHandler):
113 113
114 @base.handle_errors 114 @base.handle_errors
115 @base.validate 115 @base.validate
116 @base.serialize
116 def POST(self, cluster_id): 117 def POST(self, cluster_id):
117 """Copy VIPs from original cluster to new one 118 """Copy VIPs from original cluster to new one
118 119
@@ -120,6 +121,7 @@ class CopyVIPsHandler(base.BaseHandler):
120 clusters that is created on cluster clone operation 121 clusters that is created on cluster clone operation
121 122
122 :param cluster_id: id of cluster that VIPs must be copied to 123 :param cluster_id: id of cluster that VIPs must be copied to
124 :returns: Collection of JSON-serialised VIPs.
123 125
124 :http: * 200 (OK) 126 :http: * 200 (OK)
125 * 400 (validation failed) 127 * 400 (validation failed)
@@ -144,6 +146,9 @@ class CopyVIPsHandler(base.BaseHandler):
144 146
145 upgrade.UpgradeHelper.copy_vips(orig_cluster_adapter, 147 upgrade.UpgradeHelper.copy_vips(orig_cluster_adapter,
146 seed_cluster_adapter) 148 seed_cluster_adapter)
149 cluster_vips = objects.IPAddrCollection.get_vips_by_cluster_id(
150 cluster.id)
151 return objects.IPAddrCollection.to_list(cluster_vips)
147 152
148 153
149class CreateUpgradeReleaseHandler(base.BaseHandler): 154class CreateUpgradeReleaseHandler(base.BaseHandler):
diff --git a/cluster_upgrade/tests/test_handlers.py b/cluster_upgrade/tests/test_handlers.py
index 819a1fc..6e4382d 100644
--- a/cluster_upgrade/tests/test_handlers.py
+++ b/cluster_upgrade/tests/test_handlers.py
@@ -23,6 +23,7 @@ from nailgun.test import base
23from nailgun.utils import reverse 23from nailgun.utils import reverse
24 24
25from . import base as tests_base 25from . import base as tests_base
26from ..objects import adapters
26 27
27 28
28class TestClusterUpgradeCloneHandler(tests_base.BaseCloneClusterTest): 29class TestClusterUpgradeCloneHandler(tests_base.BaseCloneClusterTest):
@@ -224,29 +225,31 @@ class TestNodeReassignHandler(base.BaseIntegrationTest):
224 self.assertEqual(400, resp.status_code) 225 self.assertEqual(400, resp.status_code)
225 226
226 227
227class TestCopyVipsHandler(base.BaseIntegrationTest): 228class TestCopyVipsHandler(tests_base.BaseCloneClusterTest):
229 def test_copy_vips(self):
230 node_db = self.env.create_node(cluster_id=self.src_cluster.id,
231 roles=["controller"])
232 node = adapters.NailgunNodeAdapter(node_db)
228 233
229 def test_copy_vips_called(self): 234 src_net_manager = self.src_cluster.get_network_manager()
230 from ..objects import relations 235 orig_vips = src_net_manager.assign_vips_for_net_groups()
231 236
232 orig_cluster = self.env.create_cluster(api=False) 237 new_cluster = self.helper.clone_cluster(self.src_cluster, self.data)
233 new_cluster = self.env.create_cluster(api=False) 238 self.helper.assign_node_to_cluster(node, new_cluster, node.roles, [])
234 239
235 relations.UpgradeRelationObject.create_relation( 240 resp = self.app.post(
236 orig_cluster.id, new_cluster.id) 241 reverse(
242 'CopyVIPsHandler',
243 kwargs={'cluster_id': new_cluster.id}
244 ),
245 headers=self.default_headers,
246 )
237 247
238 with mock.patch('cluster_upgrade.handlers' 248 orig_vips_addrs = set(orig_vips.values())
239 '.upgrade.UpgradeHelper.copy_vips') as copy_vips_mc: 249 new_vips_addrs = {vip["ip_addr"] for vip in resp.json_body}
240 resp = self.app.post(
241 reverse(
242 'CopyVIPsHandler',
243 kwargs={'cluster_id': new_cluster.id}
244 ),
245 headers=self.default_headers,
246 )
247 250
248 self.assertEqual(resp.status_code, 200) 251 self.assertEqual(resp.status_code, 200)
249 self.assertTrue(copy_vips_mc.called) 252 self.assertEqual(orig_vips_addrs, new_vips_addrs)
250 253
251 254
252class TestCreateUpgradeReleaseHandler(base.BaseIntegrationTest): 255class TestCreateUpgradeReleaseHandler(base.BaseIntegrationTest):