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
=== modified file 'juju/control/tests/test_config_set.py'
--- juju/control/tests/test_config_set.py 2011-09-15 18:50:23 +0000
+++ juju/control/tests/test_config_set.py 2011-10-06 17:21:30 +0000
@@ -1,41 +1,44 @@
1from yaml import dump
2
1from twisted.internet.defer import inlineCallbacks3from twisted.internet.defer import inlineCallbacks
24
3from juju.control import main5from juju.control import main
4from juju.control.config_set import config_set6from .common import MachineControlToolTest
5from juju.control.tests.test_status import StatusTestBase7
68
79class ControlJujuSetTest(MachineControlToolTest):
8class ControlJujuSetTest(StatusTestBase):
910
10 @inlineCallbacks11 @inlineCallbacks
11 def setUp(self):12 def setUp(self):
12 yield super(ControlJujuSetTest, self).setUp()13 yield super(ControlJujuSetTest, self).setUp()
14 config = {
15 "environments": {"firstenv": {"type": "dummy"}}}
16 self.write_config(dump(config))
17 self.config.load()
18 self.service_state = yield self.add_service_from_charm("wordpress")
19 self.service_unit = yield self.service_state.add_unit_state()
13 self.stderr = self.capture_stream("stderr")20 self.stderr = self.capture_stream("stderr")
1421
15 @inlineCallbacks22 @inlineCallbacks
16 def test_set_and_get(self):23 def test_set_and_get(self):
17 system = yield self.build_topology()24 finished = self.setup_cli_reactor()
1825 self.setup_exit(0)
19 self.mock_environment()
20 self.mocker.replay()26 self.mocker.replay()
2127
22 yield config_set(self.environment,28 main(["set",
23 "wordpress",29 "wordpress",
24 ["blog-title=That\'ll do, pig."])30 "blog-title=Hello Tribune?"])
31 yield finished
2532
26 # Verify the state is accessible33 # Verify the state is accessible
27 wordpress = system["services"]["wordpress"]34 state = yield self.service_state.get_config()
28 state = yield wordpress.get_config()35 self.assertEqual(state, {"blog-title": "Hello Tribune?"})
29 self.assertEqual(state, {"blog-title": "That\'ll do, pig."})
3036
31 @inlineCallbacks37 @inlineCallbacks
32 def test_set_invalid_option(self):38 def test_set_invalid_option(self):
33 yield self.build_topology()
34 self.mock_environment()
35 finished = self.setup_cli_reactor()39 finished = self.setup_cli_reactor()
36 self.setup_exit(0)40 self.setup_exit(0)
37 self.mocker.replay()41 self.mocker.replay()
38
39 main(["set",42 main(["set",
40 "wordpress",43 "wordpress",
41 "blog-roll=What's a blog-roll?"])44 "blog-roll=What's a blog-roll?"])
@@ -47,8 +50,6 @@
4750
48 @inlineCallbacks51 @inlineCallbacks
49 def test_set_invalid_service(self):52 def test_set_invalid_service(self):
50 yield self.build_topology()
51 self.mock_environment()
52 finished = self.setup_cli_reactor()53 finished = self.setup_cli_reactor()
53 self.setup_exit(0)54 self.setup_exit(0)
54 self.mocker.replay()55 self.mocker.replay()
@@ -63,8 +64,6 @@
6364
64 @inlineCallbacks65 @inlineCallbacks
65 def test_set_valid_option(self):66 def test_set_valid_option(self):
66 system = yield self.build_topology()
67 self.mock_environment()
68 finished = self.setup_cli_reactor()67 finished = self.setup_cli_reactor()
69 self.setup_exit(0)68 self.setup_exit(0)
70 self.mocker.replay()69 self.mocker.replay()
@@ -75,6 +74,5 @@
75 yield finished74 yield finished
7675
77 # Verify the state is accessible76 # Verify the state is accessible
78 wordpress = system["services"]["wordpress"]77 state = yield self.service_state.get_config()
79 state = yield wordpress.get_config()
80 self.assertEqual(state, {"blog-title": "My title"})78 self.assertEqual(state, {"blog-title": "My title"})

Subscribers

People subscribed via source and target branches

to status/vote changes: