Browse Source

ng-11: API microversion 1.9

This change bumps the API microversion from 1.8 to 1.9.

Change-Id: I020940e1495f481c840c691cbe9770d14dc050ec
tags/10.0.0.0rc1
Theodoros Tsioutsias 1 year ago
parent
commit
f14c50011a
4 changed files with 74 additions and 7 deletions
  1. +5
    -0
      magnum/api/controllers/v1/nodegroup.py
  2. +2
    -1
      magnum/api/controllers/versions.py
  3. +1
    -1
      magnum/tests/unit/api/controllers/test_root.py
  4. +66
    -5
      magnum/tests/unit/api/controllers/v1/test_nodegroup.py

+ 5
- 0
magnum/api/controllers/v1/nodegroup.py View File

@@ -222,6 +222,7 @@ class NodeGroupController(base.Controller):
sort_key=sort_key,
sort_dir=sort_dir)

@base.Controller.api_version("1.9")
@expose.expose(NodeGroupCollection, types.uuid_or_name, int, int,
wtypes.text, wtypes.text, wtypes.text)
def get_all(self, cluster_id, marker=None, limit=None, sort_key='id',
@@ -260,6 +261,7 @@ class NodeGroupController(base.Controller):
filters,
expand=False)

@base.Controller.api_version("1.9")
@expose.expose(NodeGroup, types.uuid_or_name, types.uuid_or_name)
def get_one(self, cluster_id, nodegroup_id):
"""Retrieve information for the given nodegroup in a cluster.
@@ -277,6 +279,7 @@ class NodeGroupController(base.Controller):
nodegroup = objects.NodeGroup.get(context, cluster.uuid, nodegroup_id)
return NodeGroup.convert(nodegroup)

@base.Controller.api_version("1.9")
@expose.expose(NodeGroup, types.uuid_or_name, NodeGroup, body=NodeGroup,
status_code=202)
def post(self, cluster_id, nodegroup):
@@ -315,6 +318,7 @@ class NodeGroupController(base.Controller):
pecan.request.rpcapi.nodegroup_create_async(cluster, new_obj)
return NodeGroup.convert(new_obj)

@base.Controller.api_version("1.9")
@expose.expose(NodeGroup, types.uuid_or_name, types.uuid_or_name,
body=[NodeGroupPatchType], status_code=202)
def patch(self, cluster_id, nodegroup_id, patch):
@@ -329,6 +333,7 @@ class NodeGroupController(base.Controller):
pecan.request.rpcapi.nodegroup_update_async(cluster, nodegroup)
return NodeGroup.convert(nodegroup)

@base.Controller.api_version("1.9")
@expose.expose(None, types.uuid_or_name, types.uuid_or_name,
status_code=204)
def delete(self, cluster_id, nodegroup_id):


+ 2
- 1
magnum/api/controllers/versions.py View File

@@ -41,10 +41,11 @@ REST_API_VERSION_HISTORY = """REST API Version History:
* 1.6 - Add quotas API
* 1.7 - Add resize API
* 1.8 - Add upgrade API
* 1.9 - Add nodegroup API
"""

BASE_VER = '1.1'
CURRENT_MAX_VER = '1.8'
CURRENT_MAX_VER = '1.9'


class Version(object):


+ 1
- 1
magnum/tests/unit/api/controllers/test_root.py View File

@@ -40,7 +40,7 @@ class TestRootController(api_base.FunctionalTest):
[{u'href': u'http://localhost/v1/',
u'rel': u'self'}],
u'status': u'CURRENT',
u'max_version': u'1.8',
u'max_version': u'1.9',
u'min_version': u'1.1'}]}

self.v1_expected = {


+ 66
- 5
magnum/tests/unit/api/controllers/v1/test_nodegroup.py View File

@@ -44,7 +44,31 @@ class TestNodegroupObject(base.TestCase):
self.assertIsNone(nodegroup.max_node_count)


class TestListNodegroups(api_base.FunctionalTest):
class NodeGroupControllerTest(api_base.FunctionalTest):
headers = {"Openstack-Api-Version": "container-infra latest"}

def _add_headers(self, kwargs):
if 'headers' not in kwargs:
kwargs['headers'] = self.headers

def get_json(self, *args, **kwargs):
self._add_headers(kwargs)
return super(NodeGroupControllerTest, self).get_json(*args, **kwargs)

def post_json(self, *args, **kwargs):
self._add_headers(kwargs)
return super(NodeGroupControllerTest, self).post_json(*args, **kwargs)

def delete(self, *args, **kwargs):
self._add_headers(kwargs)
return super(NodeGroupControllerTest, self).delete(*args, **kwargs)

def patch_json(self, *args, **kwargs):
self._add_headers(kwargs)
return super(NodeGroupControllerTest, self).patch_json(*args, **kwargs)


class TestListNodegroups(NodeGroupControllerTest):
_expanded_attrs = ["id", "project_id", "docker_volume_size", "labels",
"node_addresses", "links"]

@@ -156,8 +180,21 @@ class TestListNodegroups(api_base.FunctionalTest):
self._verify_attrs(self._nodegroup_attrs, response)
self._verify_attrs(self._expanded_attrs, response)

def test_get_one_wrong_microversion(self):
headers = {"Openstack-Api-Version": "container-infra 1.8"}
worker = self.cluster.default_ng_worker
url = '/clusters/%s/nodegroups/%s' % (self.cluster.uuid, worker.uuid)
response = self.get_json(url, headers=headers, expect_errors=True)
self.assertEqual(406, response.status_code)

def test_get_all_wrong_microversion(self):
headers = {"Openstack-Api-Version": "container-infra 1.8"}
url = '/clusters/%s/nodegroups/' % (self.cluster.uuid)
response = self.get_json(url, headers=headers, expect_errors=True)
self.assertEqual(406, response.status_code)


class TestPost(api_base.FunctionalTest):
class TestPost(NodeGroupControllerTest):
def setUp(self):
super(TestPost, self).setUp()
self.cluster_template = obj_utils.create_test_cluster_template(
@@ -307,8 +344,17 @@ class TestPost(api_base.FunctionalTest):
self.assertEqual('application/json', response.content_type)
self.assertEqual(409, response.status_int)

@mock.patch('oslo_utils.timeutils.utcnow')
def test_create_ng_wrong_microversion(self, mock_utcnow):
headers = {"Openstack-Api-Version": "container-infra 1.8"}
ng_dict = apiutils.nodegroup_post_data(name="new_ng")
response = self.post_json(self.url, ng_dict, headers=headers,
expect_errors=True)
self.assertEqual('application/json', response.content_type)
self.assertEqual(406, response.status_int)


class TestDelete(api_base.FunctionalTest):
class TestDelete(NodeGroupControllerTest):

def setUp(self):
super(TestDelete, self).setUp()
@@ -381,8 +427,14 @@ class TestDelete(api_base.FunctionalTest):
response = self.delete(url)
self.assertEqual(204, response.status_int)

def test_delete_wrong_microversion(self):
headers = {"Openstack-Api-Version": "container-infra 1.8"}
response = self.delete(self.url + self.nodegroup.uuid, headers=headers,
expect_errors=True)
self.assertEqual(406, response.status_int)


class TestPatch(api_base.FunctionalTest):
class TestPatch(NodeGroupControllerTest):
def setUp(self):
super(TestPatch, self).setUp()
self.cluster_template = obj_utils.create_test_cluster_template(
@@ -553,8 +605,17 @@ class TestPatch(api_base.FunctionalTest):
self.assertEqual('application/json', response.content_type)
self.assertEqual(202, response.status_code)

def test_replace_wrong_microversion(self):
headers = {"Openstack-Api-Version": "container-infra 1.8"}
response = self.patch_json(self.url + self.nodegroup.name,
[{'path': '/max_node_count',
'value': 4,
'op': 'replace'}], headers=headers,
expect_errors=True)
self.assertEqual(406, response.status_code)


class TestNodeGroupPolicyEnforcement(api_base.FunctionalTest):
class TestNodeGroupPolicyEnforcement(NodeGroupControllerTest):
def setUp(self):
super(TestNodeGroupPolicyEnforcement, self).setUp()
obj_utils.create_test_cluster_template(self.context)


Loading…
Cancel
Save