manila unit tests should not mock DB functions

Bug #1528227 reported by Valeriy Ponomaryov on 2015-12-21
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Manila
Wishlist
Unassigned

Bug Description

Manila has lots of unit tests that mock DB functions and verify things based on fake return values. This makes harm in several ways:

1) Return results are dicts and not DB objects, hence, DB objects methods can not be used in main code.

2) Having fake dict results mocks it is possible to have incorrect answer from DB function.

Proposal: use existing test DB in unit tests, not mocking DB functions.

summary: - manila unit tests should not mock DB methods
+ manila unit tests should not mock DB functions
tags: added: db tests
description: updated
description: updated
Changed in manila:
importance: Undecided → Low
Changed in manila:
assignee: nobody → Valeriy Ponomaryov (vponomaryov)
status: New → In Progress
Changed in manila:
assignee: Valeriy Ponomaryov (vponomaryov) → Clinton Knight (clintonk)
Changed in manila:
assignee: Clinton Knight (clintonk) → nobody
assignee: nobody → Valeriy Ponomaryov (vponomaryov)

Reviewed: https://review.openstack.org/259024
Committed: https://git.openstack.org/cgit/openstack/manila/commit/?id=7319e0fe6f52c74b09fbfb4bca49ef49322ecc0e
Submitter: Jenkins
Branch: master

commit 7319e0fe6f52c74b09fbfb4bca49ef49322ecc0e
Author: Valeriy Ponomaryov <email address hidden>
Date: Thu Dec 17 15:53:40 2015 +0200

    Refactor share metadata tests to use DB

    For the moment tests in 'manila.tests.api.v1.test_share_metadata' module
    mock all DB requests.
    It leads to failures in main code if we use DB-specific things.
    So, refactor all tests in that module to use test DB to unblock usage of
    DB-specific things.

    Change-Id: Ia584e3e6bd02f937df7630a1d09d49c888f77c8f
    Partial-Bug: #1528227

Reviewed: https://review.openstack.org/280828
Committed: https://git.openstack.org/cgit/openstack/manila/commit/?id=5e4d589c54716aa990d1f39d98e67497e305d60e
Submitter: Jenkins
Branch: stable/liberty

commit 5e4d589c54716aa990d1f39d98e67497e305d60e
Author: Valeriy Ponomaryov <email address hidden>
Date: Thu Dec 17 15:53:40 2015 +0200

    Refactor share metadata tests to use DB

    For the moment tests in 'manila.tests.api.v1.test_share_metadata' module
    mock all DB requests.
    It leads to failures in main code if we use DB-specific things.
    So, refactor all tests in that module to use test DB to unblock usage of
    DB-specific things.

    Change-Id: Ia584e3e6bd02f937df7630a1d09d49c888f77c8f
    Partial-Bug: #1528227
    (cherry picked from commit 7319e0fe6f52c74b09fbfb4bca49ef49322ecc0e)

tags: added: in-stable-liberty
Changed in manila:
assignee: Valeriy Ponomaryov (vponomaryov) → nobody
Changed in manila:
status: In Progress → New
Changed in manila:
assignee: nobody → NidhiMittalHada (nidhimittal19)
Goutham Pacha Ravi (gouthamr) wrote :

This bug is an RFE on a lot of unit tests in the tree. It's possible that we have bugs in the code that have not been caught by these wrongly-mocked unit tests or the functional/scenario/integration testing we do with tempest in Devstack/OOO/Kolla environments. However, this bug report will not be able to track them all. I'm inclined to say this is test-only.

If someone wants to pick this up and resolve the unit tests in parts or fully, please do, your contributions are always welcome!

tags: added: low-hanging-fruit
removed: in-stable-liberty
Changed in manila:
status: New → Confirmed
assignee: NidhiMittalHada (nidhimittal19) → nobody
importance: Low → Wishlist
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers