Merge lp:~benji/charms/precise/juju-gui/second into lp:~juju-gui/charms/precise/juju-gui/trunk

Proposed by Benji York on 2012-11-14
Status: Merged
Merged at revision: 4
Proposed branch: lp:~benji/charms/precise/juju-gui/second
Merge into: lp:~juju-gui/charms/precise/juju-gui/trunk
Diff against target: 118 lines (+98/-0)
4 files modified
README.txt (+71/-0)
tests/functional-noop.test (+8/-0)
tests/test_addition.py (+13/-0)
tests/unit.test (+6/-0)
To merge this branch: bzr merge lp:~benji/charms/precise/juju-gui/second
Reviewer Review Type Date Requested Status
Juju GUI Hackers 2012-11-14 Pending
Review via email: mp+134370@code.launchpad.net

Description of the Change

Initial project structure, mostly testing.

https://codereview.appspot.com/6850052/

To post a comment you must log in.
Brad Crittenden (bac) wrote :

Hi Nicola and Benji,

This looks like a good start. I tried to work through your instructions
and ran into some problems that I have noted. Ultimately I failed due
to Quantal and LXC. I need to revisit it after sorting out those
problems.

So, consider this a tepid +1.

https://codereview.appspot.com/6850052/diff/1/README.txt
File README.txt (right):

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode21
README.txt:21:
This doesn't actually work as unit.test has '.discover('.') but is being
run from above. Either unit.test should read '.discover('./tests') or
it should be run from within the tests directory.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode43
README.txt:43: ./configure --prefix=/home/USER
--prefix=$HOME is simpler

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode46
README.txt:46:
Has anyone talked to Jim about packaging this into a PPA?

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode62
README.txt:62:
You should mention the cwd must be the top of the charm, which is
unintuitive since you pass it as a parameter.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode69
README.txt:69:
Ugh, I seem to have lxc issues since upgrading to Quantal, so I cannot
get it to start now.

https://codereview.appspot.com/6850052/diff/1/tests/test_addition.py
File tests/test_addition.py (right):

https://codereview.appspot.com/6850052/diff/1/tests/test_addition.py#newcode10
tests/test_addition.py:10:
Passing or Unpassing?

https://codereview.appspot.com/6850052/diff/1/tests/unit.test
File tests/unit.test (right):

https://codereview.appspot.com/6850052/diff/1/tests/unit.test#newcode6
tests/unit.test:6:
sys.exit(unittest.TextTestRunner().run(unittest.TestLoader().discover('.')))
See comment in README

https://codereview.appspot.com/6850052/

Gary Poster (gary) wrote :

Looks good, thank you! Maybe make the os.path change I mention, and
look at my logs and make sure they are healthy.

Otherwise approved.

Gary

https://codereview.appspot.com/6850052/diff/1/README.txt
File README.txt (right):

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode21
README.txt:21:
On 2012/11/19 18:57:34, bac wrote:
> This doesn't actually work as unit.test has '.discover('.') but is
being run
> from above. Either unit.test should read '.discover('./tests') or it
should be
> run from within the tests directory.
Maybe better would be to .discover(os.path.dirname(__file__))

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode42
README.txt:42: autoreconf
Before this I needed to sudo apt-get install libtool autoconf (and maybe
some other bits too)

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode46
README.txt:46:
On 2012/11/19 18:57:34, bac wrote:
> Has anyone talked to Jim about packaging this into a PPA?

It is supposed to land...sometime...

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode69
README.txt:69:
On 2012/11/19 18:57:34, bac wrote:
> Ugh, I seem to have lxc issues since upgrading to Quantal, so I cannot
get it to
> start now.
If you want to pay, ec2 works, I think.

The unit tests seem to run in a separate machine, which is seems
unnecessarily annoying. Not a huge deal, and maybe I'm misinterpreting:
http://pastebin.ubuntu.com/1371194/

Wow, running the tests is slow. :-/ I'd forgotten about this.

My lxc results were as follows. They seem to show some unexpected
problems. Are they OK? http://pastebin.ubuntu.com/1371234/

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode71
README.txt:71: "setup-environment" is an easy way to get started.
Maybe it would be worth mentioning that you might want to set your
default environment to lxc?

Maybe it would be worth mentioning that using an lxc environment
requires that you install the apt-cacher-ng and lxc packages?

Your call.

https://codereview.appspot.com/6850052/diff/1/tests/unit.test
File tests/unit.test (right):

https://codereview.appspot.com/6850052/diff/1/tests/unit.test#newcode6
tests/unit.test:6:
sys.exit(unittest.TextTestRunner().run(unittest.TestLoader().discover('.')))
On 2012/11/19 18:57:34, bac wrote:
> See comment in README

Mine too :-)

https://codereview.appspot.com/6850052/

Nicola Larosa (teknico) wrote :

FWIW, some of the raised points are addressed in a subsequent branch:
https://code.launchpad.net/~frankban/charms/precise/juju-gui/juju-gui/+merge/135213

https://codereview.appspot.com/6850052/diff/1/README.txt
File README.txt (right):

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode21
README.txt:21:
> Maybe better would be to .discover(os.path.dirname(__file__))

Yes, that's better.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode42
README.txt:42: autoreconf
> Before this I needed to sudo apt-get install libtool autoconf (and
maybe some
> other bits too)

