Page MenuHomeSoftware Heritage

test_storage: Fix flakiness in round to milliseconds test method
ClosedPublic

Authored by ardumont on Wed, Jun 17, 12:58 PM.

Details

Summary

Prior to this commit, the tests would fail [1] for no good reason [2]. This
fixes it.

[1] https://jenkins.softwareheritage.org/job/DSTO/job/tests/1264/console

[2] microseconds would exceed a limit of 999999 from time to time

Diff Detail

Repository
rDSTO Storage manager
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

ardumont created this revision.Wed, Jun 17, 12:58 PM
ardumont retitled this revision from test_storage: Fix flakyness in round to milliseconds test method to test_storage: Fix flakiness in round to milliseconds test method.Wed, Jun 17, 12:59 PM
ardumont edited the summary of this revision. (Show Details)Wed, Jun 17, 1:01 PM

Need to rework the commit message to align with the diff description, waiting for remarks eventually first prior to rebase it ;)

Build is green

Patch application report for D3302 (id=11702)

Rebasing onto 731949586c...

Current branch diff-target is up to date.
Changes applied before test
commit 39178038aa9661ca8598fd8bfad9d345d74398c5
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Jun 17 12:55:16 2020 +0200

    test_storage: Fix flakyness in round to milliseconds test method
    
    Prior to this commit, the tests would fail because microseconds would exceed a
    limit of 999999 for some reason once in a while [1]. Failing the tests for no
    good reason...
    
    This fixes it
    
    [1] https://jenkins.softwareheritage.org/job/DSTO/job/tests/1264/console

See https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/299/ for more details.

olasd added inline comments.Wed, Jun 17, 2:47 PM
swh/storage/tests/test_storage.py
107–116

Dividing date.microsecond by 1_000_000 will always return 0, as date.microsecond is 0 < x < 1_000_000.

To truncate to milliseconds, you need to (integer) divide by 1000, then multiply the result by 1000.

(so, (date.microsecond // 1000) * 1000).

I suggest adding tests for the edge cases, that is, microsecond=0, microsecond=1000, and microsecond=999500.

olasd requested changes to this revision.Wed, Jun 17, 2:47 PM
This revision now requires changes to proceed.Wed, Jun 17, 2:47 PM
olasd added inline comments.Wed, Jun 17, 2:49 PM
swh/storage/tests/test_storage.py
107–116

(Of course, this should read 0 <= x < 1_000_000.)

ardumont added inline comments.Wed, Jun 17, 3:10 PM
swh/storage/tests/test_storage.py
107–116

d'oh lol, yeah

thanks.

ardumont updated this revision to Diff 11703.Wed, Jun 17, 3:13 PM
ardumont edited the summary of this revision. (Show Details)

Adapt according to review

Build is green

Patch application report for D3302 (id=11703)

Rebasing onto 731949586c...

Current branch diff-target is up to date.
Changes applied before test
commit c3d177b46bb5811242ea8ce7c11850e118b6de36
Author: Antoine R. Dumont (@ardumont) <ardumont@softwareheritage.org>
Date:   Wed Jun 17 12:55:16 2020 +0200

    test_storage: Fix flakiness in round to milliseconds test util method
    
    Prior to this commit, the tests would fail [1] for no good reason [2]. This
    fixes it.
    
    [1] https://jenkins.softwareheritage.org/job/DSTO/job/tests/1264/console
    
    [2] microseconds would exceed a limit of 999999 from time to time

See https://jenkins.softwareheritage.org/job/DSTO/job/tests-on-diff/300/ for more details.

olasd accepted this revision.Wed, Jun 17, 3:57 PM
This revision is now accepted and ready to land.Wed, Jun 17, 3:57 PM