~sinzui/ubuntu/wily/juju-core/wily-1.24.5

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/jujud/agent/machine_test.go

  • Committer: Package Import Robot
  • Author(s): Oleg Strikov
  • Date: 2015-04-14 14:11:54 UTC
  • mfrom: (1.1.33)
  • Revision ID: package-import@ubuntu.com-20150414141154-7vw7hcjo53nkt9vo
Tags: 1.22.1-0ubuntu1
* New upstream bugfix release (LP: #1444037).
* Autopkgtests were changed to switch back to upstart before running their
  workload. This is needed because juju < 1.23 doesn't support systemd.
* d/patches/fix-detect-new-release.patch: Removed because applied upstream.
* d/copyright: Updated to reflect changes in the codebase.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1180
1180
        }
1181
1181
}
1182
1182
 
 
1183
func (s *MachineSuite) TestCertificateDNSUpdated(c *gc.C) {
 
1184
        // Disable the certificate work so it doesn't update the certificate.
 
1185
        newUpdater := func(certupdater.AddressWatcher, certupdater.StateServingInfoGetter, certupdater.EnvironConfigGetter,
 
1186
                certupdater.StateServingInfoSetter, chan params.StateServingInfo,
 
1187
        ) worker.Worker {
 
1188
                return worker.NewNoOpWorker()
 
1189
        }
 
1190
        s.PatchValue(&newCertificateUpdater, newUpdater)
 
1191
 
 
1192
        // Set up the machine agent.
 
1193
        m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)
 
1194
        a := s.newAgent(c, m)
 
1195
 
 
1196
        // Set up check that certificate has been updated when the agent starts.
 
1197
        updated := make(chan struct{})
 
1198
        expectedDnsNames := set.NewStrings("local", "juju-apiserver", "juju-mongodb")
 
1199
        go func() {
 
1200
                for {
 
1201
                        stateInfo, _ := a.CurrentConfig().StateServingInfo()
 
1202
                        srvCert, err := cert.ParseCert(stateInfo.Cert)
 
1203
                        c.Assert(err, jc.ErrorIsNil)
 
1204
                        certDnsNames := set.NewStrings(srvCert.DNSNames...)
 
1205
                        if !expectedDnsNames.Difference(certDnsNames).IsEmpty() {
 
1206
                                continue
 
1207
                        }
 
1208
                        pemContent, err := ioutil.ReadFile(filepath.Join(s.DataDir(), "server.pem"))
 
1209
                        c.Assert(err, jc.ErrorIsNil)
 
1210
                        if string(pemContent) == stateInfo.Cert+"\n"+stateInfo.PrivateKey {
 
1211
                                close(updated)
 
1212
                                break
 
1213
                        }
 
1214
                        time.Sleep(10 * time.Millisecond)
 
1215
                }
 
1216
        }()
 
1217
 
 
1218
        go func() { c.Check(a.Run(nil), jc.ErrorIsNil) }()
 
1219
        defer func() { c.Check(a.Stop(), jc.ErrorIsNil) }()
 
1220
        // Wait for certificate to be updated.
 
1221
        select {
 
1222
        case <-updated:
 
1223
        case <-time.After(coretesting.LongWait):
 
1224
                c.Fatalf("timeout while waiting for certificate to be updated")
 
1225
        }
 
1226
}
 
1227
 
1183
1228
func (s *MachineSuite) TestMachineAgentNetworkerMode(c *gc.C) {
1184
1229
        tests := []struct {
1185
1230
                about          string