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,
1188
return worker.NewNoOpWorker()
1190
s.PatchValue(&newCertificateUpdater, newUpdater)
1192
// Set up the machine agent.
1193
m, _, _ := s.primeAgent(c, version.Current, state.JobManageEnviron)
1194
a := s.newAgent(c, m)
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")
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() {
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 {
1214
time.Sleep(10 * time.Millisecond)
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.
1223
case <-time.After(coretesting.LongWait):
1224
c.Fatalf("timeout while waiting for certificate to be updated")
1183
1228
func (s *MachineSuite) TestMachineAgentNetworkerMode(c *gc.C) {
1184
1229
tests := []struct {