Yes, good idea mentioning it too.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode43
README.txt:43: ./configure --prefix=/home/USER
> --prefix=$HOME is simpler

It can actually be any directory on $PATH, or left out if one is
comfortable with /usr/local. Whatever path is chosen, the subdirs bin/
and share/ will be created inside it, if not already there.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode46
README.txt:46:
>> Has anyone talked to Jim about packaging this into a PPA?

> It is supposed to land...sometime...

Yes, it should become part of Jitsu eventually.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode62
README.txt:62:
> You should mention the cwd must be the top of the charm, which is
unintuitive
> since you pass it as a parameter.

Good idea mentioning it too.

https://codereview.appspot.com/6850052/diff/1/README.txt#newcode69
README.txt:69:
> My lxc results were as follows. They seem to show some unexpected
problems.
> Are they OK? http://pastebin.ubuntu.com/1371234/

The failure of collecting logs is a known problem, and we forgot making
the assertion succeed again. :-)

https://codereview.appspot.com/6850052/diff/1/tests/test_addition.py
File tests/test_addition.py (right):

https://codereview.appspot.com/6850052/diff/1/tests/test_addition.py#newcode10
tests/test_addition.py:10:
> Passing or Unpassing?

Eh. We forgot to put the expected value back to 2. :-)

https://codereview.appspot.com/6850052/

5. By Benji York on 2012-11-21

review fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'README.txt'
2--- README.txt 1970-01-01 00:00:00 +0000
3+++ README.txt 2012-11-14 21:04:22 +0000
4@@ -0,0 +1,71 @@
5+==============
6+Juju GUI Charm
7+==============
8+
9+This charm makes it easy to deploy a Juju GUI into an existing environment.
10+
11+
12+Testing
13+=======
14+
15+There are two types of tests for the charm: unit tests and functional tests.
16+
17+
18+Unit tests
19+----------
20+
21+The unit tests do not require a functional Juju environment, and can be run
22+with this command::
23+
24+ python tests/unit.test
25+
26+Unit tests should be created in the "tests" subdirectory and be named in the
27+customary way (i.e., "test_*.py").
28+
29+
30+Functional tests
31+----------------
32+
33+Running the functional tests requires a Juju testing environment as provided
34+by the Jitsu test command. All files in the tests directory which end with
35+".test" will be run in a Juju Jitsu test environment.
36+
37+
38+Functional test setup
39+~~~~~~~~~~~~~~~~~~~~~
40+
41+At the time of this writing the Jitsu test command is not yet released. To
42+run it you must first install it locally (replace USER with your user name)::
43+
44+ bzr branch lp:~jimbaker/juju-jitsu/unit-test jitsu-unit-test
45+ cd jitsu-unit-test
46+ autoreconf
47+ ./configure --prefix=/home/USER
48+ make
49+ make install
50+
51+The current incarnation of the Jitsu test command requires that the current
52+directory name match the charm name, so you must check out the charm into a
53+directory named "juju-gui"::
54+
55+ bzr branch lp:~juju-gui/charms/precise/juju-gui/trunk juju-gui
56+
57+Now you are ready to run the functional tests (see the next section).
58+
59+
60+Running the functional tests
61+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62+
63+Run the functional tests thusly::
64+
65+ ~/bin/jitsu test juju-gui --logdir /tmp
66+
67+If Jitsu generates errors about not being able bootstrap::
68+
69+ CalledProcessError: Command '['juju', 'bootstrap']'...
70+
71+...or it hangs, then you may need to bootstrap the environment yourself and
72+pass the --no-bootstrap switch to Jitsu.
73+
74+If you do not yet have an environment defined, the Jitsu command
75+"setup-environment" is an easy way to get started.
76
77=== added directory 'tests'
78=== added file 'tests/functional-noop.test'
79--- tests/functional-noop.test 1970-01-01 00:00:00 +0000
80+++ tests/functional-noop.test 2012-11-14 21:04:22 +0000
81@@ -0,0 +1,8 @@
82+#!/usr/bin/env python2
83+
84+import sys
85+
86+# The only requirement for functional tests is that they have a non-zero exit
87+# code on error. This noop is successful, therefore we exit with zero.
88+
89+sys.exit(0)
90
91=== added file 'tests/test_addition.py'
92--- tests/test_addition.py 1970-01-01 00:00:00 +0000
93+++ tests/test_addition.py 2012-11-14 21:04:22 +0000
94@@ -0,0 +1,13 @@
95+#!/usr/bin/env python2
96+
97+import sys
98+import unittest
99+
100+
101+class PassingTest(unittest.TestCase):
102+ def test_addition(self):
103+ self.assertEqual(1+1, 3)
104+
105+
106+if __name__ == '__main__':
107+ sys.exit(unittest.main())
108
109=== added file 'tests/unit.test'
110--- tests/unit.test 1970-01-01 00:00:00 +0000
111+++ tests/unit.test 2012-11-14 21:04:22 +0000
112@@ -0,0 +1,6 @@
113+#!/usr/bin/env python2
114+
115+import unittest
116+import sys
117+
118+sys.exit(unittest.TextTestRunner().run(unittest.TestLoader().discover('.')))

Subscribers

People subscribed via source and target branches

to all changes: