securedrop
securedrop copied to clipboard
test_account_edit_hotp_secret[en_US] is flaky
Description
We have seen multiple flaky CI failures in the app-page-layout-tests job for test_account_edit_hotp_secret[en_US].
The log is:
self = <tests.pageslayout.test_journalist_account.TestJournalistLayoutAccount object at 0x7fc7de574cd0>
def test_account_edit_hotp_secret(self):
self._journalist_logs_in()
self._visit_edit_account()
self._visit_edit_hotp_secret()
> self._screenshot('journalist-account_edit_hotp_secret.png')
/home/circleci/project/securedrop/tests/pageslayout/test_journalist_account.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/circleci/project/securedrop/tests/pageslayout/functional_test.py:81: in _screenshot
cropped = autocrop_btm(img)
/home/circleci/project/securedrop/tests/pageslayout/functional_test.py:51: in autocrop_btm
while all([gray.getpixel((col, btm)) == bg for col in range(gray.width)]):
/home/circleci/project/securedrop/tests/pageslayout/functional_test.py:51: in <listcomp>
while all([gray.getpixel((col, btm)) == bg for col in range(gray.width)]):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <PIL.Image.Image image mode=L size=1024x1315 at 0x7FC7DE29C820>
xy = (0, -1316)
def getpixel(self, xy):
"""
Returns the pixel value at a given position.
:param xy: The coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: The pixel value. If the image is a multi-layer image,
this method returns a tuple.
"""
self.load()
if self.pyaccess:
return self.pyaccess.getpixel(xy)
> return self.im.getpixel(xy)
E IndexError: image index out of range
/opt/venvs/securedrop-app-code/lib/python3.8/site-packages/PIL/Image.py:1411: IndexError
https://app.circleci.com/pipelines/github/freedomofpress/securedrop/3901/workflows/f8a64dc7-3f1a-49a6-b733-f5039708b415/jobs/60726
Steps to Reproduce
Unclear.
it seems like in certain circumstances autocrop_btm() is trying to retrieve pixels with negative Y values? It keeps decrementing it until the row matches a condition, maybe it's just never getting a match sometimes. Checking boundary conditions would probably help (though it could also sometimes result in busted screenshots instead of a flaky test).