Replace tearDown with addCleanup in cinder unit tests

Registered by Julia Varlamova

Infra team has indicated that tearDown methods should be replaced with addCleanup in unit tests.
The reason is that all addCleanup methods will be executed even if one of them fails, while a failure in tearDown method can leave the rest of the tearDown un-executed, which can leave stale state laying around.

Moreover, tearDown methods won't run if an exception raises in setUp method, while addCleanup will run in such case.

So, we should replace tearDown with addCleanup methods.

Blueprint information

Status:
Complete
Approver:
None
Priority:
Low
Drafter:
Julia Varlamova
Direction:
Needs approval
Assignee:
Julia Varlamova
Definition:
Obsolete
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Sean McGinnis

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/replace-teardown-with-addcleanup,n,z

Addressed by: https://review.openstack.org/72966
    Replace tearDown with addCleanup

Addressed by: https://review.openstack.org/73271
    Replace tearDown with addCleanup in cinder/tests/brick/

Addressed by: https://review.openstack.org/74040
    Replace tearDown with addCleanup - Part 3

Addressed by: https://review.openstack.org/74334
    Replace tearDown with addCleanup - Part 4

Addressed by: https://review.openstack.org/75323
    Replace tearDown with addCleanup - Part 4

Addressed by: https://review.openstack.org/76876
    Replace tearDown with addCleanup - Part 5

<jdg>
The point is valid, however the problems that arise here in say like Tempest are significantly different than unit tests in the project itself. In Tempest a common problem is the cascade of events when teardown fails. This *can* be a problem in the project unit tests as well and I'm not objecting to switching it but honestly it is very low priority for Cinder unit tests IMO. I'd much rather get the migration to mock finished and clean up the issues we have there first.

http://lists.openstack.org/pipermail/openstack-dev/2013-October/016203.html

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.