Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python implementation of datetime module is not being tested correctly. #75005

Closed
musically-ut mannequin opened this issue Jun 30, 2017 · 48 comments
Closed

Python implementation of datetime module is not being tested correctly. #75005

musically-ut mannequin opened this issue Jun 30, 2017 · 48 comments
Assignees
Labels
3.7 (EOL) end of life tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@musically-ut
Copy link
Mannequin

musically-ut mannequin commented Jun 30, 2017

BPO 30822
Nosy @abalkin, @vstinner, @ned-deily, @serhiy-storchaka, @musically-ut
PRs
  • bpo-30822: Fix testing of datetime module. #2530
  • bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. #2534
  • [3.5] bpo-30822: Fix testing of datetime module. (GH-2530) #2550
  • [3.6] bpo-30822: Fix testing of datetime module. (GH-2530) #2551
  • Revert "bpo-30822: Fix testing of datetime module." #2588
  • bpo-30822: Exclude tzdata from regrtest --all #2775
  • [3.6] bpo-30822: Exclude tzdata from regrtest --all (#2775) #2777
  • [3.5] bpo-30822: Exclude tzdata from regrtest --all (#2775) #2781
  • [3.5] bpo-30822: regrtest: remove tzdata #2782
  • bpo-30822: Fix testing of datetime module. #2783
  • [2.7] bpo-30822: regrtest: fix -u extralargefile #2788
  • [3.5] bpo-30822: Fix testing of datetime module. (GH-2530) (GH-2783) #2815
  • [3.6] bpo-30822: Fix testing of datetime module. (GH-2530) (GH-2783) #2816
  • [3.6] bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. (GH-2534) #3405
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-07-26.11:52:55.129>
    created_at = <Date 2017-06-30.23:47:48.837>
    labels = ['3.7', 'type-bug', 'tests']
    title = 'Python implementation of datetime module is not being tested correctly.'
    updated_at = <Date 2017-09-08.22:44:35.784>
    user = 'https://github.com/musically-ut'

    bugs.python.org fields:

    activity = <Date 2017-09-08.22:44:35.784>
    actor = 'vstinner'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-07-26.11:52:55.129>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2017-06-30.23:47:48.837>
    creator = 'musically_ut'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30822
    keywords = []
    message_count = 48.0
    messages = ['297455', '297470', '297515', '297517', '297518', '297519', '297520', '297522', '297523', '297524', '297525', '297530', '297546', '297548', '297554', '297555', '297557', '297559', '297562', '297571', '297573', '297612', '297734', '297736', '297743', '297752', '297753', '297760', '297762', '297763', '298032', '298033', '298059', '298664', '298717', '298721', '298725', '298726', '298729', '298732', '298755', '298756', '298786', '299221', '299222', '299223', '299224', '301749']
    nosy_count = 5.0
    nosy_names = ['belopolsky', 'vstinner', 'ned.deily', 'serhiy.storchaka', 'musically_ut']
    pr_nums = ['2530', '2534', '2550', '2551', '2588', '2775', '2777', '2781', '2782', '2783', '2788', '2815', '2816', '3405']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30822'
    versions = ['Python 3.6', 'Python 3.7']

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jun 30, 2017

    While investigating http://bugs.python.org/issue30302 it was discovered that the Python implementation of the datetime module was not being tested correctly.

    The datetimetester.py was supposed to execute tests twice, once for the _Fast implementation (i.e. C extension code in _datetimemodule.c) and once for the _Pure implementation (i.e the Python code).

    The fix is contained in the following two commits:

    The bug does not effect Python 2.7 as the C version of the datetime module had not been introduced back then. However, as fas as I can tell, the fix needs to be applied to all Python 3.x branches.

    @musically-ut musically-ut mannequin added type-feature A feature request or enhancement 3.7 (EOL) end of life tests Tests in the Lib/test dir labels Jun 30, 2017
    @serhiy-storchaka
    Copy link
    Member

    Please provide a separate PR for this. After merging it with the master branch it should be backported to 3.6 and 3.5 (3.4 and 3.3 are for security only fixes). Add your name in Misc/ACKS. Changes in Misc/NEWS.d/ are not required.

    @serhiy-storchaka serhiy-storchaka added type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Jul 1, 2017
    @serhiy-storchaka
    Copy link
    Member

    New changeset 98b6bc3 by Serhiy Storchaka (Utkarsh Upadhyay) in branch 'master':
    bpo-30822: Fix testing of datetime module. (bpo-2530)
    98b6bc3

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 2, 2017

    Are there any guides re: backporting commits?

    Just to confirm verify that I'm going about it right; I’m planning on cherry-picking relevant commits back to branch 3.5, 3.6, resolving the merge conflicts, and then opening two separate PRs for them with bpo-30822 in their titles.

    Sounds about right?

    ~
    ut

    @ned-deily
    Copy link
    Member

    Serhiy, it appears that the added tests are taking a long time to run and thus causing many buildbot failures, for example:

    http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%203.x/builds/1013

    @serhiy-storchaka
    Copy link
    Member

    Oh, test.datetimetester.ZoneInfoTest[Europe/Andorra]_Pure_Pure_Pure -- something looks wrong.

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 2, 2017

    I can reproduce the names with _Pure_Pure_Pure if I run the tests with -utzdata. Investigating.

    ~
    ut

    @serhiy-storchaka serhiy-storchaka self-assigned this Jul 2, 2017
    @serhiy-storchaka
    Copy link
    Member

    The quick solution -- just deduplicate test classes.

    But the code needs rewriting. Current code is tricky and fragile. It doesn't work with --list-cases (and I suppose it doesn't work well with other advanced unittest features). This would be not easy.

    @serhiy-storchaka
    Copy link
    Member

    Are there any guides re: backporting commits?

    Just to confirm verify that I'm going about it right; I’m planning on cherry-picking relevant commits back to branch 3.5, 3.6, resolving the merge conflicts, and then opening two separate PRs for them with bpo-30822 in their titles.

    All right. See https://docs.python.org/devguide/committing.html#backporting-changes-to-an-older-version . You can cherry-pick manually or using cherry_picker.py which adds correct prefix to commit message and helps to create a pull request.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 34b5487 by Serhiy Storchaka in branch 'master':
    bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. (bpo-2534)
    34b5487

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 2, 2017

    So the problem is occurring because a single Test class is being instantiated with three different tests here in datetimetester.py:

                for name in ZoneInfo.zonenames():
                    Test = type('ZoneInfoTest[%s]' % name, (ZoneInfoTest,), {})
                    Test.zonename = name
                    for method in dir(Test):
                        if method.startswith('test_'):
                            tests.append(Test(method))

    here: https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py#L4853

    The Test class which is being dynamically created is being instantiated with the test methods: test_folds, test_gaps, test_system_transitions and is being appended to tests. This makes that class to appear thrice in test_classes in test_datetime.py:

        elif issubclass(cls, unittest.TestSuite):
            suit = cls()
            test_classes.extend(type(test) for test in suit)
    

    here: https://github.com/python/cpython/blob/master/Lib/test/test_datetime.py#L34

    Hence, the class gets _Pure and _Fast appended to its name thrice and gets executed thrice, making the tests take 3 times as long to run.

    This is confirmed by changing the code to the following:

               for name in ZoneInfo.zonenames():
                    Test = type('ZoneInfoTest[%s]' % name, (ZoneInfoTest,), {})
                    Test.zonename = name
                    tests.append(Test())
                    # for method in dir(Test):
                    #    if method.startswith('test_'):
                    #        tests.append(Test(method))

    However, I'm not sure what implications this has w.r.t. unittests and the advanced cases.

    The other way to fix it is to create a set out of the classes, as suggested in PR bpo-2534.

    ~
    ut

    @serhiy-storchaka
    Copy link
    Member

    This is confirmed by changing the code to the following:

    Yes, this is other way to fix test_datetime. But this breaks running tests via datetimetester:

    ./python -m test -vuall datetimetester

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 3, 2017

    Hmm, I see; I did not know that.

    I had just assumed that ./python -m test test_* was the standard command for running tests.

    However, if one does run tests using standalone datetimetester (which only imports the _Fast C extension module), then I'll have to rewrite some of the self.skipTest conditions such that they are more defensive, i.e.:

        if '_Pure' not in self.__class__.__name__:
             self.skipTest('...')

    instead of:

        if '_Fast' in self.__class__.__name__:
             self.skipTest('...')

    because some (one?) of the tests fail otherwise.

    Shall I make that change?

    Also, here is an alternate fix which is a tiny bit less murky than straight up de-duplication of test-classes: https://github.com/musically-ut/cpython/pull/1/files

    I'm not sure whether this is any clearer or less fragile, though.

    ~
    ut

    @serhiy-storchaka
    Copy link
    Member

    Good point!

    But datetimetester uses the implementation depending on the availability of the _datetime extension module. If it is not available, the pure Python implementation is used, and other tests are failed.

    I think it would be better to fix first the issues with test_datetime, since this is the common way of running tests, and try to restore running tests with datetimetester in separate issue. Just backport your PR 2530 to 3.5 and 3.6. You can include the change from PR 2534 or it can be backported separately.

    @vstinner
    Copy link
    Member

    vstinner commented Jul 3, 2017

    Regression:

    http://buildbot.python.org/all/builders/PPC64%20Fedora%203.x/builds/1000/steps/test/logs/stdio

    test_system_transitions (test.datetimetester.ZoneInfoTest[America/Juneau]Pure_Pure_Pure) ... Timeout (0:15:00)!
    Thread 0x00003fffa9aa5a20 (most recent call first):
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/datetime.py", line 454 in __new
    _
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/datetime.py", line 1870 in __sub__
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/datetime.py", line 1519 in local
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/datetime.py", line 1532 in _mktime
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/datetime.py", line 1550 in timestamp
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/datetimetester.py", line 4836 in test_system_transitions
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/case.py", line 615 in run
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/case.py", line 663 in __call__
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/suite.py", line 122 in run
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/suite.py", line 84 in __call__
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/suite.py", line 122 in run
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/suite.py", line 84 in __call__
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/unittest/runner.py", line 176 in run
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/support/init.py", line 1896 in _run_suite
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/support/init.py", line 1940 in run_unittest
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/test_datetime.py", line 53 in test_main
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/libregrtest/runtest.py", line 172 in runtest_inner
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/libregrtest/runtest.py", line 140 in runtest
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/libregrtest/main.py", line 290 in rerun_failed_tests
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/libregrtest/main.py", line 540 in _main
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/libregrtest/main.py", line 510 in main
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/libregrtest/main.py", line 585 in main
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/test/main.py", line 2 in <module>
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/runpy.py", line 85 in _run_code
    File "/home/shager/cpython-buildarea/3.x.edelsohn-fedora-ppc64/build/Lib/runpy.py", line 193 in _run_module_as_main
    make: *** [buildbottest] Error 1
    program finished with exit code 2
    elapsedTime=2290.631264

    @vstinner
    Copy link
    Member

    vstinner commented Jul 3, 2017

    http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%203.x/builds/1013/steps/test/logs/stdio

    test_gaps (test.datetimetester.ZoneInfoTest[Europe/Riga]Pure_Pure_Pure) ... ok
    test_system_transitions (test.datetimetester.ZoneInfoTest[Europe/Riga]Pure_Pure_Pure) ... ok
    test_folds (test.datetimetester.ZoneInfoTest[Europe/Riga]Pure_Pure_Pure) ... ok
    test_gaps (test.datetimetester.ZoneInfoTest[Europe/Riga]Pure_Pure_Pure) ... ok
    test_system_transitions (test.datetimetester.ZoneInfoTest[Europe/Riga]Pure_Pure_Pure) ... ok
    test_folds (test.datetimetester.ZoneInfoTest[Europe/Riga]Pure_Pure_Pure) ... Timeout (0:15:00)!
    Thread 0x400c9110 (most recent call first):
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 263 in _check_int_field
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 281 in _check_date_fields
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 1376 in __new

    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 1600 in replace
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/datetimetester.py", line 4776 in test_folds
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/case.py", line 615 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/case.py", line 663 in __call

    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 122 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 84 in __call

    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 122 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 84 in __call__
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/runner.py", line 176 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/support/init.py", line 1896 in _run_suite
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/support/init.py", line 1940 in run_unittest
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/test_datetime.py", line 53 in test_main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/runtest.py", line 172 in runtest_inner
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/runtest.py", line 140 in runtest
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 290 in rerun_failed_tests
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 540 in _main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 510 in main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 585 in main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/main.py", line 2 in <module>
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/runpy.py", line 85 in _run_code
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/runpy.py", line 193 in _run_module_as_main
    make: *** [buildbottest] Error 1
    program finished with exit code 2
    elapsedTime=2225.001566

    @vstinner
    Copy link
    Member

    vstinner commented Jul 3, 2017

    Oh, I didn't read the issue. In fact, it seems like the commit 34b5487 already repaired buildbots (x86 Tiger 3.x at least).

    But... test_datetime became the *slowest* test of x86 Tiger 3.x:

    10 slowest tests:

    • test_datetime: 19 min 6 sec
    • test_tools: 7 min 20 sec
    • test_multiprocessing_spawn: 6 min 54 sec
    • ...

    Wait, 19 minutes to test datetime??? What's wrong with test_datetime?

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 3, 2017

    Previously, test_datetime was running only _Fast tests (i.e. testing the C module). Then (because of an erring commit from me), testing for _Pure implementation started but all tests per time-zone started running thrice instead of once. Hence, the timeouts while testing were triggered, breaking the buildbots. (Err ... sorry about that.)

    However, the latest fix by Serihy now runs each test only once. The _Pure tests, nevertheless, are significantly slower than _Fast tests and, hence, the slowdown.

    Running the tests take ~ 10 minutes on my system with -utzdata enabled; 19 minutes does sound like a bit much but I'm not aware of the specs of the buildbot machines.

    ~
    ut

    @vstinner
    Copy link
    Member

    vstinner commented Jul 3, 2017

    Running the tests take ~ 10 minutes on my system with -utzdata enabled; 19 minutes does sound like a bit much but I'm not aware of the specs of the buildbot machines.

    I don't consider that 10 minutes to test the small datetime module is a reasonable duration. What does take such more time? Do we really need to test all timezones around the world?

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 3, 2017

    Hmm, I don't know if testing every zone is necessary. However, I would not be comfortable picking out the zones one ought to test, considering:

             if ('Riyadh8' in self.zonename or
                # From tzdata NEWS file:
                # The files solar87, solar88, and solar89 are no longer distributed.
                # They were a negative experiment - that is, a demonstration that
                # tz data can represent solar time only with some difficulty and error.
                # Their presence in the distribution caused confusion, as Riyadh
                # civil time was generally not solar time in those years.
    self.zonename.startswith('right/')):

    and:

    Iran had a sub-minute UTC offset before 1946.

    in https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py#L4865

    Perhaps @belopolsky can suggest something? (Already in Nosy List).

    ~
    ut

    @serhiy-storchaka
    Copy link
    Member

    Let discuss too long time of testing datetime time zones in separate issue.

    @vstinner
    Copy link
    Member

    vstinner commented Jul 3, 2017

    I would prefer to make test_datetime faster in master before backporting.

    @vstinner
    Copy link
    Member

    vstinner commented Jul 5, 2017

    It's not just a matter of making test_datetime "faster". I see it as a regression, since now it fails randomly on slow buildbots.

    Maybe we should revert the change until a solution is found.

    http://buildbot.python.org/all/builders/ARMv7%20Ubuntu%203.x/builds/1025/steps/test/logs/stdio

    running: test_datetime (802 sec)
    running: test_datetime (832 sec)
    running: test_datetime (862 sec)
    running: test_datetime (892 sec)
    0:15:02 load avg: 2.30 [406/406/1] test_datetime crashed (Exit code 1)
    Timeout (0:15:00)!
    Thread 0x400b4110 (most recent call first):
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 394 in __new__
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 1519 in local
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 1522 in _mktime
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/datetime.py", line 1550 in timestamp
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/datetimetester.py", line 4836 in test_system_transitions
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/case.py", line 615 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/case.py", line 663 in __call__
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 122 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 84 in __call__
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 122 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/suite.py", line 84 in __call__
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/unittest/runner.py", line 176 in run
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/support/init.py", line 1896 in _run_suite
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/support/init.py", line 1940 in run_unittest
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/test_datetime.py", line 54 in test_main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/runtest.py", line 172 in runtest_inner
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/runtest.py", line 130 in runtest
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/runtest_mp.py", line 71 in run_tests_slave
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 519 in _main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 512 in main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/libregrtest/main.py", line 587 in main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/regrtest.py", line 46 in _main
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/regrtest.py", line 50 in <module>
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/runpy.py", line 85 in _run_code
    File "/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/runpy.py", line 193 in _run_module_as_main

    @serhiy-storchaka
    Copy link
    Member

    Another solution -- disable "cpu" and "tzdata" resources on slow buildbots (see bpo-30417).

    @vstinner
    Copy link
    Member

    vstinner commented Jul 5, 2017

    New changeset 8207c17 by Victor Stinner in branch 'master':
    Revert "bpo-30822: Fix testing of datetime module." (bpo-2588)
    8207c17

    @vstinner
    Copy link
    Member

    vstinner commented Jul 5, 2017

    I reverted the change to repair buildbots and get more time to find a proper fix:
    #2588 (comment)

    @vstinner
    Copy link
    Member

    vstinner commented Jul 5, 2017

    Another solution -- disable "cpu" and "tzdata" resources on slow buildbots (see bpo-30417).

    I didn't read test_datetime. How test_datetime can spend 20 minutes to test timestamps? Does it spawn subprocesses? Why is it so slow?

    @abalkin
    Copy link
    Member

    abalkin commented Jul 5, 2017

    Why is it so slow?

    The tests enabled by "-utzdata" check UTC to local and back conversions at several points around *every* time transition in *every* timezone. On systems with a complete installation of IANA tzdata, this is a lot of test points.

    These tests were supposed to be exhaustive and I did not expect them to be run by default. that's why I introduced the -utzdata flag in the first place.

    @vstinner
    Copy link
    Member

    vstinner commented Jul 5, 2017

    These tests were supposed to be exhaustive and I did not expect them to be run by default. that's why I introduced the -utzdata flag in the first place.

    Buildbots use "-u all" and so enables tzdata tests. Is it useful to
    run all these tests on all branches for each Python commit?

    Maybe we should disable these tests on all CI, and maybe setup a
    buildbot which runs these tests?

    Instead of being exhaustive, would it be possible to pick a few
    significant tests?

    @serhiy-storchaka
    Copy link
    Member

    Two timezones (America/New_York and Asia/Tehran) are picked for testing independently from the -utzdata flag.

    @vstinner
    Copy link
    Member

    I reverted the commit which fixes test_datetime to also test Lib/datetime.py, to repair buildbots. But since I reverted the change, nothing was done so datetime.py is still not tested :-(

    The tests enabled by "-utzdata" check UTC to local and back conversions at several points around *every* time transition in *every* timezone. On systems with a complete installation of IANA tzdata, this is a lot of test points.

    These tests were supposed to be exhaustive and I did not expect them to be run by default. that's why I introduced the -utzdata flag in the first place.

    Alexander: yeah, having an opt-in option to test all timezones makes sense. It's likely to trigger bugs in some corner cases. But the question is really having our CI.

    Alexander, Serhiy: would you be ok to disable tzdata resource on all our CI (Travis CI, AppVeyor, all buildbots)?

    *Maybe* we might enable tzdata on selected (fast) buildbots where test_datetime takes less than 20 minutes. But I would prefer to keep the option as an *opt-in*, rather than always running all tests on all CI.

    @vstinner
    Copy link
    Member

    Two timezones (America/New_York and Asia/Tehran) are picked for testing independently from the -utzdata flag.

    By the way, if someone is aware of other interesting timezones, we may also test more timezones (without tzdata)?

    @serhiy-storchaka
    Copy link
    Member

    If testing with -u tzdata is such expensive, tzdata can be excluded from all resources. There is a precedence with the extralargefile resource (see test_zipfile64).

    Actually this means that these test will never run until you request this specially.

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 19, 2017

    So it seems that running the experiments without -utzdata would be an acceptable fix (assuming that there are no other interesting time-zones worthy of explicit testing)?

    Can I help in the resolution of this issue, since resolution of http://bugs.python.org/issue30302 is tangentially conditioned on it. (-:

    @vstinner
    Copy link
    Member

    Serhiy Storchaka: "If testing with -u tzdata is such expensive, tzdata can be excluded from all resources."

    I agree, I wrote a PR for that:
    #2775

    I like using "-u all" without having to remind that a specific resource (tzdata) is too slow to be enabled by default.

    I suggest to backport this change to all branches.

    @vstinner
    Copy link
    Member

    New changeset 5b392bb by Victor Stinner in branch 'master':
    bpo-30822: Exclude tzdata from regrtest --all (bpo-2775)
    5b392bb

    @vstinner
    Copy link
    Member

    New changeset 96ef06f by Victor Stinner in branch '3.6':
    bpo-30822: Exclude tzdata from regrtest --all (bpo-2775) (bpo-2777)
    96ef06f

    @vstinner
    Copy link
    Member

    New changeset 645e503 by Victor Stinner in branch '3.5':
    bpo-30822: Exclude tzdata from regrtest --all (bpo-2775) (bpo-2781)
    645e503

    @vstinner
    Copy link
    Member

    (Oops, I gone too fast in my 3.5 backport. tzdata was only introduced in Python 3.6, for me it was something older. I wrote a new fix for 3.5, to only add extralargefile, but don't add tzdata.)

    @vstinner
    Copy link
    Member

    New changeset bf3a1e9 by Victor Stinner in branch '3.5':
    bpo-30822: regrtest: remove tzdata (bpo-2782)
    bf3a1e9

    @vstinner
    Copy link
    Member

    New changeset 80ebc43 by Victor Stinner in branch '2.7':
    bpo-30822: regrtest: fix -u extralargefile (bpo-2788)
    80ebc43

    @vstinner
    Copy link
    Member

    New changeset 287c559 by Victor Stinner (Utkarsh Upadhyay) in branch 'master':
    bpo-30822: Fix testing of datetime module. (bpo-2530) (bpo-2783)
    287c559

    @vstinner
    Copy link
    Member

    Utkarsh comment on the PR:

    I'm afraid I don't really know how to read the waterfall chart at http://buildbot.python.org/all/waterfall.

    Yeah, sorry about this awful view :-) We now have a mailing list getting notifications when a buildbot fails:
    https://mail.python.org/mm3/mailman3/lists/buildbot-status.python.org/

    We got two new failures since yesterday on Windows buildbots, but it's related to IDLE and so unrelated to your change. So a quick check says that test_datetime doesn't time out anymore!

    Previously, the test failed on a few buildbots. I checked the test output to look if test_datetime became the new slowest test and ... no. For example, on PPC64 Fedora 3.x, test_datetime is not even listed in the "10 slowest tests", which means that it took 36 sec or less, whereas the test took longer than 15 minutes when tzdata was used.

    IMHO you can already cook a first backport for 3.6, but I would prefer to wait another day just to make sure to everything is fine (to wait for new buildbot builds).

    @vstinner
    Copy link
    Member

    New changeset c52cea4 by Victor Stinner (Utkarsh Upadhyay) in branch '3.6':
    [3.6] bpo-30822: Fix testing of datetime module. (GH-2530) (GH-2783) (bpo-2816)
    c52cea4

    @vstinner
    Copy link
    Member

    Ok, I merged the change in the 3.6 branch.

    I decided to not merge the 3.5 change, since it's now too late: 3.5 slowly enters a new security-only fixes:
    #2815

    Thanks Utkarsh Upadhyay for your work on datetime, not only this issue, but also repr(timedelta) (and maybe also timedelta constructor doc later? ;-)).

    @musically-ut
    Copy link
    Mannequin Author

    musically-ut mannequin commented Jul 26, 2017

    Thanks Victor! \o/

    Secretly, I'm just happy that my legacy will not be a commit which broke all (?) the build-bots and had to be reverted. :P

    W.r.t. the docs; in retrospect, that'll probably have a larger impact on the end-users and is less likely to cause disagreement. I probably should have led with that. :)

    ~
    ut

    @vstinner
    Copy link
    Member

    Secretly, I'm just happy that my legacy will not be a commit which broke all (?) the build-bots and had to be reverted. :P

    Reverting is a new policy that we decided last June:
    https://mail.python.org/pipermail/python-committers/2017-June/004588.html

    Sorry that your commit was the first guilty, but honestly, it was a wise decision since it allowed to discuss how to handle tzdata without the pressure of broken buildbots. Nowadays, Python relies much more on CI for pull requests than before the migration to GitHub.

    Well, read the thread if you want to know the full rationale.

    @vstinner
    Copy link
    Member

    vstinner commented Sep 8, 2017

    New changeset 3892799 by Victor Stinner (Miss Islington (bot)) in branch '3.6':
    [3.6] bpo-30822: Deduplicate ZoneInfoTest classes in test_datetime. (GH-2534) (bpo-3405)
    3892799

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants