"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cinder/tests/unit/test_cleanable_manager.py" between
cinder-15.5.0.tar.gz and cinder-15.6.0.tar.gz

About: OpenStack Cinder (Core Service: Block Storage) provides persistent block storage to running instances. Its pluggable driver architecture facilitates the creation and management of block storage devices.
The "Train" series (maintained release).

test_cleanable_manager.py  (cinder-15.5.0):test_cleanable_manager.py  (cinder-15.6.0)
skipping to change at line 111 skipping to change at line 111
self.assertEqual(1, len(workers)) self.assertEqual(1, len(workers))
self.assertEqual(worker2.id, workers[0].id) self.assertEqual(worker2.id, workers[0].id)
vol.refresh() vol.refresh()
self.assertEqual('creating_cleaned', vol.status) self.assertEqual('creating_cleaned', vol.status)
vol2.refresh() vol2.refresh()
self.assertEqual('deleting', vol2.status) self.assertEqual('deleting', vol2.status)
def test_do_cleanup_not_cleaning_already_claimed_by_us(self): def test_do_cleanup_not_cleaning_already_claimed_by_us(self):
"""Basic cleanup that doesn't touch other thread's claimed works.""" """Basic cleanup that doesn't touch other thread's claimed works."""
original_time = timeutils.utcnow() now = timeutils.utcnow()
other_thread_claimed_time = timeutils.utcnow() delta = timeutils.datetime.timedelta(seconds=1)
original_time = now - delta
# Creating the worker in the future, and then changing the in-memory
# value of worker2.updated_at to an earlier time, we effectively
# simulate that the worker entry was created in the past and that it
# has been just updated between worker_get_all and trying
# to claim a work for cleanup
other_thread_claimed_time = now + delta
vol = utils.create_volume(self.context, status='creating') vol = utils.create_volume(self.context, status='creating')
worker1 = db.worker_create(self.context, status='creating', worker1 = db.worker_create(self.context, status='creating',
resource_type='Volume', resource_id=vol.id, resource_type='Volume', resource_id=vol.id,
service_id=self.service.id, service_id=self.service.id,
updated_at=original_time) updated_at=original_time)
worker1 = db.worker_get(self.context, id=worker1.id) worker1 = db.worker_get(self.context, id=worker1.id)
vol2 = utils.create_volume(self.context, status='deleting') vol2 = utils.create_volume(self.context, status='deleting')
worker2 = db.worker_create(self.context, status='deleting', worker2 = db.worker_create(self.context, status='deleting',
resource_type='Volume', resource_id=vol2.id, resource_type='Volume', resource_id=vol2.id,
service_id=self.service.id, service_id=self.service.id,
updated_at=other_thread_claimed_time) updated_at=other_thread_claimed_time)
worker2 = db.worker_get(self.context, id=worker2.id) worker2 = db.worker_get(self.context, id=worker2.id)
# This with the mock below simulates worker2 was created in the past
# Simulate that the change to vol2 worker happened between # and updated right between worker_get_all and worker_claim_for_cleanup
# worker_get_all and trying to claim a work for cleanup
worker2.updated_at = original_time worker2.updated_at = original_time
clean_req = objects.CleanupRequest(service_id=self.service.id) clean_req = objects.CleanupRequest(service_id=self.service.id)
mngr = FakeManager(self.service.id) mngr = FakeManager(self.service.id)
with mock.patch('cinder.db.worker_get_all') as get_all_mock: with mock.patch('cinder.manager.timeutils.utcnow', return_value=now),\
mock.patch('cinder.db.worker_get_all') as get_all_mock:
get_all_mock.return_value = [worker1, worker2] get_all_mock.return_value = [worker1, worker2]
mngr.do_cleanup(self.context, clean_req) mngr.do_cleanup(self.context, clean_req)
workers = db.worker_get_all(self.context) workers = db.worker_get_all(self.context)
self.assertEqual(1, len(workers)) self.assertEqual(1, len(workers))
self.assertEqual(worker2.id, workers[0].id) self.assertEqual(worker2.id, workers[0].id)
vol.refresh() vol.refresh()
self.assertEqual('creating_cleaned', vol.status) self.assertEqual('creating_cleaned', vol.status)
vol2.refresh() vol2.refresh()
 End of changes. 3 change blocks. 
6 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)