Merge lp:~thumper/juju-core/state-gc-prefix into lp:~go-bot/juju-core/trunk
- state-gc-prefix
- Merge into trunk
Proposed by
Tim Penhey
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1528 |
Proposed branch: | lp:~thumper/juju-core/state-gc-prefix |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
2134 lines (+518/-518) 2 files modified
state/state_test.go (+500/-500) state/tools_test.go (+18/-18) |
To merge this branch: | bzr merge lp:~thumper/juju-core/state-gc-prefix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+176543@code.launchpad.net |
Commit message
Trivial import testing prefix.
gc and jc prefix for imports.
Description of the change
Trivial import testing prefix.
gc and jc prefix for imports.
To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote : | # |
Revision history for this message
Ian Booth (wallyworld) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'state/state_test.go' |
2 | --- state/state_test.go 2013-07-22 04:23:33 +0000 |
3 | +++ state/state_test.go 2013-07-23 22:45:38 +0000 |
4 | @@ -11,7 +11,7 @@ |
5 | "time" |
6 | |
7 | "labix.org/v2/mgo/bson" |
8 | - . "launchpad.net/gocheck" |
9 | + gc "launchpad.net/gocheck" |
10 | |
11 | "launchpad.net/juju-core/agent/tools" |
12 | "launchpad.net/juju-core/charm" |
13 | @@ -23,7 +23,7 @@ |
14 | "launchpad.net/juju-core/state/api/params" |
15 | statetesting "launchpad.net/juju-core/state/testing" |
16 | "launchpad.net/juju-core/testing" |
17 | - "launchpad.net/juju-core/testing/checkers" |
18 | + jc "launchpad.net/juju-core/testing/checkers" |
19 | "launchpad.net/juju-core/version" |
20 | ) |
21 | |
22 | @@ -34,37 +34,37 @@ |
23 | // is useful because several tests go through a unit's lifecycle step by step, |
24 | // asserting the behaviour of a given method in each state, and the unit quick- |
25 | // remove change caused many of these to fail. |
26 | -func preventUnitDestroyRemove(c *C, u *state.Unit) { |
27 | +func preventUnitDestroyRemove(c *gc.C, u *state.Unit) { |
28 | err := u.SetStatus(params.StatusStarted, "") |
29 | - c.Assert(err, IsNil) |
30 | + c.Assert(err, gc.IsNil) |
31 | } |
32 | |
33 | type StateSuite struct { |
34 | ConnSuite |
35 | } |
36 | |
37 | -var _ = Suite(&StateSuite{}) |
38 | +var _ = gc.Suite(&StateSuite{}) |
39 | |
40 | -func (s *StateSuite) TestDialAgain(c *C) { |
41 | +func (s *StateSuite) TestDialAgain(c *gc.C) { |
42 | // Ensure idempotent operations on Dial are working fine. |
43 | for i := 0; i < 2; i++ { |
44 | st, err := state.Open(state.TestingStateInfo(), state.TestingDialOpts()) |
45 | - c.Assert(err, IsNil) |
46 | - c.Assert(st.Close(), IsNil) |
47 | + c.Assert(err, gc.IsNil) |
48 | + c.Assert(st.Close(), gc.IsNil) |
49 | } |
50 | } |
51 | |
52 | -func (s *StateSuite) TestStateInfo(c *C) { |
53 | +func (s *StateSuite) TestStateInfo(c *gc.C) { |
54 | info := state.TestingStateInfo() |
55 | stateAddr, err := s.State.Addresses() |
56 | - c.Assert(err, IsNil) |
57 | - c.Assert(stateAddr, DeepEquals, info.Addrs) |
58 | - c.Assert(s.State.CACert(), DeepEquals, info.CACert) |
59 | + c.Assert(err, gc.IsNil) |
60 | + c.Assert(stateAddr, gc.DeepEquals, info.Addrs) |
61 | + c.Assert(s.State.CACert(), gc.DeepEquals, info.CACert) |
62 | } |
63 | |
64 | -func (s *StateSuite) TestAPIAddresses(c *C) { |
65 | +func (s *StateSuite) TestAPIAddresses(c *gc.C) { |
66 | config, err := s.State.EnvironConfig() |
67 | - c.Assert(err, IsNil) |
68 | + c.Assert(err, gc.IsNil) |
69 | apiPort := strconv.Itoa(config.APIPort()) |
70 | info := state.TestingStateInfo() |
71 | expectedAddrs := make([]string, 0, len(info.Addrs)) |
72 | @@ -74,40 +74,40 @@ |
73 | expectedAddrs = append(expectedAddrs, expectedAddr) |
74 | } |
75 | apiAddrs, err := s.State.APIAddresses() |
76 | - c.Assert(err, IsNil) |
77 | - c.Assert(apiAddrs, DeepEquals, expectedAddrs) |
78 | + c.Assert(err, gc.IsNil) |
79 | + c.Assert(apiAddrs, gc.DeepEquals, expectedAddrs) |
80 | } |
81 | |
82 | -func (s *StateSuite) TestIsNotFound(c *C) { |
83 | +func (s *StateSuite) TestIsNotFound(c *gc.C) { |
84 | err1 := fmt.Errorf("unrelated error") |
85 | err2 := errors.NotFoundf("foo") |
86 | - c.Assert(err1, Not(checkers.Satisfies), errors.IsNotFoundError) |
87 | - c.Assert(err2, checkers.Satisfies, errors.IsNotFoundError) |
88 | + c.Assert(err1, gc.Not(jc.Satisfies), errors.IsNotFoundError) |
89 | + c.Assert(err2, jc.Satisfies, errors.IsNotFoundError) |
90 | } |
91 | |
92 | -func (s *StateSuite) TestAddCharm(c *C) { |
93 | +func (s *StateSuite) TestAddCharm(c *gc.C) { |
94 | // Check that adding charms from scratch works correctly. |
95 | ch := testing.Charms.Dir("dummy") |
96 | curl := charm.MustParseURL( |
97 | fmt.Sprintf("local:series/%s-%d", ch.Meta().Name, ch.Revision()), |
98 | ) |
99 | bundleURL, err := url.Parse("http://bundles.testing.invalid/dummy-1") |
100 | - c.Assert(err, IsNil) |
101 | + c.Assert(err, gc.IsNil) |
102 | dummy, err := s.State.AddCharm(ch, curl, bundleURL, "dummy-1-sha256") |
103 | - c.Assert(err, IsNil) |
104 | - c.Assert(dummy.URL().String(), Equals, curl.String()) |
105 | + c.Assert(err, gc.IsNil) |
106 | + c.Assert(dummy.URL().String(), gc.Equals, curl.String()) |
107 | |
108 | doc := state.CharmDoc{} |
109 | err = s.charms.FindId(curl).One(&doc) |
110 | - c.Assert(err, IsNil) |
111 | + c.Assert(err, gc.IsNil) |
112 | c.Logf("%#v", doc) |
113 | - c.Assert(doc.URL, DeepEquals, curl) |
114 | + c.Assert(doc.URL, gc.DeepEquals, curl) |
115 | } |
116 | |
117 | -func (s *StateSuite) AssertMachineCount(c *C, expect int) { |
118 | +func (s *StateSuite) AssertMachineCount(c *gc.C, expect int) { |
119 | ms, err := s.State.AllMachines() |
120 | - c.Assert(err, IsNil) |
121 | - c.Assert(len(ms), Equals, expect) |
122 | + c.Assert(err, gc.IsNil) |
123 | + c.Assert(len(ms), gc.Equals, expect) |
124 | } |
125 | |
126 | var jobStringTests = []struct { |
127 | @@ -121,34 +121,34 @@ |
128 | {5, "<unknown job 5>"}, |
129 | } |
130 | |
131 | -func (s *StateSuite) TestJobString(c *C) { |
132 | +func (s *StateSuite) TestJobString(c *gc.C) { |
133 | for _, t := range jobStringTests { |
134 | - c.Check(t.job.String(), Equals, t.s) |
135 | + c.Check(t.job.String(), gc.Equals, t.s) |
136 | } |
137 | } |
138 | |
139 | -func (s *StateSuite) TestAddMachineErrors(c *C) { |
140 | +func (s *StateSuite) TestAddMachineErrors(c *gc.C) { |
141 | _, err := s.State.AddMachine("") |
142 | - c.Assert(err, ErrorMatches, "cannot add a new machine: no series specified") |
143 | + c.Assert(err, gc.ErrorMatches, "cannot add a new machine: no series specified") |
144 | _, err = s.State.AddMachine("series") |
145 | - c.Assert(err, ErrorMatches, "cannot add a new machine: no jobs specified") |
146 | + c.Assert(err, gc.ErrorMatches, "cannot add a new machine: no jobs specified") |
147 | _, err = s.State.AddMachine("series", state.JobHostUnits, state.JobHostUnits) |
148 | - c.Assert(err, ErrorMatches, "cannot add a new machine: duplicate job: .*") |
149 | + c.Assert(err, gc.ErrorMatches, "cannot add a new machine: duplicate job: .*") |
150 | } |
151 | |
152 | -func (s *StateSuite) TestAddMachines(c *C) { |
153 | +func (s *StateSuite) TestAddMachines(c *gc.C) { |
154 | oneJob := []state.MachineJob{state.JobHostUnits} |
155 | m0, err := s.State.AddMachine("series", oneJob...) |
156 | - c.Assert(err, IsNil) |
157 | + c.Assert(err, gc.IsNil) |
158 | check := func(m *state.Machine, id, series string, jobs []state.MachineJob) { |
159 | - c.Assert(m.Id(), Equals, id) |
160 | - c.Assert(m.Series(), Equals, series) |
161 | - c.Assert(m.Jobs(), DeepEquals, jobs) |
162 | + c.Assert(m.Id(), gc.Equals, id) |
163 | + c.Assert(m.Series(), gc.Equals, series) |
164 | + c.Assert(m.Jobs(), gc.DeepEquals, jobs) |
165 | s.assertMachineContainers(c, m, nil) |
166 | } |
167 | check(m0, "0", "series", oneJob) |
168 | m0, err = s.State.Machine("0") |
169 | - c.Assert(err, IsNil) |
170 | + c.Assert(err, gc.IsNil) |
171 | check(m0, "0", "series", oneJob) |
172 | |
173 | allJobs := []state.MachineJob{ |
174 | @@ -157,23 +157,23 @@ |
175 | state.JobManageState, |
176 | } |
177 | m1, err := s.State.AddMachine("blahblah", allJobs...) |
178 | - c.Assert(err, IsNil) |
179 | + c.Assert(err, gc.IsNil) |
180 | check(m1, "1", "blahblah", allJobs) |
181 | |
182 | m1, err = s.State.Machine("1") |
183 | - c.Assert(err, IsNil) |
184 | + c.Assert(err, gc.IsNil) |
185 | check(m1, "1", "blahblah", allJobs) |
186 | |
187 | m, err := s.State.AllMachines() |
188 | - c.Assert(err, IsNil) |
189 | - c.Assert(m, HasLen, 2) |
190 | + c.Assert(err, gc.IsNil) |
191 | + c.Assert(m, gc.HasLen, 2) |
192 | check(m[0], "0", "series", oneJob) |
193 | check(m[1], "1", "blahblah", allJobs) |
194 | } |
195 | |
196 | -func (s *StateSuite) TestAddMachineExtraConstraints(c *C) { |
197 | +func (s *StateSuite) TestAddMachineExtraConstraints(c *gc.C) { |
198 | err := s.State.SetEnvironConstraints(constraints.MustParse("mem=4G")) |
199 | - c.Assert(err, IsNil) |
200 | + c.Assert(err, gc.IsNil) |
201 | oneJob := []state.MachineJob{state.JobHostUnits} |
202 | extraCons := constraints.MustParse("cpu-cores=4") |
203 | params := state.AddMachineParams{ |
204 | @@ -182,25 +182,25 @@ |
205 | Jobs: oneJob, |
206 | } |
207 | m, err := s.State.AddMachineWithConstraints(¶ms) |
208 | - c.Assert(err, IsNil) |
209 | - c.Assert(m.Id(), Equals, "0") |
210 | - c.Assert(m.Series(), Equals, "series") |
211 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
212 | + c.Assert(err, gc.IsNil) |
213 | + c.Assert(m.Id(), gc.Equals, "0") |
214 | + c.Assert(m.Series(), gc.Equals, "series") |
215 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
216 | expectedCons := constraints.MustParse("cpu-cores=4 mem=4G") |
217 | mcons, err := m.Constraints() |
218 | - c.Assert(err, IsNil) |
219 | - c.Assert(mcons, DeepEquals, expectedCons) |
220 | + c.Assert(err, gc.IsNil) |
221 | + c.Assert(mcons, gc.DeepEquals, expectedCons) |
222 | } |
223 | |
224 | var emptyCons = constraints.Value{} |
225 | |
226 | -func (s *StateSuite) assertMachineContainers(c *C, m *state.Machine, containers []string) { |
227 | +func (s *StateSuite) assertMachineContainers(c *gc.C, m *state.Machine, containers []string) { |
228 | mc, err := m.Containers() |
229 | - c.Assert(err, IsNil) |
230 | - c.Assert(mc, DeepEquals, containers) |
231 | + c.Assert(err, gc.IsNil) |
232 | + c.Assert(mc, gc.DeepEquals, containers) |
233 | } |
234 | |
235 | -func (s *StateSuite) TestAddContainerToNewMachine(c *C) { |
236 | +func (s *StateSuite) TestAddContainerToNewMachine(c *gc.C) { |
237 | oneJob := []state.MachineJob{state.JobHostUnits} |
238 | |
239 | params := state.AddMachineParams{ |
240 | @@ -209,29 +209,29 @@ |
241 | Jobs: oneJob, |
242 | } |
243 | m, err := s.State.AddMachineWithConstraints(¶ms) |
244 | - c.Assert(err, IsNil) |
245 | - c.Assert(m.Id(), Equals, "0/lxc/0") |
246 | - c.Assert(m.Series(), Equals, "series") |
247 | - c.Assert(m.ContainerType(), Equals, instance.LXC) |
248 | + c.Assert(err, gc.IsNil) |
249 | + c.Assert(m.Id(), gc.Equals, "0/lxc/0") |
250 | + c.Assert(m.Series(), gc.Equals, "series") |
251 | + c.Assert(m.ContainerType(), gc.Equals, instance.LXC) |
252 | mcons, err := m.Constraints() |
253 | - c.Assert(err, IsNil) |
254 | - c.Assert(mcons, DeepEquals, emptyCons) |
255 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
256 | + c.Assert(err, gc.IsNil) |
257 | + c.Assert(mcons, gc.DeepEquals, emptyCons) |
258 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
259 | |
260 | m, err = s.State.Machine("0") |
261 | - c.Assert(err, IsNil) |
262 | + c.Assert(err, gc.IsNil) |
263 | s.assertMachineContainers(c, m, []string{"0/lxc/0"}) |
264 | m, err = s.State.Machine("0/lxc/0") |
265 | - c.Assert(err, IsNil) |
266 | + c.Assert(err, gc.IsNil) |
267 | s.assertMachineContainers(c, m, nil) |
268 | } |
269 | |
270 | -func (s *StateSuite) TestAddContainerToExistingMachine(c *C) { |
271 | +func (s *StateSuite) TestAddContainerToExistingMachine(c *gc.C) { |
272 | oneJob := []state.MachineJob{state.JobHostUnits} |
273 | m0, err := s.State.AddMachine("series", oneJob...) |
274 | - c.Assert(err, IsNil) |
275 | + c.Assert(err, gc.IsNil) |
276 | m1, err := s.State.AddMachine("series", oneJob...) |
277 | - c.Assert(err, IsNil) |
278 | + c.Assert(err, gc.IsNil) |
279 | |
280 | // Add first container. |
281 | params := state.AddMachineParams{ |
282 | @@ -241,33 +241,33 @@ |
283 | Jobs: []state.MachineJob{state.JobHostUnits}, |
284 | } |
285 | m, err := s.State.AddMachineWithConstraints(¶ms) |
286 | - c.Assert(err, IsNil) |
287 | - c.Assert(m.Id(), Equals, "1/lxc/0") |
288 | - c.Assert(m.Series(), Equals, "series") |
289 | - c.Assert(m.ContainerType(), Equals, instance.LXC) |
290 | + c.Assert(err, gc.IsNil) |
291 | + c.Assert(m.Id(), gc.Equals, "1/lxc/0") |
292 | + c.Assert(m.Series(), gc.Equals, "series") |
293 | + c.Assert(m.ContainerType(), gc.Equals, instance.LXC) |
294 | mcons, err := m.Constraints() |
295 | - c.Assert(err, IsNil) |
296 | - c.Assert(mcons, DeepEquals, emptyCons) |
297 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
298 | + c.Assert(err, gc.IsNil) |
299 | + c.Assert(mcons, gc.DeepEquals, emptyCons) |
300 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
301 | s.assertMachineContainers(c, m1, []string{"1/lxc/0"}) |
302 | |
303 | s.assertMachineContainers(c, m0, nil) |
304 | s.assertMachineContainers(c, m1, []string{"1/lxc/0"}) |
305 | m, err = s.State.Machine("1/lxc/0") |
306 | - c.Assert(err, IsNil) |
307 | + c.Assert(err, gc.IsNil) |
308 | s.assertMachineContainers(c, m, nil) |
309 | |
310 | // Add second container. |
311 | m, err = s.State.AddMachineWithConstraints(¶ms) |
312 | - c.Assert(err, IsNil) |
313 | - c.Assert(m.Id(), Equals, "1/lxc/1") |
314 | - c.Assert(m.Series(), Equals, "series") |
315 | - c.Assert(m.ContainerType(), Equals, instance.LXC) |
316 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
317 | + c.Assert(err, gc.IsNil) |
318 | + c.Assert(m.Id(), gc.Equals, "1/lxc/1") |
319 | + c.Assert(m.Series(), gc.Equals, "series") |
320 | + c.Assert(m.ContainerType(), gc.Equals, instance.LXC) |
321 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
322 | s.assertMachineContainers(c, m1, []string{"1/lxc/0", "1/lxc/1"}) |
323 | } |
324 | |
325 | -func (s *StateSuite) TestAddContainerWithConstraints(c *C) { |
326 | +func (s *StateSuite) TestAddContainerWithConstraints(c *gc.C) { |
327 | oneJob := []state.MachineJob{state.JobHostUnits} |
328 | cons := constraints.MustParse("mem=4G") |
329 | |
330 | @@ -279,17 +279,17 @@ |
331 | Jobs: oneJob, |
332 | } |
333 | m, err := s.State.AddMachineWithConstraints(¶ms) |
334 | - c.Assert(err, IsNil) |
335 | - c.Assert(m.Id(), Equals, "0/lxc/0") |
336 | - c.Assert(m.Series(), Equals, "series") |
337 | - c.Assert(m.ContainerType(), Equals, instance.LXC) |
338 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
339 | + c.Assert(err, gc.IsNil) |
340 | + c.Assert(m.Id(), gc.Equals, "0/lxc/0") |
341 | + c.Assert(m.Series(), gc.Equals, "series") |
342 | + c.Assert(m.ContainerType(), gc.Equals, instance.LXC) |
343 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
344 | mcons, err := m.Constraints() |
345 | - c.Assert(err, IsNil) |
346 | - c.Assert(cons, DeepEquals, mcons) |
347 | + c.Assert(err, gc.IsNil) |
348 | + c.Assert(cons, gc.DeepEquals, mcons) |
349 | } |
350 | |
351 | -func (s *StateSuite) TestAddContainerErrors(c *C) { |
352 | +func (s *StateSuite) TestAddContainerErrors(c *gc.C) { |
353 | oneJob := []state.MachineJob{state.JobHostUnits} |
354 | |
355 | params := state.AddMachineParams{ |
356 | @@ -299,23 +299,23 @@ |
357 | Jobs: oneJob, |
358 | } |
359 | _, err := s.State.AddMachineWithConstraints(¶ms) |
360 | - c.Assert(err, ErrorMatches, "cannot add a new container: machine 10 not found") |
361 | + c.Assert(err, gc.ErrorMatches, "cannot add a new container: machine 10 not found") |
362 | params.ContainerType = "" |
363 | _, err = s.State.AddMachineWithConstraints(¶ms) |
364 | - c.Assert(err, ErrorMatches, "cannot add a new container: no container type specified") |
365 | + c.Assert(err, gc.ErrorMatches, "cannot add a new container: no container type specified") |
366 | } |
367 | |
368 | -func (s *StateSuite) TestInjectMachineErrors(c *C) { |
369 | +func (s *StateSuite) TestInjectMachineErrors(c *gc.C) { |
370 | hc := instance.HardwareCharacteristics{} |
371 | _, err := s.State.InjectMachine("", emptyCons, instance.Id("i-minvalid"), hc, state.JobHostUnits) |
372 | - c.Assert(err, ErrorMatches, "cannot add a new machine: no series specified") |
373 | + c.Assert(err, gc.ErrorMatches, "cannot add a new machine: no series specified") |
374 | _, err = s.State.InjectMachine("series", emptyCons, instance.Id(""), hc, state.JobHostUnits) |
375 | - c.Assert(err, ErrorMatches, "cannot inject a machine without an instance id") |
376 | + c.Assert(err, gc.ErrorMatches, "cannot inject a machine without an instance id") |
377 | _, err = s.State.InjectMachine("series", emptyCons, instance.Id("i-mlazy"), hc) |
378 | - c.Assert(err, ErrorMatches, "cannot add a new machine: no jobs specified") |
379 | + c.Assert(err, gc.ErrorMatches, "cannot add a new machine: no jobs specified") |
380 | } |
381 | |
382 | -func (s *StateSuite) TestInjectMachine(c *C) { |
383 | +func (s *StateSuite) TestInjectMachine(c *gc.C) { |
384 | cons := constraints.MustParse("mem=4G") |
385 | arch := "amd64" |
386 | mem := uint64(1024) |
387 | @@ -324,27 +324,27 @@ |
388 | Mem: &mem, |
389 | } |
390 | m, err := s.State.InjectMachine("series", cons, instance.Id("i-mindustrious"), hc, state.JobHostUnits, state.JobManageEnviron) |
391 | - c.Assert(err, IsNil) |
392 | - c.Assert(m.Jobs(), DeepEquals, []state.MachineJob{state.JobHostUnits, state.JobManageEnviron}) |
393 | + c.Assert(err, gc.IsNil) |
394 | + c.Assert(m.Jobs(), gc.DeepEquals, []state.MachineJob{state.JobHostUnits, state.JobManageEnviron}) |
395 | instanceId, err := m.InstanceId() |
396 | - c.Assert(err, IsNil) |
397 | - c.Assert(instanceId, Equals, instance.Id("i-mindustrious")) |
398 | + c.Assert(err, gc.IsNil) |
399 | + c.Assert(instanceId, gc.Equals, instance.Id("i-mindustrious")) |
400 | mcons, err := m.Constraints() |
401 | - c.Assert(err, IsNil) |
402 | - c.Assert(cons, DeepEquals, mcons) |
403 | + c.Assert(err, gc.IsNil) |
404 | + c.Assert(cons, gc.DeepEquals, mcons) |
405 | characteristics, err := m.HardwareCharacteristics() |
406 | - c.Assert(err, IsNil) |
407 | - c.Assert(*characteristics, DeepEquals, hc) |
408 | + c.Assert(err, gc.IsNil) |
409 | + c.Assert(*characteristics, gc.DeepEquals, hc) |
410 | |
411 | // Make sure the bootstrap nonce value is set. |
412 | - c.Assert(m.CheckProvisioned(state.BootstrapNonce), Equals, true) |
413 | + c.Assert(m.CheckProvisioned(state.BootstrapNonce), gc.Equals, true) |
414 | } |
415 | |
416 | -func (s *StateSuite) TestAddContainerToInjectedMachine(c *C) { |
417 | +func (s *StateSuite) TestAddContainerToInjectedMachine(c *gc.C) { |
418 | oneJob := []state.MachineJob{state.JobHostUnits} |
419 | hc := instance.HardwareCharacteristics{} |
420 | m0, err := s.State.InjectMachine("series", emptyCons, instance.Id("i-mindustrious"), hc, state.JobHostUnits, state.JobManageEnviron) |
421 | - c.Assert(err, IsNil) |
422 | + c.Assert(err, gc.IsNil) |
423 | |
424 | // Add first container. |
425 | params := state.AddMachineParams{ |
426 | @@ -354,141 +354,141 @@ |
427 | Jobs: []state.MachineJob{state.JobHostUnits}, |
428 | } |
429 | m, err := s.State.AddMachineWithConstraints(¶ms) |
430 | - c.Assert(err, IsNil) |
431 | - c.Assert(m.Id(), Equals, "0/lxc/0") |
432 | - c.Assert(m.Series(), Equals, "series") |
433 | - c.Assert(m.ContainerType(), Equals, instance.LXC) |
434 | + c.Assert(err, gc.IsNil) |
435 | + c.Assert(m.Id(), gc.Equals, "0/lxc/0") |
436 | + c.Assert(m.Series(), gc.Equals, "series") |
437 | + c.Assert(m.ContainerType(), gc.Equals, instance.LXC) |
438 | mcons, err := m.Constraints() |
439 | - c.Assert(err, IsNil) |
440 | - c.Assert(mcons, DeepEquals, emptyCons) |
441 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
442 | + c.Assert(err, gc.IsNil) |
443 | + c.Assert(mcons, gc.DeepEquals, emptyCons) |
444 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
445 | s.assertMachineContainers(c, m0, []string{"0/lxc/0"}) |
446 | |
447 | // Add second container. |
448 | m, err = s.State.AddMachineWithConstraints(¶ms) |
449 | - c.Assert(err, IsNil) |
450 | - c.Assert(m.Id(), Equals, "0/lxc/1") |
451 | - c.Assert(m.Series(), Equals, "series") |
452 | - c.Assert(m.ContainerType(), Equals, instance.LXC) |
453 | - c.Assert(m.Jobs(), DeepEquals, oneJob) |
454 | + c.Assert(err, gc.IsNil) |
455 | + c.Assert(m.Id(), gc.Equals, "0/lxc/1") |
456 | + c.Assert(m.Series(), gc.Equals, "series") |
457 | + c.Assert(m.ContainerType(), gc.Equals, instance.LXC) |
458 | + c.Assert(m.Jobs(), gc.DeepEquals, oneJob) |
459 | s.assertMachineContainers(c, m0, []string{"0/lxc/0", "0/lxc/1"}) |
460 | } |
461 | |
462 | -func (s *StateSuite) TestReadMachine(c *C) { |
463 | +func (s *StateSuite) TestReadMachine(c *gc.C) { |
464 | machine, err := s.State.AddMachine("series", state.JobHostUnits) |
465 | - c.Assert(err, IsNil) |
466 | + c.Assert(err, gc.IsNil) |
467 | expectedId := machine.Id() |
468 | machine, err = s.State.Machine(expectedId) |
469 | - c.Assert(err, IsNil) |
470 | - c.Assert(machine.Id(), Equals, expectedId) |
471 | + c.Assert(err, gc.IsNil) |
472 | + c.Assert(machine.Id(), gc.Equals, expectedId) |
473 | } |
474 | |
475 | -func (s *StateSuite) TestMachineNotFound(c *C) { |
476 | +func (s *StateSuite) TestMachineNotFound(c *gc.C) { |
477 | _, err := s.State.Machine("0") |
478 | - c.Assert(err, ErrorMatches, "machine 0 not found") |
479 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
480 | -} |
481 | - |
482 | -func (s *StateSuite) TestMachineIdLessThan(c *C) { |
483 | - c.Assert(state.MachineIdLessThan("0", "0"), Equals, false) |
484 | - c.Assert(state.MachineIdLessThan("0", "1"), Equals, true) |
485 | - c.Assert(state.MachineIdLessThan("1", "0"), Equals, false) |
486 | - c.Assert(state.MachineIdLessThan("10", "2"), Equals, false) |
487 | - c.Assert(state.MachineIdLessThan("0", "0/lxc/0"), Equals, true) |
488 | - c.Assert(state.MachineIdLessThan("0/lxc/0", "0"), Equals, false) |
489 | - c.Assert(state.MachineIdLessThan("1", "0/lxc/0"), Equals, false) |
490 | - c.Assert(state.MachineIdLessThan("0/lxc/0", "1"), Equals, true) |
491 | - c.Assert(state.MachineIdLessThan("0/lxc/0/lxc/1", "0/lxc/0"), Equals, false) |
492 | - c.Assert(state.MachineIdLessThan("0/kvm/0", "0/lxc/0"), Equals, true) |
493 | -} |
494 | - |
495 | -func (s *StateSuite) TestAllMachines(c *C) { |
496 | + c.Assert(err, gc.ErrorMatches, "machine 0 not found") |
497 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
498 | +} |
499 | + |
500 | +func (s *StateSuite) TestMachineIdLessThan(c *gc.C) { |
501 | + c.Assert(state.MachineIdLessThan("0", "0"), gc.Equals, false) |
502 | + c.Assert(state.MachineIdLessThan("0", "1"), gc.Equals, true) |
503 | + c.Assert(state.MachineIdLessThan("1", "0"), gc.Equals, false) |
504 | + c.Assert(state.MachineIdLessThan("10", "2"), gc.Equals, false) |
505 | + c.Assert(state.MachineIdLessThan("0", "0/lxc/0"), gc.Equals, true) |
506 | + c.Assert(state.MachineIdLessThan("0/lxc/0", "0"), gc.Equals, false) |
507 | + c.Assert(state.MachineIdLessThan("1", "0/lxc/0"), gc.Equals, false) |
508 | + c.Assert(state.MachineIdLessThan("0/lxc/0", "1"), gc.Equals, true) |
509 | + c.Assert(state.MachineIdLessThan("0/lxc/0/lxc/1", "0/lxc/0"), gc.Equals, false) |
510 | + c.Assert(state.MachineIdLessThan("0/kvm/0", "0/lxc/0"), gc.Equals, true) |
511 | +} |
512 | + |
513 | +func (s *StateSuite) TestAllMachines(c *gc.C) { |
514 | numInserts := 42 |
515 | for i := 0; i < numInserts; i++ { |
516 | m, err := s.State.AddMachine("series", state.JobHostUnits) |
517 | - c.Assert(err, IsNil) |
518 | + c.Assert(err, gc.IsNil) |
519 | err = m.SetProvisioned(instance.Id(fmt.Sprintf("foo-%d", i)), "fake_nonce", nil) |
520 | - c.Assert(err, IsNil) |
521 | + c.Assert(err, gc.IsNil) |
522 | err = m.SetAgentTools(newTools("7.8.9-foo-bar", "http://arble.tgz")) |
523 | - c.Assert(err, IsNil) |
524 | + c.Assert(err, gc.IsNil) |
525 | err = m.Destroy() |
526 | - c.Assert(err, IsNil) |
527 | + c.Assert(err, gc.IsNil) |
528 | } |
529 | s.AssertMachineCount(c, numInserts) |
530 | ms, _ := s.State.AllMachines() |
531 | for i, m := range ms { |
532 | - c.Assert(m.Id(), Equals, strconv.Itoa(i)) |
533 | + c.Assert(m.Id(), gc.Equals, strconv.Itoa(i)) |
534 | instId, err := m.InstanceId() |
535 | - c.Assert(err, IsNil) |
536 | - c.Assert(string(instId), Equals, fmt.Sprintf("foo-%d", i)) |
537 | + c.Assert(err, gc.IsNil) |
538 | + c.Assert(string(instId), gc.Equals, fmt.Sprintf("foo-%d", i)) |
539 | tools, err := m.AgentTools() |
540 | - c.Check(err, IsNil) |
541 | - c.Check(tools, DeepEquals, newTools("7.8.9-foo-bar", "http://arble.tgz")) |
542 | - c.Assert(m.Life(), Equals, state.Dying) |
543 | + c.Check(err, gc.IsNil) |
544 | + c.Check(tools, gc.DeepEquals, newTools("7.8.9-foo-bar", "http://arble.tgz")) |
545 | + c.Assert(m.Life(), gc.Equals, state.Dying) |
546 | } |
547 | } |
548 | |
549 | -func (s *StateSuite) TestAddService(c *C) { |
550 | +func (s *StateSuite) TestAddService(c *gc.C) { |
551 | charm := s.AddTestingCharm(c, "dummy") |
552 | _, err := s.State.AddService("haha/borken", charm) |
553 | - c.Assert(err, ErrorMatches, `cannot add service "haha/borken": invalid name`) |
554 | + c.Assert(err, gc.ErrorMatches, `cannot add service "haha/borken": invalid name`) |
555 | _, err = s.State.Service("haha/borken") |
556 | - c.Assert(err, ErrorMatches, `"haha/borken" is not a valid service name`) |
557 | + c.Assert(err, gc.ErrorMatches, `"haha/borken" is not a valid service name`) |
558 | |
559 | // set that a nil charm is handled correctly |
560 | _, err = s.State.AddService("umadbro", nil) |
561 | - c.Assert(err, ErrorMatches, `cannot add service "umadbro": charm is nil`) |
562 | + c.Assert(err, gc.ErrorMatches, `cannot add service "umadbro": charm is nil`) |
563 | |
564 | wordpress, err := s.State.AddService("wordpress", charm) |
565 | - c.Assert(err, IsNil) |
566 | - c.Assert(wordpress.Name(), Equals, "wordpress") |
567 | + c.Assert(err, gc.IsNil) |
568 | + c.Assert(wordpress.Name(), gc.Equals, "wordpress") |
569 | mysql, err := s.State.AddService("mysql", charm) |
570 | - c.Assert(err, IsNil) |
571 | - c.Assert(mysql.Name(), Equals, "mysql") |
572 | + c.Assert(err, gc.IsNil) |
573 | + c.Assert(mysql.Name(), gc.Equals, "mysql") |
574 | |
575 | // Check that retrieving the new created services works correctly. |
576 | wordpress, err = s.State.Service("wordpress") |
577 | - c.Assert(err, IsNil) |
578 | - c.Assert(wordpress.Name(), Equals, "wordpress") |
579 | + c.Assert(err, gc.IsNil) |
580 | + c.Assert(wordpress.Name(), gc.Equals, "wordpress") |
581 | ch, _, err := wordpress.Charm() |
582 | - c.Assert(err, IsNil) |
583 | - c.Assert(ch.URL(), DeepEquals, charm.URL()) |
584 | + c.Assert(err, gc.IsNil) |
585 | + c.Assert(ch.URL(), gc.DeepEquals, charm.URL()) |
586 | mysql, err = s.State.Service("mysql") |
587 | - c.Assert(err, IsNil) |
588 | - c.Assert(mysql.Name(), Equals, "mysql") |
589 | + c.Assert(err, gc.IsNil) |
590 | + c.Assert(mysql.Name(), gc.Equals, "mysql") |
591 | ch, _, err = mysql.Charm() |
592 | - c.Assert(err, IsNil) |
593 | - c.Assert(ch.URL(), DeepEquals, charm.URL()) |
594 | + c.Assert(err, gc.IsNil) |
595 | + c.Assert(ch.URL(), gc.DeepEquals, charm.URL()) |
596 | } |
597 | |
598 | -func (s *StateSuite) TestServiceNotFound(c *C) { |
599 | +func (s *StateSuite) TestServiceNotFound(c *gc.C) { |
600 | _, err := s.State.Service("bummer") |
601 | - c.Assert(err, ErrorMatches, `service "bummer" not found`) |
602 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
603 | + c.Assert(err, gc.ErrorMatches, `service "bummer" not found`) |
604 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
605 | } |
606 | |
607 | -func (s *StateSuite) TestAllServices(c *C) { |
608 | +func (s *StateSuite) TestAllServices(c *gc.C) { |
609 | charm := s.AddTestingCharm(c, "dummy") |
610 | services, err := s.State.AllServices() |
611 | - c.Assert(err, IsNil) |
612 | - c.Assert(len(services), Equals, 0) |
613 | + c.Assert(err, gc.IsNil) |
614 | + c.Assert(len(services), gc.Equals, 0) |
615 | |
616 | // Check that after adding services the result is ok. |
617 | _, err = s.State.AddService("wordpress", charm) |
618 | - c.Assert(err, IsNil) |
619 | + c.Assert(err, gc.IsNil) |
620 | services, err = s.State.AllServices() |
621 | - c.Assert(err, IsNil) |
622 | - c.Assert(len(services), Equals, 1) |
623 | + c.Assert(err, gc.IsNil) |
624 | + c.Assert(len(services), gc.Equals, 1) |
625 | |
626 | _, err = s.State.AddService("mysql", charm) |
627 | - c.Assert(err, IsNil) |
628 | + c.Assert(err, gc.IsNil) |
629 | services, err = s.State.AllServices() |
630 | - c.Assert(err, IsNil) |
631 | - c.Assert(len(services), Equals, 2) |
632 | + c.Assert(err, gc.IsNil) |
633 | + c.Assert(len(services), gc.Equals, 2) |
634 | |
635 | // Check the returned service, order is defined by sorted keys. |
636 | - c.Assert(services[0].Name(), Equals, "wordpress") |
637 | - c.Assert(services[1].Name(), Equals, "mysql") |
638 | + c.Assert(services[0].Name(), gc.Equals, "wordpress") |
639 | + c.Assert(services[1].Name(), gc.Equals, "mysql") |
640 | } |
641 | |
642 | var inferEndpointsTests = []struct { |
643 | @@ -645,18 +645,18 @@ |
644 | }, |
645 | } |
646 | |
647 | -func (s *StateSuite) TestInferEndpoints(c *C) { |
648 | +func (s *StateSuite) TestInferEndpoints(c *gc.C) { |
649 | _, err := s.State.AddService("ms", s.AddTestingCharm(c, "mysql-alternative")) |
650 | - c.Assert(err, IsNil) |
651 | + c.Assert(err, gc.IsNil) |
652 | _, err = s.State.AddService("wp", s.AddTestingCharm(c, "wordpress")) |
653 | - c.Assert(err, IsNil) |
654 | + c.Assert(err, gc.IsNil) |
655 | _, err = s.State.AddService("lg", s.AddTestingCharm(c, "logging")) |
656 | - c.Assert(err, IsNil) |
657 | + c.Assert(err, gc.IsNil) |
658 | riak := s.AddTestingCharm(c, "riak") |
659 | _, err = s.State.AddService("rk1", riak) |
660 | - c.Assert(err, IsNil) |
661 | + c.Assert(err, gc.IsNil) |
662 | _, err = s.State.AddService("rk2", riak) |
663 | - c.Assert(err, IsNil) |
664 | + c.Assert(err, gc.IsNil) |
665 | |
666 | for i, t := range inferEndpointsTests { |
667 | c.Logf("test %d", i) |
668 | @@ -664,75 +664,75 @@ |
669 | c.Logf(" input %d", j) |
670 | eps, err := s.State.InferEndpoints(input) |
671 | if t.err == "" { |
672 | - c.Assert(err, IsNil) |
673 | - c.Assert(eps, DeepEquals, t.eps) |
674 | + c.Assert(err, gc.IsNil) |
675 | + c.Assert(eps, gc.DeepEquals, t.eps) |
676 | } else { |
677 | - c.Assert(err, ErrorMatches, t.err) |
678 | + c.Assert(err, gc.ErrorMatches, t.err) |
679 | } |
680 | } |
681 | } |
682 | } |
683 | |
684 | -func (s *StateSuite) TestEnvironConfig(c *C) { |
685 | +func (s *StateSuite) TestEnvironConfig(c *gc.C) { |
686 | cfg, err := s.State.EnvironConfig() |
687 | - c.Assert(err, IsNil) |
688 | + c.Assert(err, gc.IsNil) |
689 | change, err := cfg.Apply(map[string]interface{}{ |
690 | "authorized-keys": "different-keys", |
691 | "arbitrary-key": "shazam!", |
692 | }) |
693 | - c.Assert(err, IsNil) |
694 | + c.Assert(err, gc.IsNil) |
695 | err = s.State.SetEnvironConfig(change) |
696 | - c.Assert(err, IsNil) |
697 | + c.Assert(err, gc.IsNil) |
698 | cfg, err = s.State.EnvironConfig() |
699 | - c.Assert(err, IsNil) |
700 | - c.Assert(cfg.AllAttrs(), DeepEquals, change.AllAttrs()) |
701 | + c.Assert(err, gc.IsNil) |
702 | + c.Assert(cfg.AllAttrs(), gc.DeepEquals, change.AllAttrs()) |
703 | } |
704 | |
705 | -func (s *StateSuite) TestEnvironConstraints(c *C) { |
706 | +func (s *StateSuite) TestEnvironConstraints(c *gc.C) { |
707 | // Environ constraints start out empty (for now). |
708 | cons0 := emptyCons |
709 | cons1, err := s.State.EnvironConstraints() |
710 | - c.Assert(err, IsNil) |
711 | - c.Assert(cons1, DeepEquals, cons0) |
712 | + c.Assert(err, gc.IsNil) |
713 | + c.Assert(cons1, gc.DeepEquals, cons0) |
714 | |
715 | // Environ constraints can be set. |
716 | cons2 := constraints.Value{Mem: uint64p(1024)} |
717 | err = s.State.SetEnvironConstraints(cons2) |
718 | - c.Assert(err, IsNil) |
719 | + c.Assert(err, gc.IsNil) |
720 | cons3, err := s.State.EnvironConstraints() |
721 | - c.Assert(err, IsNil) |
722 | - c.Assert(cons3, DeepEquals, cons2) |
723 | - c.Assert(cons3, Not(Equals), cons2) |
724 | + c.Assert(err, gc.IsNil) |
725 | + c.Assert(cons3, gc.DeepEquals, cons2) |
726 | + c.Assert(cons3, gc.Not(gc.Equals), cons2) |
727 | |
728 | // Environ constraints are completely overwritten when re-set. |
729 | cons4 := constraints.Value{CpuPower: uint64p(250)} |
730 | err = s.State.SetEnvironConstraints(cons4) |
731 | - c.Assert(err, IsNil) |
732 | + c.Assert(err, gc.IsNil) |
733 | cons5, err := s.State.EnvironConstraints() |
734 | - c.Assert(err, IsNil) |
735 | - c.Assert(cons5, DeepEquals, cons4) |
736 | - c.Assert(cons5, Not(Equals), cons4) |
737 | + c.Assert(err, gc.IsNil) |
738 | + c.Assert(cons5, gc.DeepEquals, cons4) |
739 | + c.Assert(cons5, gc.Not(gc.Equals), cons4) |
740 | } |
741 | |
742 | -func (s *StateSuite) TestWatchServicesBulkEvents(c *C) { |
743 | +func (s *StateSuite) TestWatchServicesBulkEvents(c *gc.C) { |
744 | // Alive service... |
745 | dummyCharm := s.AddTestingCharm(c, "dummy") |
746 | alive, err := s.State.AddService("service0", dummyCharm) |
747 | - c.Assert(err, IsNil) |
748 | + c.Assert(err, gc.IsNil) |
749 | |
750 | // Dying service... |
751 | dying, err := s.State.AddService("service1", dummyCharm) |
752 | - c.Assert(err, IsNil) |
753 | + c.Assert(err, gc.IsNil) |
754 | keepDying, err := dying.AddUnit() |
755 | - c.Assert(err, IsNil) |
756 | + c.Assert(err, gc.IsNil) |
757 | err = dying.Destroy() |
758 | - c.Assert(err, IsNil) |
759 | + c.Assert(err, gc.IsNil) |
760 | |
761 | // Dead service (actually, gone, Dead == removed in this case). |
762 | gone, err := s.State.AddService("service2", dummyCharm) |
763 | - c.Assert(err, IsNil) |
764 | + c.Assert(err, gc.IsNil) |
765 | err = gone.Destroy() |
766 | - c.Assert(err, IsNil) |
767 | + c.Assert(err, gc.IsNil) |
768 | |
769 | // All except gone are reported in initial event. |
770 | w := s.State.WatchServices() |
771 | @@ -743,14 +743,14 @@ |
772 | |
773 | // Remove them all; alive/dying changes reported. |
774 | err = alive.Destroy() |
775 | - c.Assert(err, IsNil) |
776 | + c.Assert(err, gc.IsNil) |
777 | err = keepDying.Destroy() |
778 | - c.Assert(err, IsNil) |
779 | + c.Assert(err, gc.IsNil) |
780 | wc.AssertChange(alive.Name(), dying.Name()) |
781 | wc.AssertNoChange() |
782 | } |
783 | |
784 | -func (s *StateSuite) TestWatchServicesLifecycle(c *C) { |
785 | +func (s *StateSuite) TestWatchServicesLifecycle(c *gc.C) { |
786 | // Initial event is empty when no services. |
787 | w := s.State.WatchServices() |
788 | defer statetesting.AssertStop(c, w) |
789 | @@ -760,54 +760,54 @@ |
790 | |
791 | // Add a service: reported. |
792 | service, err := s.State.AddService("service", s.AddTestingCharm(c, "dummy")) |
793 | - c.Assert(err, IsNil) |
794 | + c.Assert(err, gc.IsNil) |
795 | wc.AssertChange("service") |
796 | wc.AssertNoChange() |
797 | |
798 | // Change the service: not reported. |
799 | keepDying, err := service.AddUnit() |
800 | - c.Assert(err, IsNil) |
801 | + c.Assert(err, gc.IsNil) |
802 | wc.AssertNoChange() |
803 | |
804 | // Make it Dying: reported. |
805 | err = service.Destroy() |
806 | - c.Assert(err, IsNil) |
807 | + c.Assert(err, gc.IsNil) |
808 | wc.AssertChange("service") |
809 | wc.AssertNoChange() |
810 | |
811 | // Make it Dead(/removed): reported. |
812 | err = keepDying.Destroy() |
813 | - c.Assert(err, IsNil) |
814 | + c.Assert(err, gc.IsNil) |
815 | wc.AssertChange("service") |
816 | wc.AssertNoChange() |
817 | } |
818 | |
819 | -func (s *StateSuite) TestWatchMachinesBulkEvents(c *C) { |
820 | +func (s *StateSuite) TestWatchMachinesBulkEvents(c *gc.C) { |
821 | // Alive machine... |
822 | alive, err := s.State.AddMachine("series", state.JobHostUnits) |
823 | - c.Assert(err, IsNil) |
824 | + c.Assert(err, gc.IsNil) |
825 | |
826 | // Dying machine... |
827 | dying, err := s.State.AddMachine("series", state.JobHostUnits) |
828 | - c.Assert(err, IsNil) |
829 | + c.Assert(err, gc.IsNil) |
830 | err = dying.SetProvisioned(instance.Id("i-blah"), "fake-nonce", nil) |
831 | - c.Assert(err, IsNil) |
832 | + c.Assert(err, gc.IsNil) |
833 | err = dying.Destroy() |
834 | - c.Assert(err, IsNil) |
835 | + c.Assert(err, gc.IsNil) |
836 | |
837 | // Dead machine... |
838 | dead, err := s.State.AddMachine("series", state.JobHostUnits) |
839 | - c.Assert(err, IsNil) |
840 | + c.Assert(err, gc.IsNil) |
841 | err = dead.EnsureDead() |
842 | - c.Assert(err, IsNil) |
843 | + c.Assert(err, gc.IsNil) |
844 | |
845 | // Gone machine. |
846 | gone, err := s.State.AddMachine("series", state.JobHostUnits) |
847 | - c.Assert(err, IsNil) |
848 | + c.Assert(err, gc.IsNil) |
849 | err = gone.EnsureDead() |
850 | - c.Assert(err, IsNil) |
851 | + c.Assert(err, gc.IsNil) |
852 | err = gone.Remove() |
853 | - c.Assert(err, IsNil) |
854 | + c.Assert(err, gc.IsNil) |
855 | |
856 | // All except gone machine are reported in initial event. |
857 | w := s.State.WatchEnvironMachines() |
858 | @@ -818,18 +818,18 @@ |
859 | |
860 | // Remove them all; alive/dying changes reported; dead never mentioned again. |
861 | err = alive.Destroy() |
862 | - c.Assert(err, IsNil) |
863 | + c.Assert(err, gc.IsNil) |
864 | err = dying.EnsureDead() |
865 | - c.Assert(err, IsNil) |
866 | + c.Assert(err, gc.IsNil) |
867 | err = dying.Remove() |
868 | - c.Assert(err, IsNil) |
869 | + c.Assert(err, gc.IsNil) |
870 | err = dead.Remove() |
871 | - c.Assert(err, IsNil) |
872 | + c.Assert(err, gc.IsNil) |
873 | wc.AssertChange(alive.Id(), dying.Id()) |
874 | wc.AssertNoChange() |
875 | } |
876 | |
877 | -func (s *StateSuite) TestWatchMachinesLifecycle(c *C) { |
878 | +func (s *StateSuite) TestWatchMachinesLifecycle(c *gc.C) { |
879 | // Initial event is empty when no machines. |
880 | w := s.State.WatchEnvironMachines() |
881 | defer statetesting.AssertStop(c, w) |
882 | @@ -839,43 +839,43 @@ |
883 | |
884 | // Add a machine: reported. |
885 | machine, err := s.State.AddMachine("series", state.JobHostUnits) |
886 | - c.Assert(err, IsNil) |
887 | + c.Assert(err, gc.IsNil) |
888 | wc.AssertChange("0") |
889 | wc.AssertNoChange() |
890 | |
891 | // Change the machine: not reported. |
892 | err = machine.SetProvisioned(instance.Id("i-blah"), "fake-nonce", nil) |
893 | - c.Assert(err, IsNil) |
894 | + c.Assert(err, gc.IsNil) |
895 | wc.AssertNoChange() |
896 | |
897 | // Make it Dying: reported. |
898 | err = machine.Destroy() |
899 | - c.Assert(err, IsNil) |
900 | + c.Assert(err, gc.IsNil) |
901 | wc.AssertChange("0") |
902 | wc.AssertNoChange() |
903 | |
904 | // Make it Dead: reported. |
905 | err = machine.EnsureDead() |
906 | - c.Assert(err, IsNil) |
907 | + c.Assert(err, gc.IsNil) |
908 | wc.AssertChange("0") |
909 | wc.AssertNoChange() |
910 | |
911 | // Remove it: not reported. |
912 | err = machine.Remove() |
913 | - c.Assert(err, IsNil) |
914 | + c.Assert(err, gc.IsNil) |
915 | wc.AssertNoChange() |
916 | } |
917 | |
918 | -func (s *StateSuite) TestWatchMachinesIncludesOldMachines(c *C) { |
919 | +func (s *StateSuite) TestWatchMachinesIncludesOldMachines(c *gc.C) { |
920 | // Older versions of juju do not write the "containertype" field. |
921 | // This has caused machines to not be detected in the initial event. |
922 | machine, err := s.State.AddMachine("series", state.JobHostUnits) |
923 | - c.Assert(err, IsNil) |
924 | + c.Assert(err, gc.IsNil) |
925 | err = s.machines.Update( |
926 | D{{"_id", machine.Id()}}, |
927 | D{{"$unset", D{{"containertype", 1}}}}, |
928 | ) |
929 | - c.Assert(err, IsNil) |
930 | + c.Assert(err, gc.IsNil) |
931 | |
932 | w := s.State.WatchEnvironMachines() |
933 | defer statetesting.AssertStop(c, w) |
934 | @@ -884,7 +884,7 @@ |
935 | wc.AssertNoChange() |
936 | } |
937 | |
938 | -func (s *StateSuite) TestWatchMachinesIgnoresContainers(c *C) { |
939 | +func (s *StateSuite) TestWatchMachinesIgnoresContainers(c *gc.C) { |
940 | // Initial event is empty when no machines. |
941 | w := s.State.WatchEnvironMachines() |
942 | defer statetesting.AssertStop(c, w) |
943 | @@ -898,7 +898,7 @@ |
944 | Jobs: []state.MachineJob{state.JobHostUnits}, |
945 | } |
946 | machine, err := s.State.AddMachineWithConstraints(¶ms) |
947 | - c.Assert(err, IsNil) |
948 | + c.Assert(err, gc.IsNil) |
949 | wc.AssertChange("0") |
950 | wc.AssertNoChange() |
951 | |
952 | @@ -906,36 +906,36 @@ |
953 | params.ParentId = machine.Id() |
954 | params.ContainerType = instance.LXC |
955 | m, err := s.State.AddMachineWithConstraints(¶ms) |
956 | - c.Assert(err, IsNil) |
957 | + c.Assert(err, gc.IsNil) |
958 | wc.AssertNoChange() |
959 | |
960 | // Make the container Dying: not reported. |
961 | err = m.Destroy() |
962 | - c.Assert(err, IsNil) |
963 | + c.Assert(err, gc.IsNil) |
964 | wc.AssertNoChange() |
965 | |
966 | // Make the container Dead: not reported. |
967 | err = m.EnsureDead() |
968 | - c.Assert(err, IsNil) |
969 | + c.Assert(err, gc.IsNil) |
970 | wc.AssertNoChange() |
971 | |
972 | // Remove the container: not reported. |
973 | err = m.Remove() |
974 | - c.Assert(err, IsNil) |
975 | + c.Assert(err, gc.IsNil) |
976 | wc.AssertNoChange() |
977 | } |
978 | |
979 | -func (s *StateSuite) TestWatchContainerLifecycle(c *C) { |
980 | +func (s *StateSuite) TestWatchContainerLifecycle(c *gc.C) { |
981 | // Add a host machine. |
982 | params := state.AddMachineParams{ |
983 | Series: "series", |
984 | Jobs: []state.MachineJob{state.JobHostUnits}, |
985 | } |
986 | machine, err := s.State.AddMachineWithConstraints(¶ms) |
987 | - c.Assert(err, IsNil) |
988 | + c.Assert(err, gc.IsNil) |
989 | |
990 | otherMachine, err := s.State.AddMachineWithConstraints(¶ms) |
991 | - c.Assert(err, IsNil) |
992 | + c.Assert(err, gc.IsNil) |
993 | |
994 | // Initial event is empty when no containers. |
995 | w := machine.WatchContainers(instance.LXC) |
996 | @@ -948,59 +948,59 @@ |
997 | params.ParentId = machine.Id() |
998 | params.ContainerType = instance.LXC |
999 | m, err := s.State.AddMachineWithConstraints(¶ms) |
1000 | - c.Assert(err, IsNil) |
1001 | + c.Assert(err, gc.IsNil) |
1002 | wc.AssertChange("0/lxc/0") |
1003 | wc.AssertNoChange() |
1004 | |
1005 | // Add a container of a different type: not reported. |
1006 | params.ContainerType = instance.KVM |
1007 | m1, err := s.State.AddMachineWithConstraints(¶ms) |
1008 | - c.Assert(err, IsNil) |
1009 | + c.Assert(err, gc.IsNil) |
1010 | wc.AssertNoChange() |
1011 | |
1012 | // Add a container of a different machine: not reported. |
1013 | params.ParentId = otherMachine.Id() |
1014 | params.ContainerType = instance.LXC |
1015 | m2, err := s.State.AddMachineWithConstraints(¶ms) |
1016 | - c.Assert(err, IsNil) |
1017 | + c.Assert(err, gc.IsNil) |
1018 | wc.AssertNoChange() |
1019 | |
1020 | // Make the container Dying: reported. |
1021 | err = m.Destroy() |
1022 | - c.Assert(err, IsNil) |
1023 | + c.Assert(err, gc.IsNil) |
1024 | wc.AssertChange("0/lxc/0") |
1025 | wc.AssertNoChange() |
1026 | |
1027 | // Make the other containers Dying: not reported. |
1028 | err = m1.Destroy() |
1029 | - c.Assert(err, IsNil) |
1030 | + c.Assert(err, gc.IsNil) |
1031 | err = m2.Destroy() |
1032 | - c.Assert(err, IsNil) |
1033 | + c.Assert(err, gc.IsNil) |
1034 | wc.AssertNoChange() |
1035 | |
1036 | // Make the container Dead: reported. |
1037 | err = m.EnsureDead() |
1038 | - c.Assert(err, IsNil) |
1039 | + c.Assert(err, gc.IsNil) |
1040 | wc.AssertChange("0/lxc/0") |
1041 | wc.AssertNoChange() |
1042 | |
1043 | // Make the other containers Dead: not reported. |
1044 | err = m1.EnsureDead() |
1045 | - c.Assert(err, IsNil) |
1046 | + c.Assert(err, gc.IsNil) |
1047 | err = m2.EnsureDead() |
1048 | - c.Assert(err, IsNil) |
1049 | + c.Assert(err, gc.IsNil) |
1050 | wc.AssertNoChange() |
1051 | |
1052 | // Remove the container: not reported. |
1053 | err = m.Remove() |
1054 | - c.Assert(err, IsNil) |
1055 | + c.Assert(err, gc.IsNil) |
1056 | wc.AssertNoChange() |
1057 | } |
1058 | |
1059 | -func (s *StateSuite) TestWatchMachineHardwareCharacteristics(c *C) { |
1060 | +func (s *StateSuite) TestWatchMachineHardwareCharacteristics(c *gc.C) { |
1061 | // Add a machine: reported. |
1062 | machine, err := s.State.AddMachine("series", state.JobHostUnits) |
1063 | - c.Assert(err, IsNil) |
1064 | + c.Assert(err, gc.IsNil) |
1065 | w := machine.WatchHardwareCharacteristics() |
1066 | defer statetesting.AssertStop(c, w) |
1067 | |
1068 | @@ -1010,7 +1010,7 @@ |
1069 | |
1070 | // Provision a machine: reported. |
1071 | err = machine.SetProvisioned(instance.Id("i-blah"), "fake-nonce", nil) |
1072 | - c.Assert(err, IsNil) |
1073 | + c.Assert(err, gc.IsNil) |
1074 | wc.AssertOneChange() |
1075 | |
1076 | // Alter the machine: not reported. |
1077 | @@ -1023,7 +1023,7 @@ |
1078 | URL: "http://canonical.com/", |
1079 | } |
1080 | err = machine.SetAgentTools(tools) |
1081 | - c.Assert(err, IsNil) |
1082 | + c.Assert(err, gc.IsNil) |
1083 | wc.AssertNoChange() |
1084 | } |
1085 | |
1086 | @@ -1034,28 +1034,28 @@ |
1087 | {[]instance.Port{{"b", 1}, {"a", 99}, {"a", 1}}, []instance.Port{{"a", 1}, {"a", 99}, {"b", 1}}}, |
1088 | } |
1089 | |
1090 | -func (*StateSuite) TestSortPorts(c *C) { |
1091 | +func (*StateSuite) TestSortPorts(c *gc.C) { |
1092 | for _, t := range sortPortsTests { |
1093 | p := make([]instance.Port, len(t.have)) |
1094 | copy(p, t.have) |
1095 | state.SortPorts(p) |
1096 | - c.Check(p, DeepEquals, t.want) |
1097 | + c.Check(p, gc.DeepEquals, t.want) |
1098 | state.SortPorts(p) |
1099 | - c.Check(p, DeepEquals, t.want) |
1100 | + c.Check(p, gc.DeepEquals, t.want) |
1101 | } |
1102 | } |
1103 | |
1104 | -func (*StateSuite) TestNameChecks(c *C) { |
1105 | +func (*StateSuite) TestNameChecks(c *gc.C) { |
1106 | assertService := func(s string, expect bool) { |
1107 | - c.Assert(state.IsServiceName(s), Equals, expect) |
1108 | + c.Assert(state.IsServiceName(s), gc.Equals, expect) |
1109 | // Check that anything that is considered a valid service name |
1110 | // is also (in)valid if a(n) (in)valid unit designator is added |
1111 | // to it. |
1112 | - c.Assert(state.IsUnitName(s+"/0"), Equals, expect) |
1113 | - c.Assert(state.IsUnitName(s+"/99"), Equals, expect) |
1114 | - c.Assert(state.IsUnitName(s+"/-1"), Equals, false) |
1115 | - c.Assert(state.IsUnitName(s+"/blah"), Equals, false) |
1116 | - c.Assert(state.IsUnitName(s+"/"), Equals, false) |
1117 | + c.Assert(state.IsUnitName(s+"/0"), gc.Equals, expect) |
1118 | + c.Assert(state.IsUnitName(s+"/99"), gc.Equals, expect) |
1119 | + c.Assert(state.IsUnitName(s+"/-1"), gc.Equals, false) |
1120 | + c.Assert(state.IsUnitName(s+"/blah"), gc.Equals, false) |
1121 | + c.Assert(state.IsUnitName(s+"/"), gc.Equals, false) |
1122 | } |
1123 | // Service names must be non-empty... |
1124 | assertService("", false) |
1125 | @@ -1079,7 +1079,7 @@ |
1126 | assertService("foo-2", false) |
1127 | |
1128 | assertMachine := func(s string, expect bool) { |
1129 | - c.Assert(state.IsMachineId(s), Equals, expect) |
1130 | + c.Assert(state.IsMachineId(s), gc.Equals, expect) |
1131 | } |
1132 | assertMachine("0", true) |
1133 | assertMachine("00", false) |
1134 | @@ -1104,7 +1104,7 @@ |
1135 | assertMachine("0/lxc/1/embedded/2", true) |
1136 | |
1137 | assertMachineOrNewContainer := func(s string, expect bool) { |
1138 | - c.Assert(state.IsMachineOrNewContainer(s), Equals, expect) |
1139 | + c.Assert(state.IsMachineOrNewContainer(s), gc.Equals, expect) |
1140 | } |
1141 | assertMachineOrNewContainer("0", true) |
1142 | assertMachineOrNewContainer("00", false) |
1143 | @@ -1128,7 +1128,7 @@ |
1144 | |
1145 | type attrs map[string]interface{} |
1146 | |
1147 | -func (s *StateSuite) TestWatchEnvironConfig(c *C) { |
1148 | +func (s *StateSuite) TestWatchEnvironConfig(c *gc.C) { |
1149 | w := s.State.WatchEnvironConfig() |
1150 | defer statetesting.AssertStop(c, w) |
1151 | |
1152 | @@ -1143,18 +1143,18 @@ |
1153 | } |
1154 | assertChange := func(change attrs) { |
1155 | cfg, err := s.State.EnvironConfig() |
1156 | - c.Assert(err, IsNil) |
1157 | + c.Assert(err, gc.IsNil) |
1158 | if change != nil { |
1159 | cfg, err = cfg.Apply(change) |
1160 | - c.Assert(err, IsNil) |
1161 | + c.Assert(err, gc.IsNil) |
1162 | err = s.State.SetEnvironConfig(cfg) |
1163 | - c.Assert(err, IsNil) |
1164 | + c.Assert(err, gc.IsNil) |
1165 | } |
1166 | s.State.Sync() |
1167 | select { |
1168 | case got, ok := <-w.Changes(): |
1169 | - c.Assert(ok, Equals, true) |
1170 | - c.Assert(got.AllAttrs(), DeepEquals, cfg.AllAttrs()) |
1171 | + c.Assert(ok, gc.Equals, true) |
1172 | + c.Assert(got.AllAttrs(), gc.DeepEquals, cfg.AllAttrs()) |
1173 | case <-time.After(testing.LongWait): |
1174 | c.Fatalf("did not get change: %#v", change) |
1175 | } |
1176 | @@ -1165,10 +1165,10 @@ |
1177 | assertChange(attrs{"fancy-new-key": "arbitrary-value"}) |
1178 | } |
1179 | |
1180 | -func (s *StateSuite) TestWatchForEnvironConfigChanges(c *C) { |
1181 | +func (s *StateSuite) TestWatchForEnvironConfigChanges(c *gc.C) { |
1182 | cur := version.Current.Number |
1183 | err := statetesting.SetAgentVersion(s.State, cur) |
1184 | - c.Assert(err, IsNil) |
1185 | + c.Assert(err, gc.IsNil) |
1186 | w := s.State.WatchForEnvironConfigChanges() |
1187 | defer statetesting.AssertStop(c, w) |
1188 | |
1189 | @@ -1180,28 +1180,28 @@ |
1190 | newVersion := cur |
1191 | newVersion.Minor += 1 |
1192 | err = statetesting.SetAgentVersion(s.State, newVersion) |
1193 | - c.Assert(err, IsNil) |
1194 | + c.Assert(err, gc.IsNil) |
1195 | |
1196 | newerVersion := newVersion |
1197 | newerVersion.Minor += 1 |
1198 | err = statetesting.SetAgentVersion(s.State, newerVersion) |
1199 | - c.Assert(err, IsNil) |
1200 | + c.Assert(err, gc.IsNil) |
1201 | wc.AssertOneChange() |
1202 | |
1203 | // Setting it to the same value does not trigger a change notification |
1204 | err = statetesting.SetAgentVersion(s.State, newerVersion) |
1205 | - c.Assert(err, IsNil) |
1206 | + c.Assert(err, gc.IsNil) |
1207 | wc.AssertNoChange() |
1208 | } |
1209 | |
1210 | -func (s *StateSuite) TestWatchEnvironConfigCorruptConfig(c *C) { |
1211 | +func (s *StateSuite) TestWatchEnvironConfigCorruptConfig(c *gc.C) { |
1212 | cfg, err := s.State.EnvironConfig() |
1213 | - c.Assert(err, IsNil) |
1214 | + c.Assert(err, gc.IsNil) |
1215 | |
1216 | // Corrupt the environment configuration. |
1217 | settings := s.Session.DB("juju").C("settings") |
1218 | err = settings.UpdateId("e", bson.D{{"$unset", bson.D{{"name", 1}}}}) |
1219 | - c.Assert(err, IsNil) |
1220 | + c.Assert(err, gc.IsNil) |
1221 | |
1222 | s.State.Sync() |
1223 | |
1224 | @@ -1233,19 +1233,19 @@ |
1225 | |
1226 | // Fix the configuration. |
1227 | err = s.State.SetEnvironConfig(cfg) |
1228 | - c.Assert(err, IsNil) |
1229 | + c.Assert(err, gc.IsNil) |
1230 | fixed := cfg.AllAttrs() |
1231 | |
1232 | s.State.StartSync() |
1233 | select { |
1234 | case got := <-done: |
1235 | - c.Assert(got.AllAttrs(), DeepEquals, fixed) |
1236 | + c.Assert(got.AllAttrs(), gc.DeepEquals, fixed) |
1237 | case <-time.After(5 * time.Second): |
1238 | c.Fatalf("no environment configuration observed") |
1239 | } |
1240 | } |
1241 | |
1242 | -func (s *StateSuite) TestAddAndGetEquivalence(c *C) { |
1243 | +func (s *StateSuite) TestAddAndGetEquivalence(c *gc.C) { |
1244 | // The equivalence tested here isn't necessarily correct, and |
1245 | // comparing private details is discouraged in the project. |
1246 | // The implementation might choose to cache information, or |
1247 | @@ -1256,37 +1256,37 @@ |
1248 | // about such changes. |
1249 | |
1250 | m1, err := s.State.AddMachine("series", state.JobHostUnits) |
1251 | - c.Assert(err, IsNil) |
1252 | + c.Assert(err, gc.IsNil) |
1253 | m2, err := s.State.Machine(m1.Id()) |
1254 | - c.Assert(m1, DeepEquals, m2) |
1255 | + c.Assert(m1, gc.DeepEquals, m2) |
1256 | |
1257 | charm1 := s.AddTestingCharm(c, "wordpress") |
1258 | charm2, err := s.State.Charm(charm1.URL()) |
1259 | - c.Assert(err, IsNil) |
1260 | - c.Assert(charm1, DeepEquals, charm2) |
1261 | + c.Assert(err, gc.IsNil) |
1262 | + c.Assert(charm1, gc.DeepEquals, charm2) |
1263 | |
1264 | wordpress1, err := s.State.AddService("wordpress", charm1) |
1265 | - c.Assert(err, IsNil) |
1266 | + c.Assert(err, gc.IsNil) |
1267 | wordpress2, err := s.State.Service("wordpress") |
1268 | - c.Assert(err, IsNil) |
1269 | - c.Assert(wordpress1, DeepEquals, wordpress2) |
1270 | + c.Assert(err, gc.IsNil) |
1271 | + c.Assert(wordpress1, gc.DeepEquals, wordpress2) |
1272 | |
1273 | unit1, err := wordpress1.AddUnit() |
1274 | - c.Assert(err, IsNil) |
1275 | + c.Assert(err, gc.IsNil) |
1276 | unit2, err := s.State.Unit("wordpress/0") |
1277 | - c.Assert(err, IsNil) |
1278 | - c.Assert(unit1, DeepEquals, unit2) |
1279 | + c.Assert(err, gc.IsNil) |
1280 | + c.Assert(unit1, gc.DeepEquals, unit2) |
1281 | |
1282 | _, err = s.State.AddService("mysql", s.AddTestingCharm(c, "mysql")) |
1283 | - c.Assert(err, IsNil) |
1284 | + c.Assert(err, gc.IsNil) |
1285 | eps, err := s.State.InferEndpoints([]string{"wordpress", "mysql"}) |
1286 | - c.Assert(err, IsNil) |
1287 | + c.Assert(err, gc.IsNil) |
1288 | relation1, err := s.State.AddRelation(eps...) |
1289 | - c.Assert(err, IsNil) |
1290 | + c.Assert(err, gc.IsNil) |
1291 | relation2, err := s.State.EndpointsRelation(eps...) |
1292 | - c.Assert(relation1, DeepEquals, relation2) |
1293 | + c.Assert(relation1, gc.DeepEquals, relation2) |
1294 | relation3, err := s.State.Relation(relation1.Id()) |
1295 | - c.Assert(relation1, DeepEquals, relation3) |
1296 | + c.Assert(relation1, gc.DeepEquals, relation3) |
1297 | } |
1298 | |
1299 | func tryOpenState(info *state.Info) error { |
1300 | @@ -1297,22 +1297,22 @@ |
1301 | return err |
1302 | } |
1303 | |
1304 | -func (s *StateSuite) TestOpenWithoutSetMongoPassword(c *C) { |
1305 | +func (s *StateSuite) TestOpenWithoutSetMongoPassword(c *gc.C) { |
1306 | info := state.TestingStateInfo() |
1307 | info.Tag, info.Password = "arble", "bar" |
1308 | err := tryOpenState(info) |
1309 | - c.Assert(err, checkers.Satisfies, errors.IsUnauthorizedError) |
1310 | + c.Assert(err, jc.Satisfies, errors.IsUnauthorizedError) |
1311 | |
1312 | info.Tag, info.Password = "arble", "" |
1313 | err = tryOpenState(info) |
1314 | - c.Assert(err, checkers.Satisfies, errors.IsUnauthorizedError) |
1315 | + c.Assert(err, jc.Satisfies, errors.IsUnauthorizedError) |
1316 | |
1317 | info.Tag, info.Password = "", "" |
1318 | err = tryOpenState(info) |
1319 | - c.Assert(err, IsNil) |
1320 | + c.Assert(err, gc.IsNil) |
1321 | } |
1322 | |
1323 | -func (s *StateSuite) TestOpenBadAddress(c *C) { |
1324 | +func (s *StateSuite) TestOpenBadAddress(c *gc.C) { |
1325 | info := state.TestingStateInfo() |
1326 | info.Addrs = []string{"0.1.2.3:1234"} |
1327 | st, err := state.Open(info, state.DialOpts{ |
1328 | @@ -1321,10 +1321,10 @@ |
1329 | if err == nil { |
1330 | st.Close() |
1331 | } |
1332 | - c.Assert(err, ErrorMatches, "no reachable servers") |
1333 | + c.Assert(err, gc.ErrorMatches, "no reachable servers") |
1334 | } |
1335 | |
1336 | -func (s *StateSuite) TestOpenDelaysRetryBadAddress(c *C) { |
1337 | +func (s *StateSuite) TestOpenDelaysRetryBadAddress(c *gc.C) { |
1338 | // Default mgo retry delay |
1339 | retryDelay := 500 * time.Millisecond |
1340 | info := state.TestingStateInfo() |
1341 | @@ -1337,7 +1337,7 @@ |
1342 | if err == nil { |
1343 | st.Close() |
1344 | } |
1345 | - c.Assert(err, ErrorMatches, "no reachable servers") |
1346 | + c.Assert(err, gc.ErrorMatches, "no reachable servers") |
1347 | // tryOpenState should have delayed for at least retryDelay |
1348 | // internally mgo will try three times in a row before returning |
1349 | // to the caller. |
1350 | @@ -1346,29 +1346,29 @@ |
1351 | } |
1352 | } |
1353 | |
1354 | -func testSetPassword(c *C, getEntity func() (state.Authenticator, error)) { |
1355 | +func testSetPassword(c *gc.C, getEntity func() (state.Authenticator, error)) { |
1356 | e, err := getEntity() |
1357 | - c.Assert(err, IsNil) |
1358 | + c.Assert(err, gc.IsNil) |
1359 | |
1360 | - c.Assert(e.PasswordValid("foo"), Equals, false) |
1361 | + c.Assert(e.PasswordValid("foo"), gc.Equals, false) |
1362 | err = e.SetPassword("foo") |
1363 | - c.Assert(err, IsNil) |
1364 | - c.Assert(e.PasswordValid("foo"), Equals, true) |
1365 | + c.Assert(err, gc.IsNil) |
1366 | + c.Assert(e.PasswordValid("foo"), gc.Equals, true) |
1367 | |
1368 | // Check a newly-fetched entity has the same password. |
1369 | e2, err := getEntity() |
1370 | - c.Assert(err, IsNil) |
1371 | - c.Assert(e2.PasswordValid("foo"), Equals, true) |
1372 | + c.Assert(err, gc.IsNil) |
1373 | + c.Assert(e2.PasswordValid("foo"), gc.Equals, true) |
1374 | |
1375 | err = e.SetPassword("bar") |
1376 | - c.Assert(err, IsNil) |
1377 | - c.Assert(e.PasswordValid("foo"), Equals, false) |
1378 | - c.Assert(e.PasswordValid("bar"), Equals, true) |
1379 | + c.Assert(err, gc.IsNil) |
1380 | + c.Assert(e.PasswordValid("foo"), gc.Equals, false) |
1381 | + c.Assert(e.PasswordValid("bar"), gc.Equals, true) |
1382 | |
1383 | // Check that refreshing fetches the new password |
1384 | err = e2.Refresh() |
1385 | - c.Assert(err, IsNil) |
1386 | - c.Assert(e2.PasswordValid("bar"), Equals, true) |
1387 | + c.Assert(err, gc.IsNil) |
1388 | + c.Assert(e2.PasswordValid("bar"), gc.Equals, true) |
1389 | |
1390 | if le, ok := e.(lifer); ok { |
1391 | testWhenDying(c, le, noErr, deadErr, func() error { |
1392 | @@ -1383,136 +1383,136 @@ |
1393 | SetMongoPassword(password string) error |
1394 | } |
1395 | |
1396 | -func testSetMongoPassword(c *C, getEntity func(st *state.State) (entity, error)) { |
1397 | +func testSetMongoPassword(c *gc.C, getEntity func(st *state.State) (entity, error)) { |
1398 | info := state.TestingStateInfo() |
1399 | st, err := state.Open(info, state.TestingDialOpts()) |
1400 | - c.Assert(err, IsNil) |
1401 | + c.Assert(err, gc.IsNil) |
1402 | defer st.Close() |
1403 | // Turn on fully-authenticated mode. |
1404 | err = st.SetAdminMongoPassword("admin-secret") |
1405 | - c.Assert(err, IsNil) |
1406 | + c.Assert(err, gc.IsNil) |
1407 | |
1408 | // Set the password for the entity |
1409 | ent, err := getEntity(st) |
1410 | - c.Assert(err, IsNil) |
1411 | + c.Assert(err, gc.IsNil) |
1412 | err = ent.SetMongoPassword("foo") |
1413 | - c.Assert(err, IsNil) |
1414 | + c.Assert(err, gc.IsNil) |
1415 | |
1416 | // Check that we cannot log in with the wrong password. |
1417 | info.Tag = ent.Tag() |
1418 | info.Password = "bar" |
1419 | err = tryOpenState(info) |
1420 | - c.Assert(err, checkers.Satisfies, errors.IsUnauthorizedError) |
1421 | + c.Assert(err, jc.Satisfies, errors.IsUnauthorizedError) |
1422 | |
1423 | // Check that we can log in with the correct password. |
1424 | info.Password = "foo" |
1425 | st1, err := state.Open(info, state.TestingDialOpts()) |
1426 | - c.Assert(err, IsNil) |
1427 | + c.Assert(err, gc.IsNil) |
1428 | defer st1.Close() |
1429 | |
1430 | // Change the password with an entity derived from the newly |
1431 | // opened and authenticated state. |
1432 | ent, err = getEntity(st) |
1433 | - c.Assert(err, IsNil) |
1434 | + c.Assert(err, gc.IsNil) |
1435 | err = ent.SetMongoPassword("bar") |
1436 | - c.Assert(err, IsNil) |
1437 | + c.Assert(err, gc.IsNil) |
1438 | |
1439 | // Check that we cannot log in with the old password. |
1440 | info.Password = "foo" |
1441 | err = tryOpenState(info) |
1442 | - c.Assert(err, checkers.Satisfies, errors.IsUnauthorizedError) |
1443 | + c.Assert(err, jc.Satisfies, errors.IsUnauthorizedError) |
1444 | |
1445 | // Check that we can log in with the correct password. |
1446 | info.Password = "bar" |
1447 | err = tryOpenState(info) |
1448 | - c.Assert(err, IsNil) |
1449 | + c.Assert(err, gc.IsNil) |
1450 | |
1451 | // Check that the administrator can still log in. |
1452 | info.Tag, info.Password = "", "admin-secret" |
1453 | err = tryOpenState(info) |
1454 | - c.Assert(err, IsNil) |
1455 | + c.Assert(err, gc.IsNil) |
1456 | |
1457 | // Remove the admin password so that the test harness can reset the state. |
1458 | err = st.SetAdminMongoPassword("") |
1459 | - c.Assert(err, IsNil) |
1460 | + c.Assert(err, gc.IsNil) |
1461 | } |
1462 | |
1463 | -func (s *StateSuite) TestSetAdminMongoPassword(c *C) { |
1464 | +func (s *StateSuite) TestSetAdminMongoPassword(c *gc.C) { |
1465 | // Check that we can SetAdminMongoPassword to nothing when there's |
1466 | // no password currently set. |
1467 | err := s.State.SetAdminMongoPassword("") |
1468 | - c.Assert(err, IsNil) |
1469 | + c.Assert(err, gc.IsNil) |
1470 | |
1471 | err = s.State.SetAdminMongoPassword("foo") |
1472 | - c.Assert(err, IsNil) |
1473 | + c.Assert(err, gc.IsNil) |
1474 | defer s.State.SetAdminMongoPassword("") |
1475 | info := state.TestingStateInfo() |
1476 | err = tryOpenState(info) |
1477 | - c.Assert(err, checkers.Satisfies, errors.IsUnauthorizedError) |
1478 | + c.Assert(err, jc.Satisfies, errors.IsUnauthorizedError) |
1479 | |
1480 | info.Password = "foo" |
1481 | err = tryOpenState(info) |
1482 | - c.Assert(err, IsNil) |
1483 | + c.Assert(err, gc.IsNil) |
1484 | |
1485 | err = s.State.SetAdminMongoPassword("") |
1486 | - c.Assert(err, IsNil) |
1487 | + c.Assert(err, gc.IsNil) |
1488 | |
1489 | // Check that removing the password is idempotent. |
1490 | err = s.State.SetAdminMongoPassword("") |
1491 | - c.Assert(err, IsNil) |
1492 | + c.Assert(err, gc.IsNil) |
1493 | |
1494 | info.Password = "" |
1495 | err = tryOpenState(info) |
1496 | - c.Assert(err, IsNil) |
1497 | + c.Assert(err, gc.IsNil) |
1498 | } |
1499 | |
1500 | -func (s *StateSuite) testEntity(c *C, getEntity func(string) (state.Tagger, error)) { |
1501 | +func (s *StateSuite) testEntity(c *gc.C, getEntity func(string) (state.Tagger, error)) { |
1502 | bad := []string{"", "machine", "-foo", "foo-", "---", "machine-jim", "unit-123", "unit-foo", "service-", "service-foo/bar", "environment-foo"} |
1503 | for _, name := range bad { |
1504 | c.Logf(name) |
1505 | e, err := getEntity(name) |
1506 | - c.Check(e, IsNil) |
1507 | - c.Assert(err, ErrorMatches, `invalid entity tag ".*"`) |
1508 | + c.Check(e, gc.IsNil) |
1509 | + c.Assert(err, gc.ErrorMatches, `invalid entity tag ".*"`) |
1510 | } |
1511 | |
1512 | e, err := getEntity("machine-1234") |
1513 | - c.Check(e, IsNil) |
1514 | - c.Assert(err, ErrorMatches, `machine 1234 not found`) |
1515 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
1516 | + c.Check(e, gc.IsNil) |
1517 | + c.Assert(err, gc.ErrorMatches, `machine 1234 not found`) |
1518 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
1519 | |
1520 | e, err = getEntity("unit-foo-654") |
1521 | - c.Check(e, IsNil) |
1522 | - c.Assert(err, ErrorMatches, `unit "foo/654" not found`) |
1523 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
1524 | + c.Check(e, gc.IsNil) |
1525 | + c.Assert(err, gc.ErrorMatches, `unit "foo/654" not found`) |
1526 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
1527 | |
1528 | e, err = getEntity("unit-foo-bar-654") |
1529 | - c.Check(e, IsNil) |
1530 | - c.Assert(err, ErrorMatches, `unit "foo-bar/654" not found`) |
1531 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
1532 | + c.Check(e, gc.IsNil) |
1533 | + c.Assert(err, gc.ErrorMatches, `unit "foo-bar/654" not found`) |
1534 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
1535 | |
1536 | m, err := s.State.AddMachine("series", state.JobHostUnits) |
1537 | - c.Assert(err, IsNil) |
1538 | + c.Assert(err, gc.IsNil) |
1539 | |
1540 | e, err = getEntity(m.Tag()) |
1541 | - c.Assert(err, IsNil) |
1542 | - c.Assert(e, FitsTypeOf, m) |
1543 | - c.Assert(e.Tag(), Equals, m.Tag()) |
1544 | + c.Assert(err, gc.IsNil) |
1545 | + c.Assert(e, gc.FitsTypeOf, m) |
1546 | + c.Assert(e.Tag(), gc.Equals, m.Tag()) |
1547 | |
1548 | svc, err := s.State.AddService("ser-vice2", s.AddTestingCharm(c, "mysql")) |
1549 | - c.Assert(err, IsNil) |
1550 | + c.Assert(err, gc.IsNil) |
1551 | u, err := svc.AddUnit() |
1552 | - c.Assert(err, IsNil) |
1553 | + c.Assert(err, gc.IsNil) |
1554 | |
1555 | e, err = getEntity(u.Tag()) |
1556 | - c.Assert(err, IsNil) |
1557 | - c.Assert(e, FitsTypeOf, u) |
1558 | - c.Assert(e.Tag(), Equals, u.Tag()) |
1559 | + c.Assert(err, gc.IsNil) |
1560 | + c.Assert(e, gc.FitsTypeOf, u) |
1561 | + c.Assert(e.Tag(), gc.Equals, u.Tag()) |
1562 | |
1563 | m.Destroy() |
1564 | svc.Destroy() |
1565 | } |
1566 | |
1567 | -func (s *StateSuite) TestAuthenticator(c *C) { |
1568 | +func (s *StateSuite) TestAuthenticator(c *gc.C) { |
1569 | getEntity := func(tag string) (state.Tagger, error) { |
1570 | e, err := s.State.Authenticator(tag) |
1571 | if err != nil { |
1572 | @@ -1522,29 +1522,29 @@ |
1573 | } |
1574 | s.testEntity(c, getEntity) |
1575 | e, err := getEntity("user-arble") |
1576 | - c.Check(e, IsNil) |
1577 | - c.Assert(err, ErrorMatches, `user "arble" not found`) |
1578 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
1579 | + c.Check(e, gc.IsNil) |
1580 | + c.Assert(err, gc.ErrorMatches, `user "arble" not found`) |
1581 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
1582 | |
1583 | user, err := s.State.AddUser("arble", "pass") |
1584 | - c.Assert(err, IsNil) |
1585 | + c.Assert(err, gc.IsNil) |
1586 | |
1587 | e, err = getEntity(user.Tag()) |
1588 | - c.Assert(err, IsNil) |
1589 | - c.Assert(e, FitsTypeOf, user) |
1590 | - c.Assert(e.Tag(), Equals, user.Tag()) |
1591 | + c.Assert(err, gc.IsNil) |
1592 | + c.Assert(e, gc.FitsTypeOf, user) |
1593 | + c.Assert(e.Tag(), gc.Equals, user.Tag()) |
1594 | |
1595 | cfg, err := s.State.EnvironConfig() |
1596 | - c.Assert(err, IsNil) |
1597 | + c.Assert(err, gc.IsNil) |
1598 | _, err = getEntity("environment-" + cfg.Name()) |
1599 | c.Assert( |
1600 | err, |
1601 | - ErrorMatches, |
1602 | + gc.ErrorMatches, |
1603 | `entity "environment-.*" does not support authentication`, |
1604 | ) |
1605 | } |
1606 | |
1607 | -func (s *StateSuite) TestAnnotator(c *C) { |
1608 | +func (s *StateSuite) TestAnnotator(c *gc.C) { |
1609 | getEntity := func(tag string) (state.Tagger, error) { |
1610 | e, err := s.State.Annotator(tag) |
1611 | if err != nil { |
1612 | @@ -1554,33 +1554,33 @@ |
1613 | } |
1614 | s.testEntity(c, getEntity) |
1615 | svc, err := s.State.AddService("ser-vice1", s.AddTestingCharm(c, "dummy")) |
1616 | - c.Assert(err, IsNil) |
1617 | + c.Assert(err, gc.IsNil) |
1618 | |
1619 | service, err := getEntity(svc.Tag()) |
1620 | - c.Assert(err, IsNil) |
1621 | - c.Assert(service, FitsTypeOf, svc) |
1622 | - c.Assert(service.Tag(), Equals, svc.Tag()) |
1623 | + c.Assert(err, gc.IsNil) |
1624 | + c.Assert(service, gc.FitsTypeOf, svc) |
1625 | + c.Assert(service.Tag(), gc.Equals, svc.Tag()) |
1626 | |
1627 | cfg, err := s.State.EnvironConfig() |
1628 | - c.Assert(err, IsNil) |
1629 | + c.Assert(err, gc.IsNil) |
1630 | e, err := getEntity("environment-" + cfg.Name()) |
1631 | - c.Assert(err, IsNil) |
1632 | + c.Assert(err, gc.IsNil) |
1633 | env, err := s.State.Environment() |
1634 | - c.Assert(err, IsNil) |
1635 | - c.Assert(e, FitsTypeOf, env) |
1636 | - c.Assert(e.Tag(), Equals, env.Tag()) |
1637 | + c.Assert(err, gc.IsNil) |
1638 | + c.Assert(e, gc.FitsTypeOf, env) |
1639 | + c.Assert(e.Tag(), gc.Equals, env.Tag()) |
1640 | |
1641 | user, err := s.State.AddUser("arble", "pass") |
1642 | - c.Assert(err, IsNil) |
1643 | + c.Assert(err, gc.IsNil) |
1644 | _, err = getEntity(user.Tag()) |
1645 | c.Assert( |
1646 | err, |
1647 | - ErrorMatches, |
1648 | + gc.ErrorMatches, |
1649 | `entity "user-arble" does not support annotations`, |
1650 | ) |
1651 | } |
1652 | |
1653 | -func (s *StateSuite) TestLifer(c *C) { |
1654 | +func (s *StateSuite) TestLifer(c *gc.C) { |
1655 | getEntity := func(tag string) (state.Tagger, error) { |
1656 | e, err := s.State.Lifer(tag) |
1657 | if err != nil { |
1658 | @@ -1591,29 +1591,29 @@ |
1659 | s.testEntity(c, getEntity) |
1660 | |
1661 | svc, err := s.State.AddService("riak", s.AddTestingCharm(c, "riak")) |
1662 | - c.Assert(err, IsNil) |
1663 | + c.Assert(err, gc.IsNil) |
1664 | service, err := getEntity(svc.Tag()) |
1665 | - c.Assert(err, IsNil) |
1666 | - c.Assert(service, FitsTypeOf, svc) |
1667 | - c.Assert(service.Tag(), Equals, svc.Tag()) |
1668 | + c.Assert(err, gc.IsNil) |
1669 | + c.Assert(service, gc.FitsTypeOf, svc) |
1670 | + c.Assert(service.Tag(), gc.Equals, svc.Tag()) |
1671 | |
1672 | // TODO(fwereade): when lp:1199352 (relation lacks Tag) is fixed, check |
1673 | // it works here. |
1674 | |
1675 | cfg, err := s.State.EnvironConfig() |
1676 | - c.Assert(err, IsNil) |
1677 | + c.Assert(err, gc.IsNil) |
1678 | envTag := "environment-" + cfg.Name() |
1679 | _, err = getEntity(envTag) |
1680 | errTemplate := "entity %q does not support lifecycles" |
1681 | - c.Assert(err, ErrorMatches, fmt.Sprintf(errTemplate, envTag)) |
1682 | + c.Assert(err, gc.ErrorMatches, fmt.Sprintf(errTemplate, envTag)) |
1683 | |
1684 | user, err := s.State.AddUser("arble", "pass") |
1685 | - c.Assert(err, IsNil) |
1686 | + c.Assert(err, gc.IsNil) |
1687 | _, err = getEntity(user.Tag()) |
1688 | - c.Assert(err, ErrorMatches, fmt.Sprintf(errTemplate, user.Tag())) |
1689 | + c.Assert(err, gc.ErrorMatches, fmt.Sprintf(errTemplate, user.Tag())) |
1690 | } |
1691 | |
1692 | -func (s *StateSuite) TestParseTag(c *C) { |
1693 | +func (s *StateSuite) TestParseTag(c *gc.C) { |
1694 | bad := []string{ |
1695 | "", |
1696 | "machine", |
1697 | @@ -1627,78 +1627,78 @@ |
1698 | for _, name := range bad { |
1699 | c.Logf(name) |
1700 | coll, id, err := s.State.ParseTag(name) |
1701 | - c.Check(coll, Equals, "") |
1702 | - c.Check(id, Equals, "") |
1703 | - c.Assert(err, ErrorMatches, `invalid entity name ".*"`) |
1704 | + c.Check(coll, gc.Equals, "") |
1705 | + c.Check(id, gc.Equals, "") |
1706 | + c.Assert(err, gc.ErrorMatches, `invalid entity name ".*"`) |
1707 | } |
1708 | |
1709 | // Parse a machine entity name. |
1710 | m, err := s.State.AddMachine("series", state.JobHostUnits) |
1711 | - c.Assert(err, IsNil) |
1712 | + c.Assert(err, gc.IsNil) |
1713 | coll, id, err := s.State.ParseTag(m.Tag()) |
1714 | - c.Assert(coll, Equals, "machines") |
1715 | - c.Assert(id, Equals, m.Id()) |
1716 | - c.Assert(err, IsNil) |
1717 | + c.Assert(coll, gc.Equals, "machines") |
1718 | + c.Assert(id, gc.Equals, m.Id()) |
1719 | + c.Assert(err, gc.IsNil) |
1720 | |
1721 | // Parse a service entity name. |
1722 | svc, err := s.State.AddService("ser-vice2", s.AddTestingCharm(c, "dummy")) |
1723 | - c.Assert(err, IsNil) |
1724 | + c.Assert(err, gc.IsNil) |
1725 | coll, id, err = s.State.ParseTag(svc.Tag()) |
1726 | - c.Assert(coll, Equals, "services") |
1727 | - c.Assert(id, Equals, svc.Name()) |
1728 | - c.Assert(err, IsNil) |
1729 | + c.Assert(coll, gc.Equals, "services") |
1730 | + c.Assert(id, gc.Equals, svc.Name()) |
1731 | + c.Assert(err, gc.IsNil) |
1732 | |
1733 | // Parse a unit entity name. |
1734 | u, err := svc.AddUnit() |
1735 | - c.Assert(err, IsNil) |
1736 | + c.Assert(err, gc.IsNil) |
1737 | coll, id, err = s.State.ParseTag(u.Tag()) |
1738 | - c.Assert(coll, Equals, "units") |
1739 | - c.Assert(id, Equals, u.Name()) |
1740 | - c.Assert(err, IsNil) |
1741 | + c.Assert(coll, gc.Equals, "units") |
1742 | + c.Assert(id, gc.Equals, u.Name()) |
1743 | + c.Assert(err, gc.IsNil) |
1744 | |
1745 | // Parse a user entity name. |
1746 | user, err := s.State.AddUser("arble", "pass") |
1747 | - c.Assert(err, IsNil) |
1748 | + c.Assert(err, gc.IsNil) |
1749 | coll, id, err = s.State.ParseTag(user.Tag()) |
1750 | - c.Assert(coll, Equals, "users") |
1751 | - c.Assert(id, Equals, user.Name()) |
1752 | - c.Assert(err, IsNil) |
1753 | + c.Assert(coll, gc.Equals, "users") |
1754 | + c.Assert(id, gc.Equals, user.Name()) |
1755 | + c.Assert(err, gc.IsNil) |
1756 | } |
1757 | |
1758 | -func (s *StateSuite) TestCleanup(c *C) { |
1759 | +func (s *StateSuite) TestCleanup(c *gc.C) { |
1760 | needed, err := s.State.NeedsCleanup() |
1761 | - c.Assert(err, IsNil) |
1762 | - c.Assert(needed, Equals, false) |
1763 | + c.Assert(err, gc.IsNil) |
1764 | + c.Assert(needed, gc.Equals, false) |
1765 | |
1766 | _, err = s.State.AddService("wordpress", s.AddTestingCharm(c, "wordpress")) |
1767 | - c.Assert(err, IsNil) |
1768 | + c.Assert(err, gc.IsNil) |
1769 | _, err = s.State.AddService("mysql", s.AddTestingCharm(c, "mysql")) |
1770 | - c.Assert(err, IsNil) |
1771 | + c.Assert(err, gc.IsNil) |
1772 | eps, err := s.State.InferEndpoints([]string{"wordpress", "mysql"}) |
1773 | - c.Assert(err, IsNil) |
1774 | + c.Assert(err, gc.IsNil) |
1775 | relM, err := s.State.AddRelation(eps...) |
1776 | - c.Assert(err, IsNil) |
1777 | + c.Assert(err, gc.IsNil) |
1778 | |
1779 | needed, err = s.State.NeedsCleanup() |
1780 | - c.Assert(err, IsNil) |
1781 | - c.Assert(needed, Equals, false) |
1782 | + c.Assert(err, gc.IsNil) |
1783 | + c.Assert(needed, gc.Equals, false) |
1784 | |
1785 | err = relM.Destroy() |
1786 | - c.Assert(err, IsNil) |
1787 | + c.Assert(err, gc.IsNil) |
1788 | |
1789 | needed, err = s.State.NeedsCleanup() |
1790 | - c.Assert(err, IsNil) |
1791 | - c.Assert(needed, Equals, true) |
1792 | + c.Assert(err, gc.IsNil) |
1793 | + c.Assert(needed, gc.Equals, true) |
1794 | |
1795 | err = s.State.Cleanup() |
1796 | - c.Assert(err, IsNil) |
1797 | + c.Assert(err, gc.IsNil) |
1798 | |
1799 | needed, err = s.State.NeedsCleanup() |
1800 | - c.Assert(err, IsNil) |
1801 | - c.Assert(needed, Equals, false) |
1802 | + c.Assert(err, gc.IsNil) |
1803 | + c.Assert(needed, gc.Equals, false) |
1804 | } |
1805 | |
1806 | -func (s *StateSuite) TestWatchCleanups(c *C) { |
1807 | +func (s *StateSuite) TestWatchCleanups(c *gc.C) { |
1808 | // Check initial event. |
1809 | w := s.State.WatchCleanups() |
1810 | defer statetesting.AssertStop(c, w) |
1811 | @@ -1707,36 +1707,36 @@ |
1812 | |
1813 | // Set up two relations for later use, check no events. |
1814 | _, err := s.State.AddService("wordpress", s.AddTestingCharm(c, "wordpress")) |
1815 | - c.Assert(err, IsNil) |
1816 | + c.Assert(err, gc.IsNil) |
1817 | _, err = s.State.AddService("mysql", s.AddTestingCharm(c, "mysql")) |
1818 | - c.Assert(err, IsNil) |
1819 | + c.Assert(err, gc.IsNil) |
1820 | eps, err := s.State.InferEndpoints([]string{"wordpress", "mysql"}) |
1821 | - c.Assert(err, IsNil) |
1822 | + c.Assert(err, gc.IsNil) |
1823 | relM, err := s.State.AddRelation(eps...) |
1824 | - c.Assert(err, IsNil) |
1825 | + c.Assert(err, gc.IsNil) |
1826 | _, err = s.State.AddService("varnish", s.AddTestingCharm(c, "varnish")) |
1827 | - c.Assert(err, IsNil) |
1828 | + c.Assert(err, gc.IsNil) |
1829 | eps, err = s.State.InferEndpoints([]string{"wordpress", "varnish"}) |
1830 | - c.Assert(err, IsNil) |
1831 | + c.Assert(err, gc.IsNil) |
1832 | relV, err := s.State.AddRelation(eps...) |
1833 | - c.Assert(err, IsNil) |
1834 | + c.Assert(err, gc.IsNil) |
1835 | wc.AssertNoChange() |
1836 | |
1837 | // Destroy one relation, check one change. |
1838 | err = relM.Destroy() |
1839 | - c.Assert(err, IsNil) |
1840 | + c.Assert(err, gc.IsNil) |
1841 | wc.AssertOneChange() |
1842 | |
1843 | // Handle that cleanup doc and create another, check one change. |
1844 | err = s.State.Cleanup() |
1845 | - c.Assert(err, IsNil) |
1846 | + c.Assert(err, gc.IsNil) |
1847 | err = relV.Destroy() |
1848 | - c.Assert(err, IsNil) |
1849 | + c.Assert(err, gc.IsNil) |
1850 | wc.AssertOneChange() |
1851 | |
1852 | // Clean up final doc, check change. |
1853 | err = s.State.Cleanup() |
1854 | - c.Assert(err, IsNil) |
1855 | + c.Assert(err, gc.IsNil) |
1856 | wc.AssertOneChange() |
1857 | |
1858 | // Stop watcher, check closed. |
1859 | @@ -1744,7 +1744,7 @@ |
1860 | wc.AssertClosed() |
1861 | } |
1862 | |
1863 | -func (s *StateSuite) TestWatchCleanupsBulk(c *C) { |
1864 | +func (s *StateSuite) TestWatchCleanupsBulk(c *gc.C) { |
1865 | // Check initial event. |
1866 | w := s.State.WatchCleanups() |
1867 | defer statetesting.AssertStop(c, w) |
1868 | @@ -1753,29 +1753,29 @@ |
1869 | |
1870 | // Create two peer relations by creating their services. |
1871 | riak, err := s.State.AddService("riak", s.AddTestingCharm(c, "riak")) |
1872 | - c.Assert(err, IsNil) |
1873 | + c.Assert(err, gc.IsNil) |
1874 | _, err = riak.Endpoint("ring") |
1875 | - c.Assert(err, IsNil) |
1876 | + c.Assert(err, gc.IsNil) |
1877 | allHooks, err := s.State.AddService("all-hooks", s.AddTestingCharm(c, "all-hooks")) |
1878 | - c.Assert(err, IsNil) |
1879 | + c.Assert(err, gc.IsNil) |
1880 | _, err = allHooks.Endpoint("self") |
1881 | - c.Assert(err, IsNil) |
1882 | + c.Assert(err, gc.IsNil) |
1883 | wc.AssertNoChange() |
1884 | |
1885 | // Destroy them both, check one change. |
1886 | err = riak.Destroy() |
1887 | - c.Assert(err, IsNil) |
1888 | + c.Assert(err, gc.IsNil) |
1889 | err = allHooks.Destroy() |
1890 | - c.Assert(err, IsNil) |
1891 | + c.Assert(err, gc.IsNil) |
1892 | wc.AssertOneChange() |
1893 | |
1894 | // Clean them both up, check one change. |
1895 | err = s.State.Cleanup() |
1896 | - c.Assert(err, IsNil) |
1897 | + c.Assert(err, gc.IsNil) |
1898 | wc.AssertOneChange() |
1899 | } |
1900 | |
1901 | -func (s *StateSuite) TestWatchMinUnits(c *C) { |
1902 | +func (s *StateSuite) TestWatchMinUnits(c *gc.C) { |
1903 | // Check initial event. |
1904 | w := s.State.WatchMinUnits() |
1905 | defer statetesting.AssertStop(c, w) |
1906 | @@ -1786,50 +1786,50 @@ |
1907 | // Set up services for later use. |
1908 | wordpress, err := s.State.AddService( |
1909 | "wordpress", s.AddTestingCharm(c, "wordpress")) |
1910 | - c.Assert(err, IsNil) |
1911 | + c.Assert(err, gc.IsNil) |
1912 | mysql, err := s.State.AddService("mysql", s.AddTestingCharm(c, "mysql")) |
1913 | - c.Assert(err, IsNil) |
1914 | + c.Assert(err, gc.IsNil) |
1915 | wordpressName := wordpress.Name() |
1916 | |
1917 | // Add service units for later use. |
1918 | wordpress0, err := wordpress.AddUnit() |
1919 | - c.Assert(err, IsNil) |
1920 | + c.Assert(err, gc.IsNil) |
1921 | wordpress1, err := wordpress.AddUnit() |
1922 | - c.Assert(err, IsNil) |
1923 | + c.Assert(err, gc.IsNil) |
1924 | mysql0, err := mysql.AddUnit() |
1925 | - c.Assert(err, IsNil) |
1926 | + c.Assert(err, gc.IsNil) |
1927 | // No events should occur. |
1928 | wc.AssertNoChange() |
1929 | |
1930 | // Add minimum units to a service; a single change should occur. |
1931 | err = wordpress.SetMinUnits(2) |
1932 | - c.Assert(err, IsNil) |
1933 | + c.Assert(err, gc.IsNil) |
1934 | wc.AssertChange(wordpressName) |
1935 | wc.AssertNoChange() |
1936 | |
1937 | // Decrease minimum units for a service; expect no changes. |
1938 | err = wordpress.SetMinUnits(1) |
1939 | - c.Assert(err, IsNil) |
1940 | + c.Assert(err, gc.IsNil) |
1941 | wc.AssertNoChange() |
1942 | |
1943 | // Increase minimum units for two services; a single change should occur. |
1944 | err = mysql.SetMinUnits(1) |
1945 | - c.Assert(err, IsNil) |
1946 | + c.Assert(err, gc.IsNil) |
1947 | err = wordpress.SetMinUnits(3) |
1948 | - c.Assert(err, IsNil) |
1949 | + c.Assert(err, gc.IsNil) |
1950 | wc.AssertChange(mysql.Name(), wordpressName) |
1951 | wc.AssertNoChange() |
1952 | |
1953 | // Remove minimum units for a service; expect no changes. |
1954 | err = mysql.SetMinUnits(0) |
1955 | - c.Assert(err, IsNil) |
1956 | + c.Assert(err, gc.IsNil) |
1957 | wc.AssertNoChange() |
1958 | |
1959 | // Destroy a unit of a service with required minimum units. |
1960 | // Also avoid the unit removal. A single change should occur. |
1961 | preventUnitDestroyRemove(c, wordpress0) |
1962 | err = wordpress0.Destroy() |
1963 | - c.Assert(err, IsNil) |
1964 | + c.Assert(err, gc.IsNil) |
1965 | wc.AssertChange(wordpressName) |
1966 | wc.AssertNoChange() |
1967 | |
1968 | @@ -1837,25 +1837,25 @@ |
1969 | // A single change should occur, and the service name should appear only |
1970 | // one time in the change. |
1971 | err = wordpress.SetMinUnits(5) |
1972 | - c.Assert(err, IsNil) |
1973 | + c.Assert(err, gc.IsNil) |
1974 | err = wordpress1.Destroy() |
1975 | - c.Assert(err, IsNil) |
1976 | + c.Assert(err, gc.IsNil) |
1977 | wc.AssertChange(wordpressName) |
1978 | wc.AssertNoChange() |
1979 | |
1980 | // Destroy a unit of a service not requiring minimum units; expect no changes. |
1981 | err = mysql0.Destroy() |
1982 | - c.Assert(err, IsNil) |
1983 | + c.Assert(err, gc.IsNil) |
1984 | wc.AssertNoChange() |
1985 | |
1986 | // Destroy a service with required minimum units; expect no changes. |
1987 | err = wordpress.Destroy() |
1988 | - c.Assert(err, IsNil) |
1989 | + c.Assert(err, gc.IsNil) |
1990 | wc.AssertNoChange() |
1991 | |
1992 | // Destroy a service not requiring minimum units; expect no changes. |
1993 | err = mysql.Destroy() |
1994 | - c.Assert(err, IsNil) |
1995 | + c.Assert(err, gc.IsNil) |
1996 | wc.AssertNoChange() |
1997 | |
1998 | // Stop watcher, check closed. |
1999 | @@ -1863,26 +1863,26 @@ |
2000 | wc.AssertClosed() |
2001 | } |
2002 | |
2003 | -func (s *StateSuite) TestNestingLevel(c *C) { |
2004 | - c.Assert(state.NestingLevel("0"), Equals, 0) |
2005 | - c.Assert(state.NestingLevel("0/lxc/1"), Equals, 1) |
2006 | - c.Assert(state.NestingLevel("0/lxc/1/kvm/0"), Equals, 2) |
2007 | -} |
2008 | - |
2009 | -func (s *StateSuite) TestTopParentId(c *C) { |
2010 | - c.Assert(state.TopParentId("0"), Equals, "0") |
2011 | - c.Assert(state.TopParentId("0/lxc/1"), Equals, "0") |
2012 | - c.Assert(state.TopParentId("0/lxc/1/kvm/2"), Equals, "0") |
2013 | -} |
2014 | - |
2015 | -func (s *StateSuite) TestParentId(c *C) { |
2016 | - c.Assert(state.ParentId("0"), Equals, "") |
2017 | - c.Assert(state.ParentId("0/lxc/1"), Equals, "0") |
2018 | - c.Assert(state.ParentId("0/lxc/1/kvm/0"), Equals, "0/lxc/1") |
2019 | -} |
2020 | - |
2021 | -func (s *StateSuite) TestContainerTypeFromId(c *C) { |
2022 | - c.Assert(state.ContainerTypeFromId("0"), Equals, instance.ContainerType("")) |
2023 | - c.Assert(state.ContainerTypeFromId("0/lxc/1"), Equals, instance.LXC) |
2024 | - c.Assert(state.ContainerTypeFromId("0/lxc/1/kvm/0"), Equals, instance.KVM) |
2025 | +func (s *StateSuite) TestNestingLevel(c *gc.C) { |
2026 | + c.Assert(state.NestingLevel("0"), gc.Equals, 0) |
2027 | + c.Assert(state.NestingLevel("0/lxc/1"), gc.Equals, 1) |
2028 | + c.Assert(state.NestingLevel("0/lxc/1/kvm/0"), gc.Equals, 2) |
2029 | +} |
2030 | + |
2031 | +func (s *StateSuite) TestTopParentId(c *gc.C) { |
2032 | + c.Assert(state.TopParentId("0"), gc.Equals, "0") |
2033 | + c.Assert(state.TopParentId("0/lxc/1"), gc.Equals, "0") |
2034 | + c.Assert(state.TopParentId("0/lxc/1/kvm/2"), gc.Equals, "0") |
2035 | +} |
2036 | + |
2037 | +func (s *StateSuite) TestParentId(c *gc.C) { |
2038 | + c.Assert(state.ParentId("0"), gc.Equals, "") |
2039 | + c.Assert(state.ParentId("0/lxc/1"), gc.Equals, "0") |
2040 | + c.Assert(state.ParentId("0/lxc/1/kvm/0"), gc.Equals, "0/lxc/1") |
2041 | +} |
2042 | + |
2043 | +func (s *StateSuite) TestContainerTypeFromId(c *gc.C) { |
2044 | + c.Assert(state.ContainerTypeFromId("0"), gc.Equals, instance.ContainerType("")) |
2045 | + c.Assert(state.ContainerTypeFromId("0/lxc/1"), gc.Equals, instance.LXC) |
2046 | + c.Assert(state.ContainerTypeFromId("0/lxc/1/kvm/0"), gc.Equals, instance.KVM) |
2047 | } |
2048 | |
2049 | === modified file 'state/tools_test.go' |
2050 | --- state/tools_test.go 2013-07-22 04:19:25 +0000 |
2051 | +++ state/tools_test.go 2013-07-23 22:45:38 +0000 |
2052 | @@ -6,12 +6,12 @@ |
2053 | import ( |
2054 | "fmt" |
2055 | |
2056 | - . "launchpad.net/gocheck" |
2057 | + gc "launchpad.net/gocheck" |
2058 | |
2059 | "launchpad.net/juju-core/agent/tools" |
2060 | "launchpad.net/juju-core/errors" |
2061 | "launchpad.net/juju-core/state" |
2062 | - "launchpad.net/juju-core/testing/checkers" |
2063 | + jc "launchpad.net/juju-core/testing/checkers" |
2064 | "launchpad.net/juju-core/version" |
2065 | ) |
2066 | |
2067 | @@ -24,7 +24,7 @@ |
2068 | EnsureDead() error |
2069 | } |
2070 | |
2071 | -var _ = Suite(&ToolsSuite{}) |
2072 | +var _ = gc.Suite(&ToolsSuite{}) |
2073 | |
2074 | type ToolsSuite struct { |
2075 | ConnSuite |
2076 | @@ -37,43 +37,43 @@ |
2077 | } |
2078 | } |
2079 | |
2080 | -func testAgentTools(c *C, obj tooler, agent string) { |
2081 | +func testAgentTools(c *gc.C, obj tooler, agent string) { |
2082 | // object starts with zero'd tools. |
2083 | t, err := obj.AgentTools() |
2084 | - c.Assert(t, IsNil) |
2085 | - c.Assert(err, checkers.Satisfies, errors.IsNotFoundError) |
2086 | + c.Assert(t, gc.IsNil) |
2087 | + c.Assert(err, jc.Satisfies, errors.IsNotFoundError) |
2088 | |
2089 | err = obj.SetAgentTools(&tools.Tools{}) |
2090 | - c.Assert(err, ErrorMatches, fmt.Sprintf("cannot set agent tools for %s: empty series or arch", agent)) |
2091 | + c.Assert(err, gc.ErrorMatches, fmt.Sprintf("cannot set agent tools for %s: empty series or arch", agent)) |
2092 | t2 := newTools("7.8.9-foo-bar", "http://arble.tgz") |
2093 | err = obj.SetAgentTools(t2) |
2094 | - c.Assert(err, IsNil) |
2095 | + c.Assert(err, gc.IsNil) |
2096 | t3, err := obj.AgentTools() |
2097 | - c.Assert(err, IsNil) |
2098 | - c.Assert(t3, DeepEquals, t2) |
2099 | + c.Assert(err, gc.IsNil) |
2100 | + c.Assert(t3, gc.DeepEquals, t2) |
2101 | err = obj.Refresh() |
2102 | - c.Assert(err, IsNil) |
2103 | + c.Assert(err, gc.IsNil) |
2104 | t3, err = obj.AgentTools() |
2105 | - c.Assert(err, IsNil) |
2106 | - c.Assert(t3, DeepEquals, t2) |
2107 | + c.Assert(err, gc.IsNil) |
2108 | + c.Assert(t3, gc.DeepEquals, t2) |
2109 | |
2110 | testWhenDying(c, obj, noErr, deadErr, func() error { |
2111 | return obj.SetAgentTools(t2) |
2112 | }) |
2113 | } |
2114 | |
2115 | -func (s *ToolsSuite) TestMachineAgentTools(c *C) { |
2116 | +func (s *ToolsSuite) TestMachineAgentTools(c *gc.C) { |
2117 | m, err := s.State.AddMachine("series", state.JobHostUnits) |
2118 | - c.Assert(err, IsNil) |
2119 | + c.Assert(err, gc.IsNil) |
2120 | testAgentTools(c, m, "machine 0") |
2121 | } |
2122 | |
2123 | -func (s *ToolsSuite) TestUnitAgentTools(c *C) { |
2124 | +func (s *ToolsSuite) TestUnitAgentTools(c *gc.C) { |
2125 | charm := s.AddTestingCharm(c, "dummy") |
2126 | svc, err := s.State.AddService("wordpress", charm) |
2127 | - c.Assert(err, IsNil) |
2128 | + c.Assert(err, gc.IsNil) |
2129 | unit, err := svc.AddUnit() |
2130 | - c.Assert(err, IsNil) |
2131 | + c.Assert(err, gc.IsNil) |
2132 | preventUnitDestroyRemove(c, unit) |
2133 | testAgentTools(c, unit, `unit "wordpress/0"`) |
2134 | } |
Reviewers: mp+176543_ code.launchpad. net,
Message:
Please take a look.
Description:
Trivial import testing prefix.
gc and jc prefix for imports.
https:/ /code.launchpad .net/~thumper/ juju-core/ state-gc- prefix/ +merge/ 176543
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/11745043/
Affected files:
A [revision details]
M state/state_test.go
M state/tools_test.go