def setUp(self):
     super(TestClusterUpgrade, self).setUp()
     self.cluster_template1 = obj_utils.create_test_cluster_template(
         self.context,
         uuid='94889766-e686-11e9-81b4-2a2ae2dbcce4',
         name='test_1',
         id=1)
     self.cluster_template2 = obj_utils.create_test_cluster_template(
         self.context,
         uuid='94889aa4-e686-11e9-81b4-2a2ae2dbcce4',
         name='test_2',
         id=2)
     self.cluster_obj = obj_utils.create_test_cluster(
         self.context,
         name='cluster_example_A',
         cluster_template_id=self.cluster_template1.uuid)
     self.nodegroup_obj = obj_utils.create_test_nodegroup(
         self.context,
         name='test_ng',
         cluster_id=self.cluster_obj.uuid,
         uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
         project_id=self.cluster_obj.project_id,
         is_default=False)
     p = mock.patch.object(rpcapi.API, 'cluster_upgrade')
     self.mock_cluster_upgrade = p.start()
     self.mock_cluster_upgrade.side_effect = self._sim_rpc_cluster_upgrade
     self.addCleanup(p.stop)
    def test_upgrade_cluster_as_admin(self):
        token_info = {
            'token': {
                'project': {
                    'id': 'fake_project_1'
                },
                'user': {
                    'id': 'fake_user_1'
                }
            }
        }
        user_context = magnum_context.RequestContext(
            auth_token_info=token_info,
            project_id='fake_project_1',
            user_id='fake_user_1',
            is_admin=False)
        cluster_uuid = uuidutils.generate_uuid()
        cluster_template_uuid = uuidutils.generate_uuid()
        obj_utils.create_test_cluster_template(user_context,
                                               public=True,
                                               uuid=cluster_template_uuid)
        obj_utils.create_test_cluster(
            user_context,
            uuid=cluster_uuid,
            cluster_template_id=cluster_template_uuid)

        cluster_upgrade_req = {"cluster_template": "test_2"}
        self.context.is_admin = True
        response = self.post_json(
            '/clusters/%s/actions/upgrade' % cluster_uuid,
            cluster_upgrade_req,
            headers={"Openstack-Api-Version": "container-infra 1.8"})

        self.assertEqual(202, response.status_int)
Exemple #3
0
 def setUp(self):
     super(TestListNodegroups, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
     self.cluster_uuid = uuidutils.generate_uuid()
     obj_utils.create_test_cluster(self.context, uuid=self.cluster_uuid)
     self.cluster = objects.Cluster.get_by_uuid(self.context,
                                                self.cluster_uuid)
Exemple #4
0
 def setUp(self):
     super(TestListNodegroups, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
     self.cluster_uuid = uuidutils.generate_uuid()
     obj_utils.create_test_cluster(
         self.context, uuid=self.cluster_uuid)
     self.cluster = objects.Cluster.get_by_uuid(self.context,
                                                self.cluster_uuid)
Exemple #5
0
 def test_create_cluster_with_no_lb_multi_node(self):
     cluster_template = obj_utils.create_test_cluster_template(
         self.context, name='foo', uuid='foo', master_lb_enabled=False)
     bdict = apiutils.cluster_post_data(
         cluster_template_id=cluster_template.name, master_count=3)
     response = self.post_json('/clusters', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
Exemple #6
0
 def test_create_cluster_with_no_lb_multi_node(self):
     cluster_template = obj_utils.create_test_cluster_template(
         self.context, name='foo', uuid='foo', master_lb_enabled=False)
     bdict = apiutils.cluster_post_data(
         cluster_template_id=cluster_template.name, master_count=3)
     response = self.post_json('/clusters', bdict, expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
Exemple #7
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context)
     self.cluster = obj_utils.create_test_cluster(self.context)
     p = mock.patch.object(rpcapi.API, 'cluster_delete_async')
     self.mock_cluster_delete = p.start()
     self.mock_cluster_delete.side_effect = self._simulate_cluster_delete
     self.addCleanup(p.stop)
Exemple #8
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context)
     self.cluster = obj_utils.create_test_cluster(self.context)
     p = mock.patch.object(rpcapi.API, 'cluster_delete_async')
     self.mock_cluster_delete = p.start()
     self.mock_cluster_delete.side_effect = self._simulate_cluster_delete
     self.addCleanup(p.stop)
Exemple #9
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.cluster_template_obj = obj_utils.create_test_cluster_template(
         self.context)
     self.cluster_obj = obj_utils.create_test_cluster(
         self.context, name='cluster_example_A', node_count=3)
     p = mock.patch.object(rpcapi.API, 'cluster_update_async')
     self.mock_cluster_update = p.start()
     self.mock_cluster_update.side_effect = self._sim_rpc_cluster_update
     self.addCleanup(p.stop)
Exemple #10
0
 def setUp(self):
     super(TestPatch, self).setUp()
     self.cluster_template_obj = obj_utils.create_test_cluster_template(
         self.context)
     self.cluster_obj = obj_utils.create_test_cluster(
         self.context, name='cluster_example_A', node_count=3)
     p = mock.patch.object(rpcapi.API, 'cluster_update_async')
     self.mock_cluster_update = p.start()
     self.mock_cluster_update.side_effect = self._sim_rpc_cluster_update
     self.addCleanup(p.stop)
Exemple #11
0
 def setUp(self):
     super(TestPost, self).setUp()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context)
     self.cluster = obj_utils.create_test_cluster(self.context)
     self.cluster.refresh()
     p = mock.patch.object(rpcapi.API, 'nodegroup_create_async')
     self.mock_ng_create = p.start()
     self.mock_ng_create.side_effect = self._simulate_nodegroup_create
     self.addCleanup(p.stop)
     self.url = "/clusters/%s/nodegroups" % self.cluster.uuid
Exemple #12
0
 def setUp(self):
     super(TestPost, self).setUp()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context)
     p = mock.patch.object(rpcapi.API, 'cluster_create_async')
     self.mock_cluster_create = p.start()
     self.mock_cluster_create.side_effect = self._simulate_cluster_create
     self.addCleanup(p.stop)
     p = mock.patch.object(attr_validator, 'validate_os_resources')
     self.mock_valid_os_res = p.start()
     self.addCleanup(p.stop)
