Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #4387 from golemfactory/attach_fgtrf_to_srr
Browse files Browse the repository at this point in the history
send srr if fgtrf is in history
  • Loading branch information
etam authored Jun 26, 2019
2 parents 20b5cbc + bdce5de commit b5e7239
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 6 deletions.
27 changes: 21 additions & 6 deletions golem/network/concent/received_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,28 @@ def on_force_subtask_results(self, msg, **_):
task_id=msg.task_id
)
if not (sra or srr):
# I can't remember verification results,
# so try again and hope for the best
self._after_ack_report_computed_task(
report_computed_task=msg.ack_report_computed_task
.report_computed_task,
fgtrf = history.get(
message_class_name='ForceGetTaskResultFailed',
node_id=msg.provider_id,
subtask_id=msg.subtask_id,
task_id=msg.task_id
)
return
if fgtrf:
srr = message.tasks.SubtaskResultsRejected(
report_computed_task=(
msg.ack_report_computed_task.report_computed_task),
force_get_task_result_failed=fgtrf,
reason=(message.tasks.SubtaskResultsRejected.REASON
.ForcedResourcesFailure),
)
else:
# I can't remember verification results and I have no proof of
# failure from Concent, so try again and hope for the best
self._after_ack_report_computed_task(
report_computed_task=msg.ack_report_computed_task
.report_computed_task,
)
return

response_msg = message.concents.ForceSubtaskResultsResponse(
subtask_results_accepted=sra,
Expand Down
38 changes: 38 additions & 0 deletions tests/golem/network/concent/test_received_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,44 @@ def test_no_sra_nor_srr(self, last_resort_mock, get_mock):
.report_computed_task,
)

@mock.patch('golem.network.history.get')
@mock.patch(
'golem.network.concent.received_handler'
'.TaskServerMessageHandler.'
'_after_ack_report_computed_task')
def test_no_sra_nor_srr_but_has_fgtrf(self, last_resort_mock, get_mock):
fgtrf = msg_factories.concents.ForceGetTaskResultFailedFactory(
task_to_compute__subtask_id=self.msg.subtask_id,
)

def history_get(*, message_class_name, **_kwargs):
if message_class_name == 'ForceGetTaskResultFailed':
return fgtrf
return None

get_mock.side_effect = history_get

library.interpret(self.msg)

last_resort_mock.assert_not_called()
self.task_server.client.concent_service.submit_task_message \
.assert_called_once_with(
self.msg.subtask_id,
message.concents.ForceSubtaskResultsResponse(
subtask_results_accepted=None,
subtask_results_rejected=(
message.tasks.SubtaskResultsRejected(
report_computed_task=(
self.msg.ack_report_computed_task
.report_computed_task),
force_get_task_result_failed=fgtrf,
reason=(message.tasks.SubtaskResultsRejected.REASON
.ForcedResourcesFailure),
)
),
)
)

@mock.patch('golem.network.history.get')
@mock.patch(
'golem.network.concent.received_handler'
Expand Down

0 comments on commit b5e7239

Please sign in to comment.