"Fossies" - the Fresh Open Source Software Archive

Member "magnum-8.1.0/magnum/tests/unit/api/controllers/v1/test_cluster_actions.py" (1 Oct 2019, 2228 Bytes) of package /linux/misc/openstack/magnum-8.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "test_cluster_actions.py": 9.0.0_vs_9.1.0.

    1 # Licensed under the Apache License, Version 2.0 (the "License");
    2 #    you may not use this file except in compliance with the License.
    3 #    You may obtain a copy of the License at
    4 #
    5 #        http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 #    Unless required by applicable law or agreed to in writing, software
    8 #    distributed under the License is distributed on an "AS IS" BASIS,
    9 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   10 #    See the License for the specific language governing permissions and
   11 #    limitations under the License.
   12 
   13 import mock
   14 
   15 from magnum.conductor import api as rpcapi
   16 import magnum.conf
   17 from magnum.tests.unit.api import base as api_base
   18 from magnum.tests.unit.objects import utils as obj_utils
   19 
   20 CONF = magnum.conf.CONF
   21 
   22 
   23 class TestClusterActions(api_base.FunctionalTest):
   24 
   25     def setUp(self):
   26         super(TestClusterActions, self).setUp()
   27         self.cluster_obj = obj_utils.create_test_cluster(
   28             self.context, name='cluster_example_A', node_count=3)
   29         p = mock.patch.object(rpcapi.API, 'cluster_resize_async')
   30         self.mock_cluster_resize = p.start()
   31         self.mock_cluster_resize.side_effect = self._sim_rpc_cluster_resize
   32         self.addCleanup(p.stop)
   33 
   34     def _sim_rpc_cluster_resize(self, cluster, node_count, nodes_to_remove,
   35                                 nodegroup=None, rollback=False):
   36         cluster.node_count = node_count
   37         cluster.save()
   38         return cluster
   39 
   40     def test_resize(self):
   41         new_node_count = 6
   42         response = self.post_json('/clusters/%s/actions/resize' %
   43                                   self.cluster_obj.uuid,
   44                                   {"node_count": new_node_count},
   45                                   headers={"Openstack-Api-Version":
   46                                            "container-infra 1.7"})
   47         self.assertEqual(202, response.status_code)
   48 
   49         response = self.get_json('/clusters/%s' % self.cluster_obj.uuid)
   50         self.assertEqual(new_node_count, response['node_count'])
   51         self.assertEqual(self.cluster_obj.uuid, response['uuid'])
   52         self.assertEqual(self.cluster_obj.cluster_template_id,
   53                          response['cluster_template_id'])