Merge ~powersj/cloud-init:fix-centos-unittests into cloud-init:master
| Status: | Merged |
|---|---|
| Approved by: | Scott Moser on 2017-05-16 |
| Approved revision: | da2f7adc71a2d3b8fc7a7c70868474e26732a986 |
| Merged at revision: | 6edf0c72ce11e64627d3db6a0c4fd74a81039ed4 |
| Proposed branch: | ~powersj/cloud-init:fix-centos-unittests |
| Merge into: | cloud-init:master |
| Diff against target: |
194 lines (+88/-31) 4 files modified
cloudinit/config/cc_apt_configure.py (+12/-7) tests/unittests/test_handler/test_handler_apt_configure_sources_list_v3.py (+73/-21) tests/unittests/test_handler/test_handler_yum_add_repo.py (+2/-2) tox.ini (+1/-1) |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Ryan Harper | 2017-04-27 | Approve on 2017-05-05 | |
| Server Team CI bot | continuous-integration | Approve on 2017-05-03 | |
|
Review via email:
|
|||
Commit Message
unittests: fix unittests run on centos
Apt related tests were broken when running on centos becasue apt
is not available. This fixes the unit test, with a small re-work of apt_configure.
Also in 'tox -e centos6' only run nose on tests/unittests as tests/
also contain integration tests that should not be run.
| Ryan Harper (raharper) wrote : | # |
Thanks for taking this.
1) let's use @mock.patch.object decorators on the helper function for the common items (write, isfile, etc)
2) instead of testing all possible paths in the helper function and relying on the config_on_empty list, pull out the asserts to the test_* callers; they're setting up the scenario (distro=debian, cfg=XXX); they're in the best position to assert a specific path through the code.
3) Let's add a distro=ubuntu system_
4) Let's add distro=centos which should fall down the 'no apt binary' path
| Joshua Powers (powersj) wrote : | # |
If I use decorators on the helper function, but try to move asserts to the callers how is that going to work? From looking at this more it looks like every caller function would start to look like test_apt_
| Scott Moser (smoser) wrote : | # |
You could have the helper function resturn the mocks and the result of the call. There is a helper wrap_and_call which does something similar, but at the moment does not return the mocks.
One option is to modify that to return the mocks also.
On April 28, 2017 2:30:40 PM EDT, Joshua Powers <email address hidden> wrote:
>If I use decorators on the helper function, but try to move asserts to
>the callers how is that going to work? From looking at this more it
>looks like every caller function would start to look like
>test_apt_
>use the helper function.
>--
>https:/
>You are subscribed to branch cloud-init:master.
- c7a3952... by Joshua Powers on 2017-05-01
- 1d23c8c... by Joshua Powers on 2017-05-01
- 8e899e0... by Joshua Powers on 2017-05-01
PASSED: Continuous integration, rev:c7a39525da0
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
- ed61b61... by Joshua Powers on 2017-05-01
| Joshua Powers (powersj) wrote : | # |
Update:
* I used mock context managers over the use of the decorators. I was unable to even move a single one up without getting some odd errors. I can show you want I had, but we now have two default arguments, so having non-default arguments follow default arguments won't work in any case.
* Like Scott suggested I returned the mocks (never done that before, but like how it worked) and now the callers are running the asserts.
* Added a centos/rhel test
* Added a is_snappy variable and test case for ubuntu_snappy. Not sure on the unit test on this one other than to verify it wasn't called, similar to centos/rhel.
PASSED: Continuous integration, rev:ed61b61094e
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
| Ryan Harper (raharper) wrote : | # |
I like this a lot better, thanks for reworking this.
Couple of items to address.
- d5c58ed... by Joshua Powers on 2017-05-02
| Joshua Powers (powersj) wrote : | # |
Because we already mock _should_
Also updated all variable names to something more verbose.
FAILED: Continuous integration, rev:d5c58edce65
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
PASSED: Continuous integration, rev:d5c58edce65
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
| Ryan Harper (raharper) wrote : | # |
Generally looks good, couple questions below.
| Joshua Powers (powersj) wrote : | # |
I'll push changes shortly. Reply below.
- da2f7ad... by Joshua Powers on 2017-05-03
| Joshua Powers (powersj) wrote : | # |
I forgot comments get removed when I push, so:
1) I changed the line breaks from using / to use ()
2) I updated to using assert_called_with as suggested
3) +commands = nosetests {posargs:
Lasted push includes these changes/fixes.
PASSED: Continuous integration, rev:da2f7adc71a
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
| Joshua Powers (powersj) wrote : | # |
Confirmed on fresh centos 6 & 7 LXD as working. This one is ready to go.


PASSED: Continuous integration, rev:9ed5081b465 4a04f9a9c01b752 b84e26c97789ea /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 290/ /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- amd64/290 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- arm64/290 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- ppc64el/ 290 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=metal- s390x/290 /jenkins. ubuntu. com/server/ job/cloud- init-ci/ nodes=vm- i386/290
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild: /jenkins. ubuntu. com/server/ job/cloud- init-ci/ 290/rebuild
https:/