Merge lp:~jml/launchpad/one-email-on-crash into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Jonathan Lange on 2010-08-26 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11455 |
| Proposed branch: | lp:~jml/launchpad/one-email-on-crash |
| Merge into: | lp:launchpad |
| Prerequisite: | lp:~jml/launchpad/launchpad-tester |
| Diff against target: |
547 lines (+199/-60) 2 files modified
lib/devscripts/ec2test/remote.py (+34/-15) lib/devscripts/ec2test/tests/test_remote.py (+165/-45) |
| To merge this branch: | bzr merge lp:~jml/launchpad/one-email-on-crash |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code | 2010-08-26 | Approve on 2010-08-26 |
|
Review via email:
|
|||
Commit Message
Only send one email when "ec2 test" fails catastrophically.
Description of the Change
ec2 test has a fair bit of stuff in it to make sure that unexpected failures
don't screw things up too badly, and that appropriate folk get told about it.
Unfortunately, in the code currently in Launchpad, there's perhaps a bit too
much redundancy and safety. This code changes things so that you get exactly
one email if ec2 test fails surprisingly.
The reason I wanted to make this change is to:
a) clarify, test and document the way we send email on failure.
b) create separate interfaces for sending email on catastrophe vs normal
test results
c) reduce the amount of email I receive ever so slightly
Landing this branch will make it possible, finally, to free the normal
test email from the shackles of displaying the actual output of the test
runner.
In terms of code changes:
* Refactor EC2Runner & LaunchpadTester to take an SMTPConnection object
and use that for sending mail, thus allowing for easier testing of
what mail gets sent.
* Change WebTestLogger.
rather than got_result.
* Change LaunchpadTester
running the tests. Note: I'm not sure what the reason was for doing so
in the first place.
Thanks,
jml
| Jonathan Lange (jml) wrote : | # |
On Thu, Aug 26, 2010 at 3:13 PM, Michael Nelson
<email address hidden> wrote:
> Review: Approve code
> It would have been nice if the email handling could simply be a logging
> configuration using:
>
> http://
>
> but afaics, that doesn't handle attachments for emails.
>
> Anyway, r=me, with some typos fixed below.
>
>> === modified file 'lib/devscripts
>> --- lib/devscripts/
>> +++ lib/devscripts/
>> @@ -510,6 +519,13 @@
>> summary.
>> traceback.
>> summary.flush()
>> + if self._request.
>> + self._
>> + self._
>> + '\n(See the attached file for the complete log)\n')
>> + summary = self.get_
>> + full_log_gz = gzip_data(
>> + self._
>
> Is it worth reordering the args to send_report_email, so you could instead
> write:
> self._request.
> summary, full_log_gz, successful=False)
>
> Probably not. I just had to look back to see what was False, but it's obvious
> in retrospect :)
>
I won't do it in this branch, for the reasons you give here. I plan a
follow-up branch that will probably change the API & behaviour a bit,
since it would be nice if the subject for "failed tests" is noticeably
different to the subject for "something went horribly wrong".
>> === modified file 'lib/devscripts
>> --- lib/devscripts/
>> +++ lib/devscripts/
>> @@ -60,7 +71,7 @@
>>
>> def make_request(self, branch_url=None, revno=None,
>> trunk=None, sourcecode_
>> - emails=None, pqm_message=None):
>> + emails=None, pqm_message=None, emails_sent=None):
>> """Make a request to test, specifying only things we care about.
>>
>> Note that the returned request object will not ever send email, but
>
> The above comment needs updating with your change.
>
Done.
>> @@ -94,6 +106,13 @@
>> tree.commit(
>> return 'sourcecode/'
>>
>> + def make_tester(self, logger=None, test_directory=
>> + if not logger:
>> + logger = self.make_logger()
>> + if not test_directory:
>> + test_directory = 'unspecified-
>
> why is test_directory optional? If set it like this, I would have assumed
> that Popen() would fail when it tries to change into this directory?
>
> I haven't tried it, but from the docs:
>
> If cwd is not None, the child’s current directory will be changed to cwd
> before it is executed.
>
> [1] http://
>
> We discus...

It would have been nice if the email handling could simply be a logging
configuration using:
http:// docs.python. org/library/ logging. html#smtphandle r
but afaics, that doesn't handle attachments for emails.
Anyway, r=me, with some typos fixed below.
> === modified file 'lib/devscripts /ec2test/ remote. py' ec2test/ remote. py 2010-08-24 17:35:55 +0000 ec2test/ remote. py 2010-08-26 13:19:57 +0000 write(' \n\nERROR IN TESTRUNNER\n\n') print_exception (exc_type, exc_value, exc_tb, file=summary) wants_email: to_filename( filename, summary_ contents( ) self.get_ full_log_ contents( )) send_report_ email(False, summary, full_log_gz)
> --- lib/devscripts/
> +++ lib/devscripts/
> @@ -510,6 +519,13 @@
> summary.
> traceback.
> summary.flush()
> + if self._request.
> + self._write_
> + self._summary_
> + '\n(See the attached file for the complete log)\n')
> + summary = self.get_
> + full_log_gz = gzip_data(
> + self._request.
Is it worth reordering the args to send_report_email, so you could instead
self._ request. send_report_ email(
summary, full_log_gz, successful=False)
write:
Probably not. I just had to look back to see what was False, but it's obvious
in retrospect :)
> === modified file 'lib/devscripts /ec2test/ tests/test_ remote. py' ec2test/ tests/test_ remote. py 2010-08-24 17:44:22 +0000 ec2test/ tests/test_ remote. py 2010-08-26 13:19:57 +0000 path=None,
> --- lib/devscripts/
> +++ lib/devscripts/
> @@ -60,7 +71,7 @@
>
> def make_request(self, branch_url=None, revno=None,
> trunk=None, sourcecode_
> - emails=None, pqm_message=None):
> + emails=None, pqm_message=None, emails_sent=None):
> """Make a request to test, specifying only things we care about.
>
> Note that the returned request object will not ever send email, but
The above comment needs updating with your change.
> @@ -94,6 +106,13 @@ message= str(i)) None, test_options=()): test-directory'
> tree.commit(
> return 'sourcecode/'
>
> + def make_tester(self, logger=None, test_directory=
> + if not logger:
> + logger = self.make_logger()
> + if not test_directory:
> + test_directory = 'unspecified-
why is test_directory optional? If set it like this, I would have assumed
that Popen() would fail when it tries to change into this directory?
I haven't tried it, but from the docs:
If cwd is not None, the child’s current directory will be changed to cwd
before it is executed.
[1] http:// docs.python. org/library/ subprocess. html#module- subprocess
We discussed this:
15:51 < noodles775> jml: why do you set test_directory when it's passed as None?
15:52 < noodles775> (that is, why do you set it to a non-existent directory)
15:52 < jml> noodles775, umm, not sure. maybe because stuff explodes.
15:52 * jml tries.
15:53 < noodles775> According to the docs, I'd assume it wouldn't explode when its None, but will in its current state?
15:53 < noodles775> But yes, science is the best answer :)
15:54 < salgado> thanks for the reviews, noodles775
1...