~ubuntu-branches/ubuntu/saucy/juju-core/saucy

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/worker/provisioner/provisioner_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-23 08:51:44 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130723085144-0oty5omapea7t8xt
Tags: 1.11.4-0ubuntu1
* New upstream release:
  - d/copyright: Drop section for go-curl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
        select {
177
177
        case o := <-s.op:
178
178
                c.Fatalf("unexpected operation %#v", o)
179
 
        case <-time.After(200 * time.Millisecond):
 
179
        case <-time.After(coretesting.ShortWait):
180
180
                return
181
181
        }
182
182
}
210
210
}
211
211
 
212
212
func (s *CommonProvisionerSuite) waitMachine(c *C, m *state.Machine, check func() bool) {
 
213
        // TODO(jam): We need to grow a new method on NotifyWatcherC
 
214
        // that calls StartSync while waiting for changes, then
 
215
        // waitMachine and waitHardwareCharacteristics can use that
 
216
        // instead
213
217
        w := m.Watch()
214
218
        defer stop(c, w)
215
 
        timeout := time.After(500 * time.Millisecond)
 
219
        timeout := time.After(coretesting.LongWait)
216
220
        resync := time.After(0)
217
221
        for {
218
222
                select {
221
225
                                return
222
226
                        }
223
227
                case <-resync:
224
 
                        resync = time.After(50 * time.Millisecond)
 
228
                        resync = time.After(coretesting.ShortWait)
225
229
                        s.State.StartSync()
226
230
                case <-timeout:
227
231
                        c.Fatalf("machine %v wait timed out", m)
232
236
func (s *CommonProvisionerSuite) waitHardwareCharacteristics(c *C, m *state.Machine, check func() bool) {
233
237
        w := m.WatchHardwareCharacteristics()
234
238
        defer stop(c, w)
235
 
        timeout := time.After(500 * time.Millisecond)
 
239
        timeout := time.After(coretesting.LongWait)
236
240
        resync := time.After(0)
237
241
        for {
238
242
                select {
241
245
                                return
242
246
                        }
243
247
                case <-resync:
244
 
                        resync = time.After(50 * time.Millisecond)
 
248
                        resync = time.After(coretesting.ShortWait)
245
249
                        s.State.StartSync()
246
250
                case <-timeout:
247
251
                        c.Fatalf("hardware characteristics for machine %v wait timed out", m)
335
339
        c.Assert(err, IsNil)
336
340
        s.checkNoOperations(c)
337
341
 
338
 
        // And check the machine status is set to error.
339
 
        status, info, err := m.Status()
340
 
        c.Assert(err, IsNil)
341
 
        c.Assert(status, Equals, params.StatusError)
342
 
        c.Assert(info, Equals, brokenMsg)
 
342
        t0 := time.Now()
 
343
        for time.Since(t0) < coretesting.LongWait {
 
344
                // And check the machine status is set to error.
 
345
                status, info, err := m.Status()
 
346
                c.Assert(err, IsNil)
 
347
                if status == params.StatusPending {
 
348
                        time.Sleep(coretesting.ShortWait)
 
349
                        continue
 
350
                }
 
351
                c.Assert(status, Equals, params.StatusError)
 
352
                c.Assert(info, Equals, brokenMsg)
 
353
                break
 
354
        }
343
355
 
344
356
        // Unbreak the environ config.
345
357
        err = s.fixEnvironment()
563
575
        // wait for the PA to load the new configuration
564
576
        select {
565
577
        case <-cfgObserver:
566
 
        case <-time.After(200 * time.Millisecond):
 
578
        case <-time.After(coretesting.LongWait):
567
579
                c.Fatalf("PA did not action config change")
568
580
        }
569
581