Page MenuHomeSoftware Heritage

test_storage: Fix flakiness in round to milliseconds test method
ClosedPublic

Authored by ardumont on Jun 17 2020, 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
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 12912
Build 19662: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 19661: arc lint + arc unit

Event Timeline

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.Jun 17 2020, 12:59 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.

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.Jun 17 2020, 2:47 PM
This revision now requires changes to proceed.Jun 17 2020, 2:47 PM
swh/storage/tests/test_storage.py
107–116

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

swh/storage/tests/test_storage.py
107–116

d'oh lol, yeah

thanks.

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.

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