Skip to content

Commit

Permalink
C4-257 Reduce ingestion listener test flakiness (#168)
Browse files Browse the repository at this point in the history
* C4-257 small changes that should improve test flakiness

* C4-223 attempt fix in similar fashion as other fixtures
  • Loading branch information
willronchetti committed Aug 4, 2020
1 parent 67f281b commit 729d868
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
# Note: Various modules refer to this system as "encoded", not "cgap-portal".
name = "encoded"
version = "2.3.5"
version = "2.3.6"
description = "Clinical Genomics Analysis Platform"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down
10 changes: 7 additions & 3 deletions src/encoded/ingestion_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,15 @@ def get_counts(self):
}
return formatted['waiting'], formatted['inflight']

def receive_messages(self):
""" Returns an array of messages, if any that are waiting """
def receive_messages(self, batch_size=None):
""" Returns an array of messages, if any that are waiting
:param batch_size: an integer number of messages
:returns: messages received or [] if no messages were ready to be received
"""
response = self.client.receive_message(
QueueUrl=self.queue_url,
MaxNumberOfMessages=self.batch_size
MaxNumberOfMessages=self.batch_size if batch_size is None else batch_size
)
return response.get('Messages', [])

Expand Down
9 changes: 8 additions & 1 deletion src/encoded/tests/test_ingestion_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ def test_ingestion_queue_add_and_receive(setup_and_teardown_sqs_state):
str(uuid4()), str(uuid4())
])
wait_for_queue_to_catch_up(0)
msgs = queue_manager.receive_messages()
tries, msgs = 5, []
while len(msgs) < 2:
if tries < 0:
break
_msgs = queue_manager.receive_messages(batch_size=1) # should reduce flakiness
msgs.extend(_msgs)
wait_for_queue_to_catch_up(0)
tries -= 1
assert len(msgs) == 2


Expand Down
9 changes: 7 additions & 2 deletions src/encoded/tests/test_static_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ def help_page_json_deleted():

@pytest.fixture(scope='module')
def posted_help_page_section(testapp, help_page_section_json):
res = testapp.post_json('/static-sections/', help_page_section_json, status=201)
return res.json['@graph'][0]
try:
res = testapp.post_json('/static-sections/', help_page_section_json, status=201)
val = res.json['@graph'][0]
except webtest.AppError:
res = testapp.get('/' + help_page_section_json['uuid'], status=301).follow()
val = res.json
return val


@pytest.fixture(scope='module')
Expand Down

0 comments on commit 729d868

Please sign in to comment.