Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Change local integration tests to use test status objects instead of True/False #1546

Merged
merged 3 commits into from
Nov 10, 2016

Conversation

billonahill
Copy link
Contributor

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 a TestFailure 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.

@billonahill billonahill added this to the 0.14.5 milestone Nov 9, 2016
@billonahill billonahill self-assigned this Nov 9, 2016
logging.error("Test failed, attempting to clean up")
self.cleanup_test()
raise e
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate except ... as e?

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good call.

@objmagic
Copy link
Contributor

besides comments and style issues, 👍 👍 👍 👍 👍

@billonahill billonahill merged commit 3e9b581 into apache:master Nov 10, 2016
@billonahill billonahill deleted the billg/local_int_test_response branch November 10, 2016 18:45
nicknezis pushed a commit that referenced this pull request Sep 14, 2020
…True/False (#1546)



* fix checkstyles

* Fixing checkstyles and using finally block
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants