Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture plug exceptions into the test record #614

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fahhem
Copy link
Collaborator

@fahhem fahhem commented Jul 25, 2017

This change is Reviewable

"""When the framework throws an exception, turn it into a failure code."""
if self.test_state and not self.test_state.is_finalized:
self.test_state.test_record.add_outcome_details(exc_type.__name__, exc_val.message)
return True
Copy link
Contributor

Choose a reason for hiding this comment

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

This is going to be a departure from the previous logic, which suppressed only in the case of ThreadTerminationError. Is that intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree we should look into this more.

  • Looking at util/threads.py it seems like this is mainly a matter of logging (if the exception is suppressed, it is not printed or logged, otherwise, it is sent to both logging.exception and stderr) or am I missing another side effect that can occur as a result of the thread raising an exception?
  • It seems like returning True here risks silencing some errors completely (except for the outcome detail added to the test record). Errors in plug initialization are logged in PlugManager.initialize_plugs but other errors might be silenced.
  • I noticed PhaseExecutorThread has sort of the opposite behavior—it never suppresses exceptions. It also makes its own call to logger.exception, so in the console you get “Phase <...> raised an exception” followed by “Thread raised an exception” followed by “Exception in thread” (three printouts of the same exception). We should see if the logging behavior can be more consistent (and not unnecessarily repetitive?).

@@ -224,3 +249,4 @@ def test_execute_run_if_false(self):
def test_execute_phase_return_skip(self):
result = self.phase_executor.execute_phase(phase_return_skip)
self.assertEqual(PhaseResult.SKIP, result.phase_result)

Copy link
Contributor

Choose a reason for hiding this comment

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

Extra newline

def _thread_exception(self, exc_type, exc_val, exc_tb):
"""When the framework throws an exception, turn it into a failure code."""
if self.test_state and not self.test_state.is_finalized:
self.test_state.test_record.add_outcome_details(exc_type.__name__, exc_val.message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Line length > 80

@@ -146,6 +146,12 @@ def _thread_proc(self):

# Everything is set, set status and begin test execution.
self._execute_test_phases(phase_exec)

def _thread_exception(self, exc_type, exc_val, exc_tb):
"""When the framework throws an exception, turn it into a failure code."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should clarify When the framework throws an exception a little more. Looks like this is called when an exception is raised inside a test but outside of all phases?

"""When the framework throws an exception, turn it into a failure code."""
if self.test_state and not self.test_state.is_finalized:
self.test_state.test_record.add_outcome_details(exc_type.__name__, exc_val.message)
return True
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree we should look into this more.

  • Looking at util/threads.py it seems like this is mainly a matter of logging (if the exception is suppressed, it is not printed or logged, otherwise, it is sent to both logging.exception and stderr) or am I missing another side effect that can occur as a result of the thread raising an exception?
  • It seems like returning True here risks silencing some errors completely (except for the outcome detail added to the test record). Errors in plug initialization are logged in PlugManager.initialize_plugs but other errors might be silenced.
  • I noticed PhaseExecutorThread has sort of the opposite behavior—it never suppresses exceptions. It also makes its own call to logger.exception, so in the console you get “Phase <...> raised an exception” followed by “Thread raised an exception” followed by “Exception in thread” (three printouts of the same exception). We should see if the logging behavior can be more consistent (and not unnecessarily repetitive?).

@wallacbe
Copy link
Collaborator

wallacbe commented Aug 9, 2017

I'm also not seeing the logger in the plug show up in the test record, example self.logger.info('blah'). Does this PR address that also? Thanks

@fahhem
Copy link
Collaborator Author

fahhem commented Aug 9, 2017

I don't think so. That should be in the test record already...

@wallacbe
Copy link
Collaborator

wallacbe commented Aug 9, 2017

Ah I see it in test record when run within a phase, I don't see it when called in tearDown

@jettisonjoe
Copy link
Contributor

@Kenadia is this PR still needed? Looks like it's getting stale sitting here.

@wallacbe
Copy link
Collaborator

Having plug exceptions into the test record would still be useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants