Merge lp:~cprov/adt-cloud-worker/selftest into lp:adt-cloud-worker

Proposed by Celso Providelo
Status: Merged
Approved by: Celso Providelo
Approved revision: 44
Merged at revision: 42
Proposed branch: lp:~cprov/adt-cloud-worker/selftest
Merge into: lp:adt-cloud-worker
Diff against target: 123 lines (+90/-0)
4 files modified
README.rst (+22/-0)
dep8/debian/tests/control (+3/-0)
dep8/tests/__init__.py (+17/-0)
dep8/tests/test_proxy.py (+48/-0)
To merge this branch: bzr merge lp:~cprov/adt-cloud-worker/selftest
Reviewer Review Type Date Requested Status
Thomi Richards (community) Approve
Joe Talbott (community) Approve
Paul Larson Approve
Review via email: mp+257707@code.launchpad.net

Commit message

Adding basic DEP-8 tests for uci-nova, it's mainly intended to ensure feature consistency of uci-nova accross clouds.

Description of the change

Adding basic DEP-8 tests for uci-nova, it's mainly intended to ensure feature consistency of uci-nova accross clouds.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Looks good as is. I had a few minor suggestions, but mostly just personal preference.

review: Approve
Revision history for this message
Joe Talbott (joetalbott) wrote :

This looks good to me as well. I agree with Paul's suggestions as well but don't see them as blocking.

review: Approve
Revision history for this message
Celso Providelo (cprov) wrote :

Paul, Joe,

Thanks for the review.

I've updated the README as suggested and proposed a new change for the test_proxy checks, actually check access we depend on in production. Since they are only 3 and tend to be gone once the sources get fixed, we can make the test reflect the exact conditions we expect in production, i.e. when the test fails we know what will be broken and can act accordingly.

lp:~cprov/adt-cloud-worker/selftest updated
43. By Celso Providelo

Extending dogfood proxy tests to reflect the exact access we depend on in production.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

Please don't add more shell code that we need to maintain.

I agree that a selftest suite is a great thing to have, but I think writing it as a bash script is a bad idea. This could be trivially written as a python test suite, and would be easier to extend and maintain over time.

review: Needs Fixing
lp:~cprov/adt-cloud-worker/selftest updated
44. By Celso Providelo

Re-write the basic test suite in python ... because *simple* is not enough.

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

I think you could have gotten away without making dep8/tests/__init__.py - but there's nothing wrong with it either.

Thanks for the python rewrite.

review: Approve
Revision history for this message
Celso Providelo (cprov) wrote :

THomi,

Fine, python it is ... However, it carries a lot more test dependencies and specialties (allow-stderr) that were not a problem with the much simpler, main-stream and perfectly functional shell test suite.

This tendency of aiming for *bonus* points and twinkling stars, instead of getting things done on time, is what makes us kind of borderline mediocre ... We haven't reached the point where people start criticising our design choices and coding skills, simply because we have nothing to show :-/ I'd rather live with bad ideas that work than keep chasing tangential satisfaction on "perfect solutions" that do not serve their purpose.

That all said, enough ranting. Let's land the tests and use it to our benefit for validating other aspects of uci-nova.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'README.rst'
--- README.rst 2015-04-28 03:13:30 +0000
+++ README.rst 2015-04-29 04:44:51 +0000
@@ -58,6 +58,7 @@
5858
59 $ python setup.py test59 $ python setup.py test
6060
61
61Run the Service62Run the Service
62===============63===============
6364
@@ -90,3 +91,24 @@
9091
91It's possible to run multiple instances of the worker in the same machine92It's possible to run multiple instances of the worker in the same machine
92by providing diffent working directories of configuration file path.93by providing diffent working directories of configuration file path.
94
95
96Run DEP-8 tests for uci-nova ssh-setup
97======================================
98
99`uci-nova` is a special `adt-run` ssh-setup for adjusting testbed for a
100production like environment.
101
102We have created a specific test-suite for ensuring it works as expected on
103any choice of cloud.
104
105The `uci-nova` tests can be run from this project as::
106
107 adt-run --built-tree ./dep8 -d \
108 --- ssh -s ./uci-nova -d \
109 -- -d --flavor m1.small \
110 --image=ubuntu-trusty-14.04-amd64-server-20150417-disk1.img \
111 --net-id=415a0839-eb05-4e7a-907c-413c657f4bf5
112
113(adjust cloud-specific options like --flavor, --image and --net-id according
114to the available environment)
93115
=== added directory 'dep8'
=== added directory 'dep8/debian'
=== added directory 'dep8/debian/tests'
=== added file 'dep8/debian/tests/control'
--- dep8/debian/tests/control 1970-01-01 00:00:00 +0000
+++ dep8/debian/tests/control 2015-04-29 04:44:51 +0000
@@ -0,0 +1,3 @@
1Test-Command: python3 -m unittest tests
2Restrictions: allow-stderr
3Depends: python3, python3-requests
04
=== added directory 'dep8/tests'
=== added file 'dep8/tests/__init__.py'
--- dep8/tests/__init__.py 1970-01-01 00:00:00 +0000
+++ dep8/tests/__init__.py 2015-04-29 04:44:51 +0000
@@ -0,0 +1,17 @@
1# Copyright (C) 2015 Canonical
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15#
16
17from tests.test_proxy import *
018
=== added file 'dep8/tests/test_proxy.py'
--- dep8/tests/test_proxy.py 1970-01-01 00:00:00 +0000
+++ dep8/tests/test_proxy.py 2015-04-29 04:44:51 +0000
@@ -0,0 +1,48 @@
1#!/usr/bin/env python3
2#
3# Copyright (C) 2015 Canonical
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17#
18
19"""Tests for 'uci-nova' testbed proxy setup."""
20
21import requests
22import unittest
23
24
25class TestUciNova(unittest.TestCase):
26
27 def assertAccess(self, url):
28 """Assert given url is accessible (HTTP 200)."""
29 r = requests.get(url, headers={'Connection': 'close'})
30 self.assertEqual(requests.codes.ok, r.status_code)
31
32 def test_unity_firefox_extension(self):
33 # 'unity-firefox-extension' test requires pypi for installing mozmill.
34 self.assertAccess('https://pypi.python.org/pypi')
35
36 def test_lxc(self):
37 # 'lxc' test requires keyserver access.
38 self.assertAccess('http://keyserver.ubuntu.com')
39
40 def test_linux(self):
41 # 'linux' test requires access to kernel.ubuntu.com and a specific
42 # github project (patch).
43 self.assertAccess('http://kernel.ubuntu.com')
44 self.assertAccess('https://github.com/redpig/seccomp')
45
46
47if __name__ == '__main__':
48 unittest.main()

Subscribers

People subscribed via source and target branches