ImageImage

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Running the test suite with --junit-xml and -R incorrectly reports refleaks
Type: Stage:
Components: Tests Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: pablogsal, steve.dower, vstinner
Priority: normal Keywords:

Created on 2020-01-07 23:54 by pablogsal, last changed 2022-04-11 14:59 by admin.

Messages (9)
msg359561 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-01-07 23:54
./python -m test test_list -R : --junit-xml something
0:00:00 load avg: 0.52 Run tests sequentially
0:00:00 load avg: 0.52 [1/1] test_list
beginning 9 repetitions
123456789
.........
test_list leaked [798, 798, 798, 798] references, sum=3192
test_list leaked [345, 345, 345, 345] memory blocks, sum=1380
test_list failed

== Tests result: FAILURE ==

1 test failed:
    test_list

Total duration: 3.4 sec
Tests result: FAILURE
msg359562 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-01-07 23:55
This is going to be very noisy now that we are using  --junit-xml in the buildbots...
msg359563 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-08 00:06
Oh. That explains these strange results on AMD64 RHEL7 Refleaks 3.8:

https://buildbot.python.org/all/#/builders/219/builds/41

 argv: [b'make', b'buildbottest', b'TESTOPTS=-R 3:3 -u-cpu --junit-xml test-results.xml -j10 ${BUILDBOT_TESTOPTS}', b'TESTPYTHONOPTS=', b'TESTTIMEOUT=11700']

...
test_quopri leaked [168, 168, 168] references, sum=504
test_quopri leaked [75, 75, 75] memory blocks, sum=225
1:50:20 load avg: 1.06 Re-running test_future5 in verbose mode
test_future5 leaked [42, 42, 42] references, sum=126
test_future5 leaked [20, 20, 20] memory blocks, sum=60
...

The previous build is successful and it didn't use --junit-xml option:

https://buildbot.python.org/all/#/builders/219/builds/40
msg359606 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-01-08 16:33
We can stop using --junit-xml if we want. GitHub Actions doesn't support displaying test results anyway, so once Azure Pipelines is switched off we'll just be reading the console all the time anyway (unless Buildbot has a way of rendering test results that I haven't noticed?)
msg359608 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2020-01-08 16:35
My guess would be that the reference tracking needs some kind of awareness for logging results. The results are collected as regular Python objects and formatted later, as we need to calculate totals before writing the XML file.

I guess keeping those objects around looks like a leak?
msg359610 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-01-08 16:43
> We can stop using --junit-xml if we want. GitHub Actions doesn't support displaying test results anyway, so once Azure Pipelines is switched off we'll just be reading the console all the time anyway (unless Buildbot has a way of rendering test results that I haven't noticed?)


We are using --junit-xml on the buildbots to analyze failures and in the future we can use it to better display the summary, as is more reliable than parsing the longs.

> I guess keeping those objects around looks like a leak?

Yeah, because it seems that we collect those objects in the innermost runner, while the refleak runner runs the whole "test suite" (the test file, like test_list.py) as one unit.

To be honest, the easiest fix here maybe is just deactivating the --junit and make a warning as in bpo-27103
msg359611 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-01-08 16:44
> deactivating the --junit

I mean deactivating the --junit *if* is used together with -R
msg359612 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-08 16:57
FYI test_io is skipped in Python 2.7 when using -R, because test_io is not reliable. Extract of Lib/test/test_io.py:

    if huntrleaks:
        # FIXME: bpo-31731: test_io hangs with --huntrleaks
        print("Warning: bpo-31731: test_io hangs with --huntrleaks: "
              "exclude the test")
        nottests.add('test_io')

I'm not shocked by disabling JUnit feature when using -R. But I suggest to raise an error and tune the buildbot configuration to not use it, rather than silently ignore the option.
msg359615 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-01-08 17:31
>  But I suggest to raise an error and tune the buildbot configuration to not use it, rather than silently ignore the option.

I already configured the buildbots to not use --junit when running with =R
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83434
2020-01-08 17:31:56pablogsalsetmessages: + msg359615
2020-01-08 16:57:58vstinnersetmessages: + msg359612
2020-01-08 16:44:20pablogsalsetmessages: + msg359611
2020-01-08 16:43:53pablogsalsetmessages: + msg359610
2020-01-08 16:35:53steve.dowersetmessages: + msg359608
2020-01-08 16:33:20steve.dowersetmessages: + msg359606
2020-01-08 00:06:28vstinnersetmessages: + msg359563
2020-01-07 23:55:26pablogsalsetmessages: + msg359562
2020-01-07 23:54:53pablogsalcreate