[SERVER-21801] CheckReplDBHash testing hook should check document type (resmoke.py) Created: 08/Dec/15  Updated: 18/Nov/16  Resolved: 22/Jan/16

Status: Closed
Project: Core Server
Component/s: Testing Infrastructure
Affects Version/s: 3.2.0
Fix Version/s: 3.2.3, 3.3.1

Type: Bug Priority: Minor - P4
Reporter: Robert Guo (Inactive) Assignee: Michael Grundy
Resolution: Done Votes: 0
Labels: test-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-21800 updates that implicitly change type m... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Completed:
Sprint: TIG E (01/08/16), TIG F (01/29/16)
Participants:
Linked BF Score: 0

 Description   

Instead of doing

primary_doc == secondary_doc #hooks.py

to compare 2 documents, we should check that each field is of the same type. We could miss things like:

>>> -9.223372036854776e+18 == -9223372036854775808
True



 Comments   
Comment by Githook User [ 25/Jan/16 ]

Author:

{u'username': u'mgrundy', u'name': u'Mike Grundy', u'email': u'michael.grundy@10gen.com'}

Message: SERVER-21801 CheckReplDBHash testing hook should check document type (resmoke.py)

(cherry picked from commit ca39291d733cb2171be6bddcdda8ace8851b1906)
Branch: v3.2
https://github.com/mongodb/mongo/commit/30b0de8351b6050925835cb8c211740d54abbe24

Comment by Githook User [ 22/Jan/16 ]

Author:

{u'username': u'mgrundy', u'name': u'Mike Grundy', u'email': u'michael.grundy@10gen.com'}

Message: SERVER-21801 CheckReplDBHash testing hook should check document type (resmoke.py)
Branch: master
https://github.com/mongodb/mongo/commit/ca39291d733cb2171be6bddcdda8ace8851b1906

Comment by Bernie Hackett [ 10/Dec/15 ]

I suppose you could create a new subclass of dict to do that, or monkey patch SON, but we wouldn't make that change in PyMongo. SON works like OrderedDict:

>>> 1.0 == 1
True
>>> {'a': 1} == {'a': 1.0}
True
>>> from collections import OrderedDict
>>> OrderedDict([('a', 1)]) == OrderedDict([('a', 1.0)])
True

Comment by Max Hirschhorn [ 10/Dec/15 ]

One option is to extend the bson.SON class and override the __eq__() method to make it check that the types of the values are also equal. Effectively we want bson.SON([('a', int(1))]) == bson.SON([('a', float(1))]) to return false instead of true.

behackett, thoughts?

Comment by Robert Guo (Inactive) [ 08/Dec/15 ]

Oops, I forgot to mention this was Python code.

Comment by Eric Milkie [ 08/Dec/15 ]

Triple equals to the rescue?

Generated at Thu Feb 08 03:58:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.