Pix4D / cogito

Concourse resource for GitHub Commit Status and Google Chat notifications
MIT License
34 stars 14 forks source link

fix #132: does not sleep when it should, approach 2 #134

Closed marco-m-pix4d closed 1 year ago

marco-m-pix4d commented 1 year ago

As mentioned, this is approach 2 at fixing https://github.com/Pix4D/cogito/issues/132. See also approach 1 at #133.

Compared with #133, it keeps the tests running as fast as possible and does not introduce test flakiness since it does not measure time.

To do this, I added an injectable sleep function, which I then substituted with a spy in the tests.

Best reviewed commit-per-commit, since commit 1 adds the repro and commit 2 adds the fix.

Fixes https://github.com/Pix4D/cogito/issues/132.

marco-m-pix4d commented 1 year ago

@Pix4D/integration: ready for re-review. Given the refactoring, I suggest to review commit-per-commit; the commit message is there to help understanding the reason of each change.

Thanks @aliculPix4D for pointing out yet another corner case. It has been longer than expected, but I think now that we can trust the tests. I also think that the retry loop is now self-evident.

Using a virtual sleep reduced the test running time from 4.5 sec to circa 1.1 sec, although we went from 215 to 224 test cases :-)