~rogpeppe/juju-core/axwalk-lp1300889-disable-mongo-keyfile

« back to all changes in this revision

Viewing changes to worker/apiaddressupdater/apiaddressupdater_test.go

  • Committer: Roger Peppe
  • Date: 2014-04-02 11:37:02 UTC
  • Revision ID: roger.peppe@canonical.com-20140402113702-6t4kmxkpww0dsydb
apiaddressupdater: fix test

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
        worker := apiaddressupdater.NewAPIAddressUpdater(st.Machiner(), setter)
73
73
        defer func() { c.Assert(worker.Wait(), gc.IsNil) }()
74
74
        defer worker.Kill()
75
 
 
 
75
        s.BackingState.StartSync()
76
76
        updatedServers := [][]instance.HostPort{instance.AddressesWithPort(
77
77
                instance.NewAddresses("localhost", "127.0.0.1"),
78
78
                1234,
79
79
        )}
80
 
        err := s.State.SetAPIHostPorts(updatedServers)
81
 
        c.Assert(err, gc.IsNil)
82
 
 
83
80
        // SetAPIHostPorts should be called with the initial value (empty),
84
81
        // and then the updated value.
85
 
        n := 0
86
 
        select {
87
 
        case <-time.After(coretesting.LongWait):
88
 
                c.Fatalf("timed out waiting for SetAPIHostPorts to be called")
89
 
        case servers := <-setter.servers:
90
 
                if n == 0 {
91
 
                        c.Assert(servers, gc.HasLen, 0)
92
 
                } else {
93
 
                        c.Assert(servers, gc.DeepEquals, updatedServers)
94
 
                }
95
 
                n++
 
82
        select {
 
83
        case <-time.After(coretesting.LongWait):
 
84
                c.Fatalf("timed out waiting for SetAPIHostPorts to be called first")
 
85
        case servers := <-setter.servers:
 
86
                c.Assert(servers, gc.HasLen, 0)
 
87
        }
 
88
        err := s.State.SetAPIHostPorts(updatedServers)
 
89
        c.Assert(err, gc.IsNil)
 
90
        s.BackingState.StartSync()
 
91
        select {
 
92
        case <-time.After(coretesting.LongWait):
 
93
                c.Fatalf("timed out waiting for SetAPIHostPorts to be called second")
 
94
        case servers := <-setter.servers:
 
95
                c.Assert(servers, gc.DeepEquals, updatedServers)
96
96
        }
97
97
}