Cluster upgrade extension for Fuel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_extension.py 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 Mirantis, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. import mock
  16. from oslo_serialization import jsonutils
  17. from nailgun import objects
  18. from nailgun.orchestrator.deployment_serializers import DeploymentLCMSerializer
  19. from nailgun.test.base import BaseTestCase
  20. from nailgun.utils import reverse
  21. from cluster_upgrade import extension
  22. from cluster_upgrade.objects import relations
  23. from cluster_upgrade.tests import base
  24. class TestExtension(BaseTestCase):
  25. @mock.patch.object(relations.UpgradeRelationObject, "delete_relation")
  26. def test_on_cluster_delete(self, mock_on_cluster_delete):
  27. cluster = mock.Mock(id=42)
  28. extension.ClusterUpgradeExtension.on_cluster_delete(cluster)
  29. mock_on_cluster_delete.assert_called_once_with(42)
  30. class TestPipeline(base.BaseCloneClusterTest):
  31. def setUp(self):
  32. super(TestPipeline, self).setUp()
  33. resp = self.app.post(
  34. reverse("ClusterUpgradeCloneHandler",
  35. kwargs={"cluster_id": self.src_cluster_db.id}),
  36. jsonutils.dumps(self.data),
  37. headers=self.default_headers
  38. ).json_body
  39. self.dst_cluster_db = objects.Cluster.get_by_uid(resp['id'])
  40. def test_upgrade_info(self):
  41. deployment_info = DeploymentLCMSerializer().serialize(
  42. self.dst_cluster_db, []
  43. )
  44. expected = {
  45. 'relation_info': {
  46. 'orig_cluster_id': self.src_cluster_db.id,
  47. 'seed_cluster_id': self.dst_cluster_db.id,
  48. }
  49. }
  50. self.assertEqual(
  51. deployment_info['common']['upgrade'],
  52. expected,
  53. )