-
Notifications
You must be signed in to change notification settings - Fork 594
Change local integration tests to use test status objects instead of True/False #1546
Change local integration tests to use test status objects instead of True/False #1546
Conversation
logging.error("Test failed, attempting to clean up") | ||
self.cleanup_test() | ||
raise e | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate except ... as e
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's ok since e
is scoped within each except clause so only 1 will be defined without collision.
if topology_submitted: | ||
logging.error("Test failed, attempting to clean up") | ||
self.cleanup_test() | ||
return status.TestFailure("Exception thrown during test", e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about using try .. except .. finally
clause? https://docs.python.org/2.7/tutorial/errors.html#defining-clean-up-actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good call.
besides comments and style issues, 👍 👍 👍 👍 👍 |
…True/False (#1546) * fix checkstyles * Fixing checkstyles and using finally block
The integration test frameworks return True/False, or sometimes "success"/"fail" to denote a successful or failed test. This changes that so tests can either return a
Success
object or raise aTestFailure
exception.This simplifies the code because all methods in the chain no longer need to check for True/False and log before proceeding. Instead tests proceed assuming success and handle the failure exceptions if thrown. We also don't need topology cleanup calls scattered about, since we can just catch the failure and clean up.
This changes the local integration test, but I plan to change the remote tests similarly in another PR.