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: test_dbm_gnu.test_reorganize() failed on x86-64 High Sierra 3.x
Type: Stage: resolved
Components: macOS, Tests Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, mattbillenstein, miss-islington, ned.deily, ronaldoussoren, serhiy.storchaka, vstinner, xiang.zhang
Priority: normal Keywords: patch

Created on 2018-06-19 08:50 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7786 merged serhiy.storchaka, 2018-06-19 09:25
PR 7787 closed miss-islington, 2018-06-19 10:32
PR 7788 closed miss-islington, 2018-06-19 10:33
PR 7790 closed vstinner, 2018-06-19 11:32
PR 7791 merged vstinner, 2018-06-19 12:04
PR 7794 merged vstinner, 2018-06-19 13:33
PR 7795 merged vstinner, 2018-06-19 14:14
PR 7798 merged vstinner, 2018-06-19 15:43
PR 7801 merged miss-islington, 2018-06-19 16:20
PR 7818 merged vstinner, 2018-06-20 08:43
Messages (24)
msg319942 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 08:50
http://buildbot.python.org/all/#/builders/145/builds/81

x86-64 High Sierra 3.x:

======================================================================
FAIL: test_reorganize (test.test_dbm_gnu.TestGdbm)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_dbm_gnu.py", line 77, in test_reorganize
    self.assertTrue(size0 < size1)
AssertionError: False is not true


The only change of this build is the commit cb970730e3ca2522e9b1700dcaf0a06b7e898db6: bpo-33630. But I hardly believe that it's related.
msg319951 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 10:31
New changeset 22525de737679ace1488e63b7ed289bdb253ffc7 by Serhiy Storchaka in branch 'master':
Use more specific asserts in dbm tests. (GH-7786)
https://github.com/python/cpython/commit/22525de737679ace1488e63b7ed289bdb253ffc7
msg319952 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 11:09
http://buildbot.python.org/all/#/builders/145/builds/84

======================================================================
FAIL: test_reorganize (test.test_dbm_gnu.TestGdbm)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_dbm_gnu.py", line 77, in test_reorganize
    self.assertGreater(size1, size0)
AssertionError: 16777216 not greater than 16777216
----------------------------------------------------------------------
msg319953 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 11:12
16777216 = 2**24 = 16 MiB

Looks too large for the size of an empty database.
msg319954 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 11:14
@Matt Billenstein: Hi! Would you mind to have a look at this issue? It seems like test_dbm_gnu started to fail today. Did you upgrade the buildbot worker recently?
msg319955 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 11:17
For comparison, on Linux size0 = 12288 = 12 KiB. 3 decimal orders smaller.
msg319956 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 11:22
size0=16777216 (16 MiB). On my Fedora 28, size0=12288 (12 KiB).

Even more strange: another test starts by removing the filename, just in case!?

    def test_error_conditions(self):
        # Try to open a non-existent database.
        unlink(filename)
        ...

Maybe the setUp() method must fail if filename already exists?

The buildbot runs tests in subprocesses:
"Run tests in parallel using 2 child processes"

regrtest spawns child procsses which creates their own temporary empty current directory and TESTFN is related to the current directory. If the filename/database existed before test_reorganize(), it's likely a bug in test_dbm_gnu: but there is a single TestCase class with a tearDown() method which calls unlink(filename).

--

Maybe x86-64 High Sierra 3.x has a different dbm library version which always creates an empty database with 16 MiB preallocated on disk!?
msg319957 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 12:00
Ok, I reproduced the issue on macOS High-Sierra and gdbm 1.15. Creating a DB creates a file of 16 MiB.

macbook:master haypo$ brew info gdbm
gdbm: stable 1.15 (bottled)
GNU database manager
https://www.gnu.org/software/gdbm/
/usr/local/Cellar/gdbm/1.15 (19 files, 569.8KB)
  Poured from bottle on 2018-06-19 at 13:48:35
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gdbm.rb
==> Options
--with-libgdbm-compat
	Build libgdbm_compat, a compatibility layer which provides UNIX-like dbm and ndbm interfaces.

and

