Thang, Thanks! Its still not clear to me why my method doesn't work. FWIW, i did try db.snapshot_get = mock.Mock(...) before and when that didn't work, i was just trying out with remotefs.db.snapshot_get with the assumption that maybe some scope issue is there hence I should try using the complete path right from module, but that didn't work either and i guess its still not clear why a mock in one test module affects another.
Given that mock.patch is working as evident from your patch, i will continue to use it. Thanks for helping out. On Thu, Jun 4, 2015 at 9:21 PM, Thang Pham <[email protected]> wrote: > The problem is in your test case. There is no such methods as > "remotefs.db.snapshot_get" or "remotefs.db.snapshot_admin_metadata_get". > You need to use "with mock.patch('cinder.db.snapshot_get') as snapshot_get, > mock.patch('cinder.db.snapshot_admin_metadata_get') > as snapshot_admin_metadata_get". These incorrect calls somehow created a > side effect in the other test cases. I updated you patch with what is > correct, so you should follow it for you other tests. Your test case needs > a lot more work, I just edited it to just have it pass the unit tests. > > Thang > > On Thu, Jun 4, 2015 at 4:36 AM, Deepak Shetty <[email protected]> wrote: > >> I was able to narrow down to the scenario where it fails only when i do: >> >> ./run_tests.sh -N cinder.tests.unit.test_remotefs >> cinder.tests.unit.test_volume.VolumeTestCase >> >> and fails with: >> {0} >> cinder.tests.unit.test_volume.VolumeTestCase.test_can_delete_errored_snapshot >> [0.507361s] ... FAILED >> >> Captured traceback: >> ~~~~~~~~~~~~~~~~~~~ >> Traceback (most recent call last): >> File "cinder/tests/unit/test_volume.py", line 3029, in >> test_can_delete_errored_snapshot >> snapshot_obj = objects.Snapshot.get_by_id(self.context, >> snapshot_id) >> File >> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 169, >> in wrapper >> result = fn(cls, context, *args, **kwargs) >> File "cinder/objects/snapshot.py", line 130, in get_by_id >> expected_attrs=['metadata']) >> File "cinder/objects/snapshot.py", line 112, in _from_db_object >> snapshot[name] = value >> File >> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 691, >> in __setitem__ >> setattr(self, name, value) >> File >> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", line 70, >> in setter >> field_value = field.coerce(self, name, value) >> File >> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/fields.py", line >> 183, in coerce >> return self._null(obj, attr) >> File >> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/fields.py", line >> 161, in _null >> raise ValueError(_("Field `%s' cannot be None") % attr) >> ValueError: Field `volume_id' cannot be None >> >> Both the testsuites run fine when i run them individually, as in the >> below is success: >> >> ./run_tests.sh -N cinder.tests.unit.test_remotefs - no errors >> >> ./run_tests.sh -N cinder.tests.unit.test_volume.VolumeTestCase - no errors >> >> So i modified my patch @ https://review.openstack.org/#/c/172808/ (Patch >> set 6) and >> removed all testcase i added in test_remotefs.py except one, so that we >> have lesser code to debug/deal with! >> >> See >> https://review.openstack.org/#/c/172808/6/cinder/tests/unit/test_remotefs.py >> >> Now when i disable test_create_snapshot_online_success then running both >> the suites work, >> but when i enable test_create_snapshot_online_success then it fails as >> above. >> >> I am unable to figure whats the connection between >> test_create_snapshot_online_success >> in test_remotefs.py >> and VolumeTestCase.test_can_delete_errored_snapshot in test_volume.py >> failure >> >> Can someone help here ? >> >> thanx, >> deepak >> >> >> >> On Thu, Jun 4, 2015 at 1:37 PM, Deepak Shetty <[email protected]> >> wrote: >> >>> Hi Thang, >>> Since you are working on Snapshot Objects, any idea on why the >>> testcase when run all by itself, works, but when run as part of the overall >>> suite, fails ? >>> This seems to be related to the Snapshot Objects, hence Ccing you. >>> >>> On Wed, Jun 3, 2015 at 9:54 PM, Deepak Shetty <[email protected]> >>> wrote: >>> >>>> Hi All, >>>> I am hitting a strange issue when running Cinder unit tests against >>>> my patch @ >>>> https://review.openstack.org/#/c/172808/5 >>>> >>>> I have spent 1 day and haven't been successfull at figuring how/why my >>>> patch is causing it! >>>> >>>> All tests failing are part of VolumeTestCase suite and from the error >>>> (see below) it seems >>>> the Snapshot Object is complaining that 'volume_id' field is null >>>> (while it shouldn't be) >>>> >>>> An example error from the associated Jenkins run can be seen @ >>>> >>>> http://logs.openstack.org/08/172808/5/check/gate-cinder-python27/0abd15e/console.html.gz#_2015-05-22_13_28_47_140 >>>> >>>> I am seeing a total of 21 such errors. >>>> >>>> Its strange because, when I try to reproduce it locally in my devstack >>>> env, I see the below: >>>> >>>> 1) When i just run: ./run_tests.sh -N cinder.tests.unit.test_volume. >>>> VolumeTestCase >>>> all testcases pass >>>> >>>> 2) When i run 1 individual testcase: ./run_tests.sh -N >>>> cinder.tests.unit.test_volume.VolumeTestCase.test_delete_busy_snapshot >>>> that passes too >>>> >>>> 3) When i run : ./run_tests.sh -N >>>> I see 21 tests failing and all are failing with error similar to the >>>> below >>>> >>>> {0} cinder.tests.unit.test_volume.VolumeTestCase.test_delete_busy_snapshot >>>> [0.537366s] ... FAILED >>>> >>>> Captured traceback: >>>> ~~~~~~~~~~~~~~~~~~~ >>>> Traceback (most recent call last): >>>> File "cinder/tests/unit/test_volume.py", line 3219, in >>>> test_delete_busy_snapshot >>>> snapshot_obj = objects.Snapshot.get_by_id(self.context, >>>> snapshot_id) >>>> File >>>> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", >>>> line 163, in wrapper >>>> result = fn(cls, context, *args, **kwargs) >>>> File "cinder/objects/snapshot.py", line 130, in get_by_id >>>> expected_attrs=['metadata']) >>>> File "cinder/objects/snapshot.py", line 112, in _from_db_object >>>> snapshot[name] = value >>>> File >>>> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", >>>> line 675, in __setitem__ >>>> setattr(self, name, value) >>>> File >>>> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/base.py", >>>> line 70, in setter >>>> field_value = field.coerce(self, name, value) >>>> File >>>> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/fields.py", >>>> line 182, in coerce >>>> return self._null(obj, attr) >>>> File >>>> "/usr/lib/python2.7/site-packages/oslo_versionedobjects/fields.py", >>>> line 160, in _null >>>> raise ValueError(_("Field `%s' cannot be None") % attr) >>>> ValueError: Field `volume_id' cannot be None >>>> >>>> Any suggestions / thoughts on why this could be happening ? >>>> >>>> thanx, >>>> deepak >>>> >>> >>> >> >
__________________________________________________________________________ OpenStack Development Mailing List (not for usage questions) Unsubscribe: [email protected]?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
