Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a256833163537375_immortal_bridge'
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaksymiv committed Feb 21, 2017
2 parents 8228741 + e91fcb0 commit 0a0fd65
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 15 deletions.
33 changes: 26 additions & 7 deletions openprocurement/tender/competitivedialogue/databridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,6 @@ def get_competitive_dialogue_backward(self):
extra=journal_context({"MESSAGE_ID": DATABRIDGE_TENDER_PROCESS},
{"TENDER_ID": tender_data['id']}))
self.competitive_dialogues_queue.put(tender_data)
except ResourceError as re:
logger.warn('Backward worker died!', extra=journal_context({"MESSAGE_ID": DATABRIDGE_WORKER_DIED}, {}))
logger.error("Error response {}".format(re.message))
raise re
except Exception, e:
# TODO reset queues and restart sync
logger.warn('Backward worker died!', extra=journal_context({"MESSAGE_ID": DATABRIDGE_WORKER_DIED}, {}))
Expand Down Expand Up @@ -702,21 +698,44 @@ def _start_competitive_wokers(self):
def _restart_synchronization_workers(self):
logger.warn("Restarting synchronization", extra=journal_context({"MESSAGE_ID": DATABRIDGE_RESTART}, {}))
for j in self.jobs:
j.kill()
j.kill(timeout=5)
self._start_competitive_wokers()

def run(self):
self._start_competitive_sculptors()
self._start_competitive_wokers()
backward_worker, forward_worker = self.jobs

counter = 0
try:
while True:
gevent.sleep(self.jobs_watcher_delay)
if counter == 20:
logger.info(
"""Current state: First stages in processing {competitive_dialogues_queue};
Prepared data for second stage {handicap_competitive_dialogues_queue};
Prepared data with owner and token {dialogs_stage2_put_queue};
Retry prepared data with owner and token {dialogs_stage2_retry_put_queue};
Data with second stage ID {dialog_stage2_id_queue};
Retry data with second stage ID {dialog_retry_stage2_id_queue};
Data with new status and first stage ID {dialogs_stage2_patch_queue}
Retry data with new status and first stage ID {dialogs_stage2_retry_patch_queue}
Data with new status for first stage {dialog_set_complete_queue}
Retry data with new status for first stage {dialog_retry_set_complete_queue}""".format(
competitive_dialogues_queue=self.competitive_dialogues_queue.qsize(),
handicap_competitive_dialogues_queue=self.handicap_competitive_dialogues_queue.qsize(),
dialogs_stage2_put_queue=self.dialogs_stage2_put_queue.qsize(),
dialogs_stage2_retry_put_queue=self.dialogs_stage2_retry_put_queue.qsize(),
dialog_stage2_id_queue=self.dialog_stage2_id_queue.qsize(),
dialog_retry_stage2_id_queue=self.dialog_retry_stage2_id_queue.qsize(),
dialogs_stage2_patch_queue=self.dialogs_stage2_patch_queue.qsize(),
dialogs_stage2_retry_patch_queue=self.dialogs_stage2_retry_patch_queue.qsize(),
dialog_set_complete_queue=self.dialog_set_complete_queue.qsize(),
dialog_retry_set_complete_queue=self.dialog_retry_set_complete_queue.qsize()))
counter = 0
counter += 1
if forward_worker.dead or (backward_worker.dead and not backward_worker.successful()):
self._restart_synchronization_workers()
backward_worker, forward_worker = self.jobs
logger.info('Starting forward and backward sync workers')
except KeyboardInterrupt:
logger.info('Exiting...')
gevent.killall(self.jobs, timeout=5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1239,13 +1239,11 @@ def setUp(self):
test_bid_1['tenderers'] = [author]
test_bid_2 = deepcopy(test_bids[1])
test_bid_2['tenderers'] = [author]
print 0, self.app.authorization
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': test_bid_1})
bid = response.json['data']
self.bid_id = bid['id']
self.bid_token = response.json['access']['token']
# create second bid
print 1, self.app.authorization
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': test_bid_2})
bid2 = response.json['data']
self.bid2_id = bid2['id']
Expand Down Expand Up @@ -1430,7 +1428,6 @@ def all_documents_are_accessible_for_bid_owner(resource):
orig_auth = self.app.authorization
self.app.authorization = ('Basic', ('broker', ''))
for resource in ['documents', 'financial_documents', 'eligibility_documents', 'qualification_documents']:
print 2, self.app.authorization
response = self.app.get('/tenders/{}/bids/{}/{}?acc_token={}'.format(self.tender_id, self.bid_id,
resource, self.bid_token))
self.assertEqual(response.status, '200 OK')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2919,10 +2919,11 @@ def test_create_tender_bidder_invalid(self):
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [u'This field is required.'], u'location': u'body', u'name': u'lotValues'},
{u'description': [u'All features parameters is required.'], u'location': u'body', u'name': u'parameters'}
])
for error in response.json['errors']:
self.assertIn(
error, [{u'description': [u'This field is required.'], u'location': u'body', u'name': u'lotValues'},
{u'description': [u'All features parameters is required.'], u'location': u'body', u'name': u'parameters'}]
)

response = self.app.post_json(request_path, {'data': {'selfEligible': True, 'selfQualified': True,
'tenderers': tenderers[0], 'lotValues': [{"value": {"amount": 500}}]}}, status=422)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '1.0.9'
version = '1.0.12'

requires = [
'setuptools'
Expand Down

0 comments on commit 0a0fd65

Please sign in to comment.