Replace tearDown with addCleanup in cinder unit tests
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
- Started by
- Completed by
- Sean McGinnis
Related branches
Related bugs
Sprints
Whiteboard
Gerrit topic: https:/
Addressed by: https:/
Replace tearDown with addCleanup
Addressed by: https:/
Replace tearDown with addCleanup in cinder/tests/brick/
Addressed by: https:/
Replace tearDown with addCleanup - Part 3
Addressed by: https:/
Replace tearDown with addCleanup - Part 4
Addressed by: https:/
Replace tearDown with addCleanup - Part 4
Addressed by: https:/
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://