Merge lp://staging/~gmb/maas-test/add-reporting-follow-up into lp://staging/maas-test

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: 126
Merged at revision: 99
Proposed branch: lp://staging/~gmb/maas-test/add-reporting-follow-up
Merge into: lp://staging/maas-test
Prerequisite: lp://staging/~gmb/maas-test/add-reporting
Diff against target: 573 lines (+172/-78)
12 files modified
docs/man/maas-test.8.rst (+27/-0)
maastest/console.py (+2/-1)
maastest/main.py (+4/-2)
maastest/parser.py (+8/-0)
maastest/proxyfixture.py (+1/-0)
maastest/report.py (+45/-30)
maastest/tests/test_detect_dhcp.py (+1/-1)
maastest/tests/test_maasfixture.py (+5/-2)
maastest/tests/test_main.py (+1/-1)
maastest/tests/test_report.py (+33/-18)
maastest/tests/test_utils.py (+17/-17)
maastest/utils.py (+28/-6)
To merge this branch: bzr merge lp://staging/~gmb/maas-test/add-reporting-follow-up
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+199255@code.staging.launchpad.net

Description of the change

This is a follow-up to my add-reporting branch in it, I:

 - Reformatted imports using the format-imports utility.
 - Added docstrings for BufferingOutputStream
 - Made maas-test *always* saves test logs to disc unless told not to.
 - Added options to not report to Launchpad and not report at all

To post a comment you must log in.
121. By Graham Binns

Merged trunk.

122. By Graham Binns

More import reformatting.

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Delightful, thanks. A few notes as (almost) always.

.

It looks like a torn-off snippet of text landed inadvertently at the top of docs/man/maas-test.8.rst. A more complete version is about a hundred lines further down.

Where, by the way, it says "By defaults" where I would have expected "By default." And I notice you write "disk" in the documentation but "disc" in the MP — wasn't the last decision in our former Launchpad team to use British English? At any rate, "file" may avoid some unnecessary specificity.

.

In maastest/parser.py, the help texts for the new options are a bit long. Given that the manpage provides more extensive information anyway, can you think of more concise descriptions here? How about respectively “Log results only, do not store them or submit them to Launchpad” and “Store results, but do not submit them to Launchpad”?

.

It's a shame that report_test_results() doesn't have more information about why creating a blob might fail. Also, shouldn't that timestamp be either (a) always in UTC, or (b) be logged with a timezone?

.

Typo: “def test_doest_upload_blob_if_log_only_set(self):” has a “doest” where you probably meant either “doesnt” or, at a stretch, “doth” for 3rd person instead of 2nd.

Consider saying "does_not" instead.

.

In that same test, a spacing typo:

        now =datetime(2013, 12, 17, 7, 18, 0)

Did you run "make lint"?

.

Just below that, you use mock.MagicMock.assert_has_calls(). Mock's design makes that dangerous. If you get everything right, the test passes. If you type it wrong, the test passes. If the assertion doesn't hold but you type it right, the test fails. If the assertion doesn't hold and you type it wrong, the test passes.

It may not seem like much of an issue because in TDD you watch the test fail before you make it pass, but code changes, conditions change, and you want to be sure the test doesn't become a broken alarm light. It's only a tiny change to self.assertIn(call(...), my_mock.mock_calls) which is less prone to false negatives.

.

Typo in the docstring for BufferingOutputStream.__getattr__:

        """Pass-through for any attribute ther than write().

Also, it would be nice to stick to the Python convention of documenting in the imperative: "Pass through any attribute other than `write`."

.

Still in BufferingOutputStream, why is the StringIO import not at the top of the file?

.

Finally, it's not clear to me that BufferingOutputStream actually buffers. Everything about its names and documentation gives me the impression that it collects data in a buffer and only writes it to the stream when the buffer overflows or when the buffer is closed. But the code looks more like a "tee"!

Could you clear that up?

Jeroen

review: Approve
123. By Graham Binns

De-linted.

124. By Graham Binns

Review changes for Jeroen.

125. By Graham Binns

Merged parent branch.

126. By Graham Binns

Renamed BufferingOutputStream -> CachingOutputStream.

Revision history for this message
Graham Binns (gmb) wrote :
Download full text (4.0 KiB)

> Delightful, thanks. A few notes as (almost) always.
>
> .
>
> It looks like a torn-off snippet of text landed inadvertently at the top of
> docs/man/maas-test.8.rst. A more complete version is about a hundred lines
> further down.
>
> Where, by the way, it says "By defaults" where I would have expected "By
> default." And I notice you write "disk" in the documentation but "disc" in
> the MP — wasn't the last decision in our former Launchpad team to use British
> English? At any rate, "file" may avoid some unnecessary specificity.

Gaah, spelling. It's rare that I type "disc" these days, I must have had a giddy moment. Yes, let's go with "file"

> .
>
> In maastest/parser.py, the help texts for the new options are a bit long.
> Given that the manpage provides more extensive information anyway, can you
> think of more concise descriptions here? How about respectively “Log results
> only, do not store them or submit them to Launchpad” and “Store results, but
> do not submit them to Launchpad”?

Yep, those sound fine.

> .
>
> It's a shame that report_test_results() doesn't have more information about
> why creating a blob might fail.

Yeah, I'm not too hot about that, but if there's a failure it's logged by upload_blob() so at least we have something. I found in my experimentations that uploading blobs to Launchpad is at best ill-documented, at worst positively Kafk-esque, so there's not actually that much information to be had in the first place. (Worst yet is the fact that for all our hoop-jumping here, there's every possibility that the LP side of blob processing could change in the future and it would just start silently dropping our now non-compliant blobs).

> Also, shouldn't that timestamp be either (a)
> always in UTC, or (b) be logged with a timezone?

For the sake of my sanity, I've changed it to use datetime.utcnow() instead of datetime.now(), but I'm not sure how to test that. Any ideas?

> Typo: “def test_doest_upload_blob_if_log_only_set(self):” has a “doest” where
> you probably meant either “doesnt” or, at a stretch, “doth” for 3rd person
> instead of 2nd.
>
> Consider saying "does_not" instead.

Fixed.

>
> In that same test, a spacing typo:
>
> now =datetime(2013, 12, 17, 7, 18, 0)
>
> Did you run "make lint"?

Whoops. No, I forgot it's not run automatically.

> .
>
> Just below that, you use mock.MagicMock.assert_has_calls(). Mock's design
> makes that dangerous. If you get everything right, the test passes. If you
> type it wrong, the test passes. If the assertion doesn't hold but you type it
> right, the test fails. If the assertion doesn't hold and you type it wrong,
> the test passes.
>
> It may not seem like much of an issue because in TDD you watch the test fail
> before you make it pass, but code changes, conditions change, and you want to
> be sure the test doesn't become a broken alarm light. It's only a tiny change
> to self.assertIn(call(...), my_mock.mock_calls) which is less prone to false
> negatives.
>

Oy. Thanks for the tip.

>
> Typo in the docstring for BufferingOutputStream.__getattr__:
>
> """Pass-through for any attribute ther than write().
>
> Also, it would ...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches