Merge "Remove Heartbeat-Before check from heartbeat"
This commit is contained in:
@@ -70,13 +70,6 @@ class APIClient(object):
|
|||||||
msg = 'Invalid status code: {0}'.format(response.status_code)
|
msg = 'Invalid status code: {0}'.format(response.status_code)
|
||||||
raise errors.HeartbeatError(msg)
|
raise errors.HeartbeatError(msg)
|
||||||
|
|
||||||
try:
|
|
||||||
return float(response.headers['Heartbeat-Before'])
|
|
||||||
except KeyError:
|
|
||||||
raise errors.HeartbeatError('Missing Heartbeat-Before header')
|
|
||||||
except Exception:
|
|
||||||
raise errors.HeartbeatError('Invalid Heartbeat-Before header')
|
|
||||||
|
|
||||||
def lookup_node(self, hardware_info, timeout, starting_interval):
|
def lookup_node(self, hardware_info, timeout, starting_interval):
|
||||||
timer = backoff.BackOffLoopingCall(
|
timer = backoff.BackOffLoopingCall(
|
||||||
self._do_lookup,
|
self._do_lookup,
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from oslotest import base as test_base
|
from oslotest import base as test_base
|
||||||
@@ -54,21 +53,16 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_successful_heartbeat(self):
|
def test_successful_heartbeat(self):
|
||||||
expected_heartbeat_before = time.time() + 120
|
response = FakeResponse(status_code=202)
|
||||||
response = FakeResponse(status_code=202, headers={
|
|
||||||
'Heartbeat-Before': expected_heartbeat_before,
|
|
||||||
})
|
|
||||||
|
|
||||||
self.api_client.session.request = mock.Mock()
|
self.api_client.session.request = mock.Mock()
|
||||||
self.api_client.session.request.return_value = response
|
self.api_client.session.request.return_value = response
|
||||||
|
|
||||||
heartbeat_before = self.api_client.heartbeat(
|
self.api_client.heartbeat(
|
||||||
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
||||||
advertise_address=('192.0.2.1', '9999')
|
advertise_address=('192.0.2.1', '9999')
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(heartbeat_before, expected_heartbeat_before)
|
|
||||||
|
|
||||||
heartbeat_path = 'v1/nodes/deadbeef-dabb-ad00-b105-f00d00bab10c/' \
|
heartbeat_path = 'v1/nodes/deadbeef-dabb-ad00-b105-f00d00bab10c/' \
|
||||||
'vendor_passthru/heartbeat'
|
'vendor_passthru/heartbeat'
|
||||||
request_args = self.api_client.session.request.call_args[0]
|
request_args = self.api_client.session.request.call_args[0]
|
||||||
@@ -94,28 +88,6 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
|||||||
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
||||||
advertise_address=('192.0.2.1', '9999'))
|
advertise_address=('192.0.2.1', '9999'))
|
||||||
|
|
||||||
def test_heartbeat_missing_heartbeat_before_header(self):
|
|
||||||
response = FakeResponse(status_code=202)
|
|
||||||
self.api_client.session.request = mock.Mock()
|
|
||||||
self.api_client.session.request.return_value = response
|
|
||||||
|
|
||||||
self.assertRaises(errors.HeartbeatError,
|
|
||||||
self.api_client.heartbeat,
|
|
||||||
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
|
||||||
advertise_address=('192.0.2.1', '9999'))
|
|
||||||
|
|
||||||
def test_heartbeat_invalid_heartbeat_before_header(self):
|
|
||||||
response = FakeResponse(status_code=202, headers={
|
|
||||||
'Heartbeat-Before': 'tomorrow',
|
|
||||||
})
|
|
||||||
self.api_client.session.request = mock.Mock()
|
|
||||||
self.api_client.session.request.return_value = response
|
|
||||||
|
|
||||||
self.assertRaises(errors.HeartbeatError,
|
|
||||||
self.api_client.heartbeat,
|
|
||||||
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
|
||||||
advertise_address=('192.0.2.1', '9999'))
|
|
||||||
|
|
||||||
@mock.patch('eventlet.greenthread.sleep')
|
@mock.patch('eventlet.greenthread.sleep')
|
||||||
@mock.patch('ironic_python_agent.ironic_api_client.APIClient._do_lookup')
|
@mock.patch('ironic_python_agent.ironic_api_client.APIClient._do_lookup')
|
||||||
def test_lookup_node(self, lookup_mock, sleep_mock):
|
def test_lookup_node(self, lookup_mock, sleep_mock):
|
||||||
|
Reference in New Issue
Block a user