[openstack-dev] [nova] Do we have some guidelines for mock, stub, mox when writing unit test?

Nikola Đipanov ndipanov at redhat.com
Wed Dec 4 16:16:15 UTC 2013


On 11/19/2013 05:52 PM, Peter Feiner wrote:
> On Tue, Nov 19, 2013 at 11:19 AM, Chuck Short <chuck.short at canonical.com> wrote:
>> Hi
>>
>>
>> On Tue, Nov 19, 2013 at 10:43 AM, Peter Feiner <peter at gridcentric.ca> wrote:
>>>
>>> A substantive reason for switching from mox to mock is the derelict
>>> state of mox releases. There hasn't been a release of mox in three
>>> years: the latest, mox-0.5.3, was released in 2010 [1, 2]. Moreover,
>>> in the past 3 years, substantial bugs have been fixed in upstream mox.
>>> For example, with the year-old fix to
>>> https://code.google.com/p/pymox/issues/detail?id=16, a very nasty bug
>>> in nova would have been caught by an existing test [3].
>>>
>>> Alternatively, a copy of the upstream mox code could be added in-tree.
>>>
>> Please no, I think we are in an agreement with mox3 and mock.
> 
> That's cool. As long as the mox* is phased out, the false-positive
> test results will be fixed.
> 
> Of course, there's _another_ alternative, which is to retrofit mox3
> with the upstream mox fixes (e.g., the bug I cited above exists in
> mox3). However, the delta between mox3 and upstream mox is pretty huge
> (I just checked), so effort is probably better spent switching to
> mock. To that end, I plan on changing the tests I cited above.
> 

Resurrecting this thread because of an interesting review that came up
yesterday [1].

It seems that our lack of a firm decision on what to do with the mocking
framework has left people confused. In hope to help - I'll give my view
of where things are now and what we should do going forward, and
hopefully we'll reach some consensus on this.

Here's the breakdown:

We should abandon mox:
* It has not had a release in over 3 years [2] and a patch upstream for 2
* There are bugs that are impacting the project with it (see above)
* It will not be ported to python 3

Proposed path forward options:
1) Port nova to mock now:
  * Literally unmanageable - huge review overhead and regression risk
for not so much gain (maybe) [1]

2) Opportunistically port nova (write new tests using mock, when fixing
tests, move them to mock):
 * Will take a really long time to move to mock, and is not really a
solution since we are stuck with mock for an undetermined period of time
- it's what we are doing now (kind of).

3) Same as 2) but move current codebase to mox3
 * Buys us py3k compat, and fresher code
 * Mox3 and mox have diverged and we would need to backport mox fixes
onto the mox3 three and become de-facto active maintainers (as per Peter
Feiner's last email - that may not be so easy).

I think we should follow path 3) if we can, but we need to:

1) Figure out what is the deal with mox3 and decide if owning it will
really be less trouble than porting nova. To be hones - I was unable to
even find the code repo for it, only [3]. If anyone has more info -
please weigh in. We'll also need volunteers

2) Make better testing guidelines when using mock, and maybe add some
testing helpers (like we do already have for mox) that will make porting
existing tests easier. mreidem already put this on this weeks nova
meeting agenda - so that might be a good place to discuss all the issues
mentioned here as well.

We should really take a stronger stance on this soon IMHO, as this comes
up with literally every commit.

Cheers,

Nikola

[1] https://review.openstack.org/#/c/59694/
[2] https://pypi.python.org/pypi/mox
[3] https://pypi.python.org/pypi/mox3/0.7.0

> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
> 




More information about the OpenStack-dev mailing list