Merge lp:~hazmat/pyjuju/config-set-sans-status into lp:pyjuju

Proposed by Kapil Thangavelu
Status: Merged
Approved by: Gustavo Niemeyer
Approved revision: 393
Merged at revision: 393
Proposed branch: lp:~hazmat/pyjuju/config-set-sans-status
Merge into: lp:pyjuju
Diff against target: 91 lines (+21/-23)
1 file modified
juju/control/tests/test_config_set.py (+21/-23)
To merge this branch: bzr merge lp:~hazmat/pyjuju/config-set-sans-status
Reviewer Review Type Date Requested Status
Benjamin Saller (community) Approve
Jim Baker (community) Approve
Review via email: mp+78445@code.launchpad.net

Description of the change

Simplify config set tests to reduce runtime significantly.

The config set tests where using the status test infrastructure which
builds a quite complex setup. Clint noticed that one of the automated
tests runs against trunk would timeout on the config set test. This branch
simplifies the config set tests to just build what's needed (a deployed
service) and cuts runtime for the the four tests from 12.5s to 2s on
this developer's laptop.

To post a comment you must log in.
393. By Kapil Thangavelu

remove commented out bits, oops

Revision history for this message
Jim Baker (jimbaker) wrote :

+1, looks like a nice improvement to the current testing. In the past, I found this import from test_status to be surprising. I'm also getting an approx 5x improvement on my desktop, from 5s to 1s.

review: Approve
Revision history for this message
Benjamin Saller (bcsaller) wrote :

+1 if just for the better blog-title string ;)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'juju/control/tests/test_config_set.py'
2--- juju/control/tests/test_config_set.py 2011-09-15 18:50:23 +0000
3+++ juju/control/tests/test_config_set.py 2011-10-06 17:21:30 +0000
4@@ -1,41 +1,44 @@
5+from yaml import dump
6+
7 from twisted.internet.defer import inlineCallbacks
8
9 from juju.control import main
10-from juju.control.config_set import config_set
11-from juju.control.tests.test_status import StatusTestBase
12-
13-
14-class ControlJujuSetTest(StatusTestBase):
15+from .common import MachineControlToolTest
16+
17+
18+class ControlJujuSetTest(MachineControlToolTest):
19
20 @inlineCallbacks
21 def setUp(self):
22 yield super(ControlJujuSetTest, self).setUp()
23+ config = {
24+ "environments": {"firstenv": {"type": "dummy"}}}
25+ self.write_config(dump(config))
26+ self.config.load()
27+ self.service_state = yield self.add_service_from_charm("wordpress")
28+ self.service_unit = yield self.service_state.add_unit_state()
29 self.stderr = self.capture_stream("stderr")
30
31 @inlineCallbacks
32 def test_set_and_get(self):
33- system = yield self.build_topology()
34-
35- self.mock_environment()
36+ finished = self.setup_cli_reactor()
37+ self.setup_exit(0)
38 self.mocker.replay()
39
40- yield config_set(self.environment,
41- "wordpress",
42- ["blog-title=That\'ll do, pig."])
43+ main(["set",
44+ "wordpress",
45+ "blog-title=Hello Tribune?"])
46+ yield finished
47
48 # Verify the state is accessible
49- wordpress = system["services"]["wordpress"]
50- state = yield wordpress.get_config()
51- self.assertEqual(state, {"blog-title": "That\'ll do, pig."})
52+ state = yield self.service_state.get_config()
53+ self.assertEqual(state, {"blog-title": "Hello Tribune?"})
54
55 @inlineCallbacks
56 def test_set_invalid_option(self):
57- yield self.build_topology()
58- self.mock_environment()
59 finished = self.setup_cli_reactor()
60 self.setup_exit(0)
61 self.mocker.replay()
62-
63 main(["set",
64 "wordpress",
65 "blog-roll=What's a blog-roll?"])
66@@ -47,8 +50,6 @@
67
68 @inlineCallbacks
69 def test_set_invalid_service(self):
70- yield self.build_topology()
71- self.mock_environment()
72 finished = self.setup_cli_reactor()
73 self.setup_exit(0)
74 self.mocker.replay()
75@@ -63,8 +64,6 @@
76
77 @inlineCallbacks
78 def test_set_valid_option(self):
79- system = yield self.build_topology()
80- self.mock_environment()
81 finished = self.setup_cli_reactor()
82 self.setup_exit(0)
83 self.mocker.replay()
84@@ -75,6 +74,5 @@
85 yield finished
86
87 # Verify the state is accessible
88- wordpress = system["services"]["wordpress"]
89- state = yield wordpress.get_config()
90+ state = yield self.service_state.get_config()
91 self.assertEqual(state, {"blog-title": "My title"})

Subscribers

People subscribed via source and target branches

to status/vote changes: