// checkStartInstance checks that an instance has been started // with a machine id the same as m's, and that the machine's // instance id has been set appropriately. func (s *ProvisionerSuite) checkStartInstance(c *C, m *state.Machine, secret string) { s.State.StartSync() for { select { case o := <-s.op: switch o := o.(type) { case dummy.OpStartInstance: info := s.StateInfo(c) info.EntityName = m.EntityName() c.Assert(o.Info.Password, Not(HasLen), 0) info.Password = o.Info.Password c.Assert(o.Info, DeepEquals, info) // Check we can connect to the state with // the machine's entity name and password. st, err := state.Open(o.Info) c.Assert(err, IsNil) st.Close() c.Assert(o.MachineId, Equals, m.Id()) c.Assert(o.Instance, NotNil) s.checkInstanceId(c, m, o.Instance) c.Assert(o.Secret, Equals, secret) return default: c.Logf("ignoring unexpected operation %#v", o) } case <-time.After(2 * time.Second): c.Errorf("provisioner did not start an instance") return } } }