Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2553)

Delta Between Two Patch Sets: environs/jujutest/livetests.go

Issue 6696043: environs/jujutest: use AttemptStrategy
Left Patch Set: environs/jujutest: use AttemptStrategy Created 12 years, 6 months ago
Right Patch Set: environs/jujutest: use AttemptStrategy Created 12 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « environs/ec2/live_test.go ('k') | environs/jujutest/tests.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package jujutest 1 package jujutest
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 . "launchpad.net/gocheck" 5 . "launchpad.net/gocheck"
6 "launchpad.net/juju-core/charm" 6 "launchpad.net/juju-core/charm"
7 "launchpad.net/juju-core/environs" 7 "launchpad.net/juju-core/environs"
8 "launchpad.net/juju-core/environs/config" 8 "launchpad.net/juju-core/environs/config"
9 "launchpad.net/juju-core/juju" 9 "launchpad.net/juju-core/juju"
10 "launchpad.net/juju-core/juju/testing" 10 "launchpad.net/juju-core/juju/testing"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 insts, err = t.Env.Instances([]string{id0, ""}) 117 insts, err = t.Env.Instances([]string{id0, ""})
118 c.Assert(err, Equals, environs.ErrPartialInstances) 118 c.Assert(err, Equals, environs.ErrPartialInstances)
119 c.Assert(insts, HasLen, 2) 119 c.Assert(insts, HasLen, 2)
120 c.Check(insts[0].Id(), Equals, id0) 120 c.Check(insts[0].Id(), Equals, id0)
121 c.Check(insts[1], IsNil) 121 c.Check(insts[1], IsNil)
122 122
123 err = t.Env.StopInstances([]environs.Instance{inst}) 123 err = t.Env.StopInstances([]environs.Instance{inst})
124 c.Assert(err, IsNil) 124 c.Assert(err, IsNil)
125 125
126 » // Stopping may not be noticed at first due to eventual 126 » // The machine may not be marked as shutting down
127 » // consistency. Repeat a few times to ensure we get the error. 127 » // immediately. Repeat a few times to ensure we get the error.
128 for a := t.Attempt.Start(); a.Next(); { 128 for a := t.Attempt.Start(); a.Next(); {
129 insts, err = t.Env.Instances([]string{id0}) 129 insts, err = t.Env.Instances([]string{id0})
130 if err != nil { 130 if err != nil {
131 break 131 break
132 } 132 }
133 } 133 }
134 c.Assert(err, Equals, environs.ErrNoInstances) 134 c.Assert(err, Equals, environs.ErrNoInstances)
135 c.Assert(insts, HasLen, 0) 135 c.Assert(insts, HasLen, 0)
136 } 136 }
137 137
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 err = inst1.ClosePorts(1, []state.Port{{"tcp", 45}, {"udp", 67}}) 204 err = inst1.ClosePorts(1, []state.Port{{"tcp", 45}, {"udp", 67}})
205 c.Assert(err, IsNil) 205 c.Assert(err, IsNil)
206 ports, err = inst1.Ports(1) 206 ports, err = inst1.Ports(1)
207 c.Assert(ports, HasLen, 0) 207 c.Assert(ports, HasLen, 0)
208 208
209 // Check that we can close ports that aren't there. 209 // Check that we can close ports that aren't there.
210 err = inst2.ClosePorts(2, []state.Port{{"tcp", 111}, {"udp", 222}}) 210 err = inst2.ClosePorts(2, []state.Port{{"tcp", 111}, {"udp", 222}})
211 c.Assert(err, IsNil) 211 c.Assert(err, IsNil)
212 ports, err = inst2.Ports(2) 212 ports, err = inst2.Ports(2)
213 c.Assert(ports, DeepEquals, []state.Port{{"tcp", 89}}) 213 c.Assert(ports, DeepEquals, []state.Port{{"tcp", 89}})
214
215 // Check errors when acting on environment.
216 err = t.Env.OpenPorts([]state.Port{{"tcp", 80}})
217 c.Assert(err, ErrorMatches, `invalid firewall mode for opening ports on environment: "instance"`)
218
219 err = t.Env.ClosePorts([]state.Port{{"tcp", 80}})
220 c.Assert(err, ErrorMatches, `invalid firewall mode for closing ports on environment: "instance"`)
221
222 _, err = t.Env.Ports()
223 c.Assert(err, ErrorMatches, `invalid firewall mode for retrieving ports from environment: "instance"`)
214 } 224 }
215 225
216 func (t *LiveTests) TestGlobalPorts(c *C) { 226 func (t *LiveTests) TestGlobalPorts(c *C) {
217 // Change configuration. 227 // Change configuration.
218 oldConfig := t.Env.Config() 228 oldConfig := t.Env.Config()
219 defer func() { 229 defer func() {
220 err := t.Env.SetConfig(oldConfig) 230 err := t.Env.SetConfig(oldConfig)
221 c.Assert(err, IsNil) 231 c.Assert(err, IsNil)
222 }() 232 }()
223 233
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 c.Assert(err, IsNil) 268 c.Assert(err, IsNil)
259 c.Assert(ports, DeepEquals, []state.Port{{"tcp", 45}, {"tcp", 89}}) 269 c.Assert(ports, DeepEquals, []state.Port{{"tcp", 45}, {"tcp", 89}})
260 270
261 // Check that we can close ports that aren't there. 271 // Check that we can close ports that aren't there.
262 err = t.Env.ClosePorts([]state.Port{{"tcp", 111}, {"udp", 222}}) 272 err = t.Env.ClosePorts([]state.Port{{"tcp", 111}, {"udp", 222}})
263 c.Assert(err, IsNil) 273 c.Assert(err, IsNil)
264 274
265 ports, err = t.Env.Ports() 275 ports, err = t.Env.Ports()
266 c.Assert(err, IsNil) 276 c.Assert(err, IsNil)
267 c.Assert(ports, DeepEquals, []state.Port{{"tcp", 45}, {"tcp", 89}}) 277 c.Assert(ports, DeepEquals, []state.Port{{"tcp", 45}, {"tcp", 89}})
278
279 // Check errors when acting on instances.
280 err = inst1.OpenPorts(1, []state.Port{{"tcp", 80}})
281 c.Assert(err, ErrorMatches, `invalid firewall mode for opening ports on instance: "global"`)
282
283 err = inst1.ClosePorts(1, []state.Port{{"tcp", 80}})
284 c.Assert(err, ErrorMatches, `invalid firewall mode for closing ports on instance: "global"`)
285
286 _, err = inst1.Ports(1)
287 c.Assert(err, ErrorMatches, `invalid firewall mode for retrieving ports from instance: "global"`)
268 } 288 }
269 289
270 func (t *LiveTests) TestBootstrapMultiple(c *C) { 290 func (t *LiveTests) TestBootstrapMultiple(c *C) {
271 t.BootstrapOnce(c) 291 t.BootstrapOnce(c)
272 292
273 » var err error 293 » err := t.Env.Bootstrap(false)
274 » for a := t.Attempt.Start(); a.Next(); {
275 » » if err = t.Env.Bootstrap(false); err != nil {
276 » » » break
277 » » }
278 » }
279 c.Assert(err, ErrorMatches, "environment is already bootstrapped") 294 c.Assert(err, ErrorMatches, "environment is already bootstrapped")
280 295
281 c.Logf("destroy env") 296 c.Logf("destroy env")
282 t.Destroy(c) 297 t.Destroy(c)
283 t.Destroy(c) // Again, should work fine and do nothing. 298 t.Destroy(c) // Again, should work fine and do nothing.
284 299
285 // check that we can bootstrap after destroy 300 // check that we can bootstrap after destroy
286 t.BootstrapOnce(c) 301 t.BootstrapOnce(c)
287 } 302 }
288 303
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 651 }
637 652
638 inst, err := t.Env.StartInstance(4, testing.InvalidStateInfo(4), tools) 653 inst, err := t.Env.StartInstance(4, testing.InvalidStateInfo(4), tools)
639 if inst != nil { 654 if inst != nil {
640 err := t.Env.StopInstances([]environs.Instance{inst}) 655 err := t.Env.StopInstances([]environs.Instance{inst})
641 c.Check(err, IsNil) 656 c.Check(err, IsNil)
642 } 657 }
643 c.Assert(inst, IsNil) 658 c.Assert(inst, IsNil)
644 c.Assert(err, ErrorMatches, "cannot find image.*") 659 c.Assert(err, ErrorMatches, "cannot find image.*")
645 } 660 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b