Exemple #13
0
 def setUp(self):
     super(TestPost, self).setUp()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context)
     p = mock.patch.object(rpcapi.API, 'cluster_create_async')
     self.mock_cluster_create = p.start()
     self.mock_cluster_create.side_effect = self._simulate_cluster_create
     self.addCleanup(p.stop)
     p = mock.patch.object(attr_validator, 'validate_os_resources')
     self.mock_valid_os_res = p.start()
     self.addCleanup(p.stop)
Exemple #14
0
    def setUp(self):
        super(TestRotateCaCertificateNonTls, self).setUp()
        self.cluster_template = obj_utils.create_test_cluster_template(
            self.context, tls_disabled=True)
        self.cluster = obj_utils.create_test_cluster(self.context)

        conductor_api_patcher = mock.patch('magnum.conductor.api.API')
        self.conductor_api_class = conductor_api_patcher.start()
        self.conductor_api = mock.MagicMock()
        self.conductor_api_class.return_value = self.conductor_api
        self.addCleanup(conductor_api_patcher.stop)
Exemple #15
0
 def test_replace_cluster_template_id_failed(self):
     cluster_template = obj_utils.create_test_cluster_template(
         self.context,
         uuid=uuidutils.generate_uuid())
     response = self.patch_json('/clusters/%s' % self.cluster_obj.uuid,
                                [{'path': '/cluster_template_id',
                                  'value': cluster_template.uuid,
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_code)
     self.assertTrue(response.json['errors'])
Exemple #16
0
 def test_replace_cluster_template_id_failed(self):
     cluster_template = obj_utils.create_test_cluster_template(
         self.context,
         uuid=uuidutils.generate_uuid())
     response = self.patch_json('/clusters/%s' % self.cluster_obj.uuid,
                                [{'path': '/cluster_template_id',
                                  'value': cluster_template.uuid,
                                  'op': 'replace'}],
                                expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_code)
     self.assertTrue(response.json['errors'])
Exemple #17
0
 def setUp(self):
     super(TestDelete, self).setUp()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context)
     self.cluster = obj_utils.create_test_cluster(self.context)
     self.cluster.refresh()
     self.nodegroup = obj_utils.create_test_nodegroup(
         self.context, cluster_id=self.cluster.uuid, is_default=False)
     p = mock.patch.object(rpcapi.API, 'nodegroup_delete_async')
     self.mock_ng_delete = p.start()
     self.mock_ng_delete.side_effect = self._simulate_nodegroup_delete
     self.addCleanup(p.stop)
     self.url = "/clusters/%s/nodegroups/" % self.cluster.uuid
Exemple #18
0
 def setUp(self):
     super(K8sFedoraAtomicV1DriverTest, self).setUp()
     self.driver = driver.Driver()
     self.cluster_template = obj_utils.create_test_cluster_template(
         self.context,
         uuid='94889aa4-e686-11e9-81b4-2a2ae2dbcce4',
         name='test_2',
         id=2,
         labels={'kube_tag': 'v1.14.7'},
         image_id='test-image2')
     self.cluster_obj = obj_utils.create_test_cluster(
         self.context, name='cluster_example_A', image_id='test-image1')
     self.cluster_obj.refresh()
     self.nodegroup_obj = obj_utils.create_test_nodegroup(
         self.context,
         name='test_ng',
         cluster_id=self.cluster_obj.uuid,
         uuid='27e3153e-d5bf-4b7e-b517-fb518e17f34c',
         project_id=self.cluster_obj.project_id,
         is_default=False,
         image_id='test-image1')
     self.nodegroup_obj.refresh()
Exemple #19
0
 def setUp(self):
     self.base_headers = {'OpenStack-API-Version': 'container-infra 1.4'}
     super(TestStatsController, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
Exemple #20
0
 def setUp(self):
     super(TestListCluster, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
Exemple #21
0
 def setUp(self):
     super(TestClusterPolicyEnforcement, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
Exemple #22
0
 def setUp(self):
     super(TestClusterPolicyEnforcement, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
Exemple #23
0
 def setUp(self):
     self.base_headers = {'OpenStack-API-Version': 'container-infra 1.4'}
     super(TestStatsController, self).setUp()
     obj_utils.create_test_cluster_template(self.context)
Exemple #24
0
 def setUp(self):
     super(TestListCluster, self).setUp()
     obj_utils.create_test_cluster_template(self.context)