macbook:master haypo$ ./python.exe
Python 3.8.0a0 (heads/master:22525de, Jun 19 2018, 13:56:57) 
[Clang 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbm.gnu
>>> import os
>>> dbm.gnu.open("x", "c").close()
>>> os.path.getsize("x")
16777216
msg319958 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 12:12
PR 7791 makes the test less useful.

I suggest to replace 10000 with size0 or max(size0, 10000).
msg319959 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 12:19
New changeset 1261bfa83db30b1cf86c1fb816cc167db77874cd by Victor Stinner in branch 'master':
bpo-33901: Fix test_dbm_gnu for gdbm 1.15 (GH-7791)
https://github.com/python/cpython/commit/1261bfa83db30b1cf86c1fb816cc167db77874cd
msg319960 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2018-06-19 13:04
Considering adding gdbm version to pythoninfo? It is possible to expose version info from gnu dbm.
msg319962 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 13:25
Did not increasing the size of the value fixed the test?
msg319963 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 13:34
Xiang: "Considering adding gdbm version to pythoninfo? It is possible to expose version info from gnu dbm."

I wrote PR 7794. What do you think of this?
msg319964 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 13:36
Serhiy Storchaka: "Did not increasing the size of the value fixed the test?"

Honestly, I don't understand the purpose of the test. Why does *Python* check such low level implementation detail, the exact file size used by gdbm? We are supposed to only test the API, no? If someone wants to change something else, I would suggest to remove test_reorganize().
msg319966 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 13:50
How can we test an API if calling it doesn't have any effect? reorganize() can be a no-op method, and still pass the test.
msg319982 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 15:37
New changeset c44d8e5db6fb9d3847c49e9c9718f2b4cf71f506 by Victor Stinner in branch 'master':
bpo-33901: Better test_dbm_gnu.test_reorganize() fix (GH-7795)
https://github.com/python/cpython/commit/c44d8e5db6fb9d3847c49e9c9718f2b4cf71f506
msg319983 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 16:19
New changeset 13c79c677f9ec9437c82eda72fa1c2d288d8fceb by Victor Stinner in branch '3.7':
bpo-33901: Fix test_dbm_gnu for gdbm 1.15 (GH-7798)
https://github.com/python/cpython/commit/13c79c677f9ec9437c82eda72fa1c2d288d8fceb
msg319987 - (view) Author: miss-islington (miss-islington) Date: 2018-06-19 16:45
New changeset fe8122d7b7c747fc344dde8467b09de6b5888d01 by Miss Islington (bot) in branch '3.6':
bpo-33901: Fix test_dbm_gnu for gdbm 1.15 (GH-7798)
https://github.com/python/cpython/commit/fe8122d7b7c747fc344dde8467b09de6b5888d01
msg319988 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-19 17:30
The buildbot is green again!
msg319998 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 21:29
New changeset 00f9edb98dd64e14daf5c44f303deca5cbc3cdeb by Victor Stinner in branch 'master':
bpo-33901: Add _gdbm._GDBM_VERSION (GH-7794)
https://github.com/python/cpython/commit/00f9edb98dd64e14daf5c44f303deca5cbc3cdeb
msg319999 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 21:32
Ok, the test have been fixed in 3.6, 3.7 and master. I added a private version number in master.

If someone wants to add a public version number, please go ahead but open a new issue.
msg320000 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-19 21:33
Thanks Serhiy and Xiang for the reviews and to help to debug this bug.
msg320038 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-20 08:57
Oh, the test also fails on 2.7:

x86-64 High Sierra 2.7
http://buildbot.python.org/all/#builders/140/builds/25

I backported the fix to 2.7: PR 7818.
msg320039 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-20 08:57
New changeset f2918881b7b2e13ed1091dad482aec2382358bcb by Victor Stinner in branch '2.7':
bpo-33901: Fix test_gdbm for gdbm 1.15 (GH-7798) (GH-7818)
https://github.com/python/cpython/commit/f2918881b7b2e13ed1091dad482aec2382358bcb
History
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 78082
2018-06-20 08:57:53vstinnersetstatus: open -> closed
resolution: fixed
versions: + Python 2.7, Python 3.6, Python 3.7
2018-06-20 08:57:42vstinnersetmessages: + msg320039
2018-06-20 08:57:03vstinnersetstatus: closed -> open
resolution: fixed -> (no value)
messages: + msg320038
2018-06-20 08:43:41vstinnersetpull_requests: + pull_request7426
2018-06-19 21:33:25vstinnersetmessages: + msg320000
2018-06-19 21:32:23vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg319999

stage: patch review -> resolved
2018-06-19 21:29:25vstinnersetmessages: + msg319998
2018-06-19 17:57:32barrysetnosy: + barry
2018-06-19 17:30:41serhiy.storchakasetmessages: + msg319988
2018-06-19 16:45:49miss-islingtonsetnosy: + miss-islington
messages: + msg319987
2018-06-19 16:20:38miss-islingtonsetpull_requests: + pull_request7404
2018-06-19 16:19:26vstinnersetmessages: + msg319983
2018-06-19 15:43:06vstinnersetpull_requests: + pull_request7401
2018-06-19 15:37:10vstinnersetmessages: + msg319982
2018-06-19 14:14:41vstinnersetpull_requests: + pull_request7400
2018-06-19 13:50:54serhiy.storchakasetmessages: + msg319966
2018-06-19 13:36:07vstinnersetmessages: + msg319964
2018-06-19 13:34:18vstinnersetmessages: + msg319963
2018-06-19 13:33:45vstinnersetpull_requests: + pull_request7399
2018-06-19 13:25:04serhiy.storchakasetmessages: + msg319962
2018-06-19 13:04:43xiang.zhangsetnosy: + xiang.zhang
messages: + msg319960
2018-06-19 12:19:56vstinnersetmessages: + msg319959
2018-06-19 12:12:04serhiy.storchakasetmessages: + msg319958
2018-06-19 12:04:58vstinnersetpull_requests: + pull_request7396
2018-06-19 12:00:53vstinnersetmessages: + msg319957
2018-06-19 11:32:40vstinnersetpull_requests: + pull_request7395
2018-06-19 11:22:26vstinnersetmessages: + msg319956
2018-06-19 11:17:29serhiy.storchakasetmessages: + msg319955
2018-06-19 11:14:05vstinnersetnosy: + mattbillenstein
messages: + msg319954
2018-06-19 11:12:00serhiy.storchakasetmessages: + msg319953
2018-06-19 11:09:15serhiy.storchakasetmessages: + msg319952
2018-06-19 10:33:00miss-islingtonsetpull_requests: + pull_request7392
2018-06-19 10:32:19miss-islingtonsetpull_requests: + pull_request7391
2018-06-19 10:31:58serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg319951
2018-06-19 09:25:45serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request7390
2018-06-19 08:50:25vstinnercreate