Merge ~larsks/cloud-init:bug/ec2-tests into cloud-init:master
| Status: | Rejected |
|---|---|
| Rejected by: | Chad Smith on 2017-08-31 |
| Proposed branch: | ~larsks/cloud-init:bug/ec2-tests |
| Merge into: | cloud-init:master |
| Prerequisite: | ~larsks/cloud-init:feature/hide-oauthlib-import-failure |
| Diff against target: |
70 lines (+25/-2) 1 file modified
tests/unittests/test_datasource/test_ec2.py (+25/-2) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Lars Kellogg-Stedman (community) | Approve on 2017-09-01 | ||
| Scott Moser | 2017-08-26 | Needs Fixing on 2017-08-29 | |
| Server Team CI bot | continuous-integration | 2017-08-26 | Approve on 2017-08-26 |
|
Review via email:
|
|||
Description of the Change
test_ec2: metadata tests were mocking wrong urls
The ec2 metadata tests were only mocking one version of the metadata
api, but requests were made against both. This fixes _setup_ds to
register mock data at both versions of the API, and adds a fallback
handler to raise an http error on requests to un-mocked requests.
| Scott Moser (smoser) wrote : | # |
Lars,
As this is right now, it is definitely 'needs_fixing'.
- you are not registering / using bad_uri_handler at all.
- as a result your commit message doesn't match the code changes.
I recall from talking to you that this is because 'tox -e xenial' (xenial/ubuntu 16.04 having an older version of httppretty). The memory is fuzzy in my head though.
I do think we want to register a 'not found' response / exception, and make sure nothing ever gets out, as our unit tests shouldn't hit external resources.
If we simply can't achieve that with 16.04 versions of packages, then i'd be ok for these tests to be skipIf in that scenario.
| Chad Smith (chad.smith) wrote : | # |
Lars, thank you for this. I replaced this content with a slightly different approach which only mocks the instance-id of the extended_
I'm marking as Rejected only because a slightly different take for bad_url_handling and unit test setup to make a minimally mocked set of metadata endpoints.
For your and my reference in future, it looks like the following allows httpretty to raise MockErrors for unmocked url attempts from unit tests:
httpretty.
| Chad Smith (chad.smith) wrote : | # |
https:/
| Lars Kellogg-Stedman (larsks) wrote : | # |
I do appreciate the chance to fix my own merge requests rather than having them replaced, but it's too late for that. In any case I'm glad it's working. You'll note that the final version of my code simply wasn't using the bad_uri_handler anymore, because there was no way to support that under Xenial.
| Lars Kellogg-Stedman (larsks) wrote : | # |
Actually, I didn't mean to reject this merge request. I'm not familiar enough with launchpad.
Unmerged commits
- 1884378... by Lars Kellogg-Stedman on 2017-08-25
- 29025c3... by Lars Kellogg-Stedman on 2016-12-08


PASSED: Continuous integration, rev:1884378859c cd5638dc2e52d10 82b89e892c7ad6 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 214/
https:/
Executed test runs:
SUCCESS: Checkout
SUCCESS: Unit & Style Tests
SUCCESS: Ubuntu LTS: Build
SUCCESS: Ubuntu LTS: Integration
SUCCESS: MAAS Compatability Testing
IN_PROGRESS: Declarative: Post Actions
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 214/rebuild
https:/