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

Proposed by Celso Providelo on 2015-04-28
Status: Merged
Approved by: Celso Providelo on 2015-04-29
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 on 2015-04-29
Joe Talbott (community) Approve on 2015-04-29
Paul Larson 2015-04-28 Approve on 2015-04-29
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.
Paul Larson (pwlars) wrote :

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

review: Approve
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
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 on 2015-04-29
43. By Celso Providelo on 2015-04-29

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

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 on 2015-04-29
44. By Celso Providelo on 2015-04-29

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

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

Subscribers

People subscribed via source and target branches