Repair the deprecated uuid/uuids arguments
Commit 084d1dee76
was supposed to
deprecate them, but it broke their usage via keyword arguments.
Change-Id: I25cf9c8b941847a5d987531f033753523898b66f
This commit is contained in:
parent
519190d59e
commit
81ae133bd5
|
@ -87,6 +87,12 @@ class TestIntrospect(BaseTest):
|
|||
'post', '/introspection/%s' % self.uuid,
|
||||
params={})
|
||||
|
||||
def test_deprecated_uuid(self, mock_req):
|
||||
self.get_client().introspect(uuid=self.uuid)
|
||||
mock_req.assert_called_once_with(
|
||||
'post', '/introspection/%s' % self.uuid,
|
||||
params={})
|
||||
|
||||
def test_invalid_input(self, mock_req):
|
||||
self.assertRaises(TypeError, self.get_client().introspect, 42)
|
||||
|
||||
|
@ -106,6 +112,13 @@ class TestReprocess(BaseTest):
|
|||
'/introspection/%s/data/unprocessed' % self.uuid
|
||||
)
|
||||
|
||||
def test_deprecated_uuid(self, mock_req):
|
||||
self.get_client().reprocess(uuid=self.uuid)
|
||||
mock_req.assert_called_once_with(
|
||||
'post',
|
||||
'/introspection/%s/data/unprocessed' % self.uuid
|
||||
)
|
||||
|
||||
def test_invalid_input(self, mock_req):
|
||||
self.assertRaises(TypeError, self.get_client().reprocess, 42)
|
||||
self.assertFalse(mock_req.called)
|
||||
|
@ -121,6 +134,14 @@ class TestGetStatus(BaseTest):
|
|||
mock_req.assert_called_once_with(
|
||||
'get', '/introspection/%s' % self.uuid)
|
||||
|
||||
def test_deprecated_uuid(self, mock_req):
|
||||
mock_req.return_value.json.return_value = 'json'
|
||||
|
||||
self.get_client().get_status(uuid=self.uuid)
|
||||
|
||||
mock_req.assert_called_once_with(
|
||||
'get', '/introspection/%s' % self.uuid)
|
||||
|
||||
def test_invalid_input(self, _):
|
||||
self.assertRaises(TypeError, self.get_client().get_status, 42)
|
||||
|
||||
|
@ -180,6 +201,19 @@ class TestWaitForFinish(BaseTest):
|
|||
self.sleep.assert_called_with(v1.DEFAULT_RETRY_INTERVAL)
|
||||
self.assertEqual(5, self.sleep.call_count)
|
||||
|
||||
def test_deprecated_uuids(self, mock_get_st):
|
||||
mock_get_st.side_effect = (
|
||||
[{'finished': False, 'error': None}] * 5
|
||||
+ [{'finished': True, 'error': None}]
|
||||
)
|
||||
|
||||
res = self.get_client().wait_for_finish(uuids=['uuid1'],
|
||||
sleep_function=self.sleep)
|
||||
self.assertEqual({'uuid1': {'finished': True, 'error': None}},
|
||||
res)
|
||||
self.sleep.assert_called_with(v1.DEFAULT_RETRY_INTERVAL)
|
||||
self.assertEqual(5, self.sleep.call_count)
|
||||
|
||||
def test_timeout(self, mock_get_st):
|
||||
mock_get_st.return_value = {'finished': False, 'error': None}
|
||||
|
||||
|
@ -212,6 +246,10 @@ class TestWaitForFinish(BaseTest):
|
|||
self.sleep.assert_called_with(v1.DEFAULT_RETRY_INTERVAL)
|
||||
self.assertEqual(2, self.sleep.call_count)
|
||||
|
||||
def test_no_arguments(self, mock_get_st):
|
||||
self.assertRaises(TypeError,
|
||||
self.get_client().wait_for_finish)
|
||||
|
||||
|
||||
@mock.patch.object(http.BaseClient, 'request')
|
||||
class TestGetData(BaseTest):
|
||||
|
@ -223,6 +261,14 @@ class TestGetData(BaseTest):
|
|||
mock_req.assert_called_once_with(
|
||||
'get', '/introspection/%s/data' % self.uuid)
|
||||
|
||||
def test_deprecated_uuid(self, mock_req):
|
||||
mock_req.return_value.json.return_value = 'json'
|
||||
|
||||
self.assertEqual('json', self.get_client().get_data(uuid=self.uuid))
|
||||
|
||||
mock_req.assert_called_once_with(
|
||||
'get', '/introspection/%s/data' % self.uuid)
|
||||
|
||||
def test_raw(self, mock_req):
|
||||
mock_req.return_value.content = b'json'
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class ClientV1(http.BaseClient):
|
|||
"node_id instead.", DeprecationWarning)
|
||||
return node_id
|
||||
|
||||
def introspect(self, node_id, manage_boot=None, uuid=None):
|
||||
def introspect(self, node_id=None, manage_boot=None, uuid=None):
|
||||
"""Start introspection for a node.
|
||||
|
||||
:param uuid: node UUID or name, deprecated
|
||||
|
@ -128,7 +128,7 @@ class ClientV1(http.BaseClient):
|
|||
|
||||
self.request('post', '/introspection/%s' % node_id, params=params)
|
||||
|
||||
def reprocess(self, node_id, uuid=None):
|
||||
def reprocess(self, node_id=None, uuid=None):
|
||||
"""Reprocess stored introspection data.
|
||||
|
||||
If swift support is disabled, introspection data won't be stored,
|
||||
|
@ -186,7 +186,7 @@ class ClientV1(http.BaseClient):
|
|||
response = self.request('get', '/introspection', params=params)
|
||||
return response.json()['introspection']
|
||||
|
||||
def get_status(self, node_id, uuid=None):
|
||||
def get_status(self, node_id=None, uuid=None):
|
||||
"""Get introspection status for a node.
|
||||
|
||||
:param uuid: node UUID or name, deprecated
|
||||
|
@ -209,7 +209,8 @@ class ClientV1(http.BaseClient):
|
|||
|
||||
return self.request('get', '/introspection/%s' % node_id).json()
|
||||
|
||||
def wait_for_finish(self, node_ids, retry_interval=DEFAULT_RETRY_INTERVAL,
|
||||
def wait_for_finish(self, node_ids=None,
|
||||
retry_interval=DEFAULT_RETRY_INTERVAL,
|
||||
max_retries=DEFAULT_MAX_RETRIES,
|
||||
sleep_function=time.sleep, uuids=None):
|
||||
"""Wait for introspection finishing for given nodes.
|
||||
|
@ -234,6 +235,8 @@ class ClientV1(http.BaseClient):
|
|||
warnings.warn("Parameter uuid is deprecated and will be "
|
||||
"removed in future releases, please use "
|
||||
"node_id instead.", DeprecationWarning)
|
||||
elif not node_ids:
|
||||
raise TypeError("The node_ids argument is required")
|
||||
|
||||
# Number of attempts = number of retries + first attempt
|
||||
for attempt in range(max_retries + 1):
|
||||
|
@ -261,7 +264,7 @@ class ClientV1(http.BaseClient):
|
|||
raise WaitTimeoutError(_("Timeout while waiting for introspection "
|
||||
"of nodes %s") % new_active_node_ids)
|
||||
|
||||
def get_data(self, node_id, raw=False, uuid=None):
|
||||
def get_data(self, node_id=None, raw=False, uuid=None):
|
||||
"""Get introspection data from the last introspection of a node.
|
||||
|
||||
If swift support is disabled, introspection data won't be stored,
|
||||
|
@ -286,7 +289,7 @@ class ClientV1(http.BaseClient):
|
|||
else:
|
||||
return resp.json()
|
||||
|
||||
def abort(self, node_id, uuid=None):
|
||||
def abort(self, node_id=None, uuid=None):
|
||||
"""Abort running introspection for a node.
|
||||
|
||||
:param uuid: node UUID or name, deprecated
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes regression in 3.6.0 that caused the deprecated ``uuid`` argument
|
||||
to various calls to stop working.
|
Loading…
Reference in New Issue