Merge lp:~themue/juju-core/go-provisioner-environment-test into lp:~juju/juju-core/trunk

Proposed by Frank Mueller
Status: Merged
Approved by: Gustavo Niemeyer
Approved revision: no longer in the source branch.
Merged at revision: 460
Proposed branch: lp:~themue/juju-core/go-provisioner-environment-test
Merge into: lp:~juju/juju-core/trunk
Diff against target: 171 lines (+23/-31)
2 files modified
environs/dummy/environs.go (+2/-0)
worker/provisioner/provisioner_test.go (+21/-31)
To merge this branch: bzr merge lp:~themue/juju-core/go-provisioner-environment-test
Reviewer Review Type Date Requested Status
The Go Language Gophers Pending
Review via email: mp+122114@code.launchpad.net

Description of the change

provisioner: changed environment config. test

The tests now check that a changing environment configuration
is watched by the provisioner and passed to the environment.

https://codereview.appspot.com/6488057/

To post a comment you must log in.
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/dummy/environs.go'
2--- environs/dummy/environs.go 2012-08-31 05:04:38 +0000
3+++ environs/dummy/environs.go 2012-08-31 12:56:18 +0000
4@@ -63,6 +63,7 @@
5 MachineId int
6 Instance environs.Instance
7 Info *state.Info
8+ Secret string
9 }
10
11 type OpStopInstances struct {
12@@ -469,6 +470,7 @@
13 MachineId: machineId,
14 Instance: i,
15 Info: info,
16+ Secret: e.ecfg().secret(),
17 }
18 return i, nil
19 }
20
21=== modified file 'worker/provisioner/provisioner_test.go'
22--- worker/provisioner/provisioner_test.go 2012-08-30 13:21:00 +0000
23+++ worker/provisioner/provisioner_test.go 2012-08-31 12:56:18 +0000
24@@ -66,7 +66,7 @@
25 // checkStartInstance checks that an instance has been started
26 // with a machine id the same as m's, and that the machine's
27 // instance id has been set appropriately.
28-func (s *ProvisionerSuite) checkStartInstance(c *C, m *state.Machine) {
29+func (s *ProvisionerSuite) checkStartInstance(c *C, m *state.Machine, secret string) {
30 for {
31 select {
32 case o := <-s.op:
33@@ -76,6 +76,7 @@
34 c.Assert(o.MachineId, Equals, m.Id())
35 c.Assert(o.Instance, NotNil)
36 s.checkMachineId(c, m, o.Instance)
37+ c.Assert(o.Secret, Equals, secret)
38 return
39 default:
40 c.Logf("ignoring unexpected operation %#v", o)
41@@ -156,25 +157,6 @@
42 c.Assert(p.Stop(), IsNil)
43 }
44
45-func (s *ProvisionerSuite) TestProvisionerEnvironmentChange(c *C) {
46- p := provisioner.NewProvisioner(s.State)
47- defer s.stopProvisioner(c, p)
48- // Twiddle with the environment configuration.
49- cfg, err := s.State.EnvironConfig()
50- c.Assert(err, IsNil)
51- cfgAttrs := cfg.AllAttrs()
52- cfgAttrs["name"] = "testing2"
53- cfg, err = config.New(cfgAttrs)
54- c.Assert(err, IsNil)
55- err = s.State.SetEnvironConfig(cfg)
56- c.Assert(err, IsNil)
57- cfgAttrs["name"] = "testing3"
58- cfg, err = config.New(cfgAttrs)
59- c.Assert(err, IsNil)
60- err = s.State.SetEnvironConfig(cfg)
61- c.Assert(err, IsNil)
62-}
63-
64 func (s *ProvisionerSuite) TestProvisionerStopOnStateClose(c *C) {
65 st, err := state.Open(s.StateInfo(c))
66 c.Assert(err, IsNil)
67@@ -196,7 +178,7 @@
68 m, err := s.State.AddMachine()
69 c.Assert(err, IsNil)
70
71- s.checkStartInstance(c, m)
72+ s.checkStartInstance(c, m, "pork")
73
74 // now remove it
75 c.Assert(s.State.RemoveMachine(m.Id()), IsNil)
76@@ -238,7 +220,7 @@
77 err = s.fixEnvironment()
78 c.Assert(err, IsNil)
79
80- s.checkStartInstance(c, m)
81+ s.checkStartInstance(c, m, "pork")
82 }
83
84 func (s *ProvisionerSuite) TestProvisioningDoesOccurAfterInvalidEnvironmentPublished(c *C) {
85@@ -249,7 +231,7 @@
86 m, err := s.State.AddMachine()
87 c.Assert(err, IsNil)
88
89- s.checkStartInstance(c, m)
90+ s.checkStartInstance(c, m, "pork")
91
92 err = s.invalidateEnvironment()
93 c.Assert(err, IsNil)
94@@ -259,7 +241,7 @@
95 c.Assert(err, IsNil)
96
97 // the PA should create it using the old environment
98- s.checkStartInstance(c, m)
99+ s.checkStartInstance(c, m, "pork")
100 }
101
102 func (s *ProvisionerSuite) TestProvisioningDoesNotProvisionTheSameMachineAfterRestart(c *C) {
103@@ -271,7 +253,7 @@
104 m, err := s.State.AddMachine()
105 c.Check(err, IsNil)
106
107- s.checkStartInstance(c, m)
108+ s.checkStartInstance(c, m, "pork")
109
110 // restart the PA
111 c.Check(p.Stop(), IsNil)
112@@ -299,13 +281,13 @@
113 m, err := s.State.AddMachine()
114 c.Check(err, IsNil)
115
116- s.checkStartInstance(c, m)
117+ s.checkStartInstance(c, m, "pork")
118
119 // create a second machine
120 m, err = s.State.AddMachine()
121 c.Check(err, IsNil)
122
123- s.checkStartInstance(c, m)
124+ s.checkStartInstance(c, m, "pork")
125
126 // stop the PA
127 c.Check(p.Stop(), IsNil)
128@@ -334,7 +316,7 @@
129 m, err := s.State.AddMachine()
130 c.Check(err, IsNil)
131
132- s.checkStartInstance(c, m)
133+ s.checkStartInstance(c, m, "pork")
134
135 // stop the PA
136 c.Check(p.Stop(), IsNil)
137@@ -363,7 +345,7 @@
138 m, err := s.State.AddMachine()
139 c.Assert(err, IsNil)
140
141- s.checkStartInstance(c, m)
142+ s.checkStartInstance(c, m, "pork")
143
144 err = s.invalidateEnvironment()
145 c.Assert(err, IsNil)
146@@ -373,15 +355,23 @@
147 c.Assert(err, IsNil)
148
149 // the PA should create it using the old environment
150- s.checkStartInstance(c, m)
151+ s.checkStartInstance(c, m, "pork")
152
153 err = s.fixEnvironment()
154 c.Assert(err, IsNil)
155
156+ cfg, err := s.State.EnvironConfig()
157+ c.Assert(err, IsNil)
158+ attrs := cfg.AllAttrs()
159+ attrs["secret"] = "beef"
160+ cfg, err = config.New(attrs)
161+ c.Assert(err, IsNil)
162+ err = s.State.SetEnvironConfig(cfg)
163+
164 // create a third machine
165 m, err = s.State.AddMachine()
166 c.Assert(err, IsNil)
167
168 // the PA should create it using the new environment
169- s.checkStartInstance(c, m)
170+ s.checkStartInstance(c, m, "beef")
171 }

Subscribers

People subscribed via source and target branches