示例#1
0
func (s *KillSuite) TestKillEarlyAPIConnectionTimeout(c *gc.C) {
	stop := make(chan struct{})
	defer close(stop)
	testDialer := func(sysName string) (*api.State, error) {
		<-stop
		return nil, errors.New("kill command waited too long")
	}

	done := make(chan struct{})
	go func() {
		defer close(done)
		cmd := system.NewKillCommand(nil, nil, nil, testDialer)
		ctx, err := testing.RunCommand(c, cmd, "test1", "-y")
		c.Check(err, jc.ErrorIsNil)
		c.Check(testing.Stderr(ctx), jc.Contains, "Unable to open API: connection to state server timed out")
		c.Check(s.api.ignoreBlocks, jc.IsFalse)
		c.Check(s.api.destroyAll, jc.IsFalse)
		checkSystemRemovedFromStore(c, "test1", s.store)
	}()
	select {
	case <-done:
	case <-time.After(1 * time.Minute):
		c.Fatalf("Kill command waited too long to open the API")
	}
}
示例#2
0
func (s *KillSuite) newKillCommand() cmd.Command {
	return system.NewKillCommand(
		s.api,
		s.clientapi,
		s.apierror,
		func(name string) (api.Connection, error) {
			return juju.NewAPIFromName(name, nil)
		})
}
示例#3
0
func (s *KillSuite) runKillCommand(c *gc.C, args ...string) (*cmd.Context, error) {
	cmd := system.NewKillCommand(
		s.api,
		s.clientapi,
		s.apierror,
		func(name string) (api.Connection, error) {
			return juju.NewAPIFromName(name, nil)
		})
	return testing.RunCommand(c, cmd, args...)
}
示例#4
0
func (s *KillSuite) TestKillAPIPermErrFails(c *gc.C) {
	testDialer := func(sysName string) (*api.State, error) {
		return nil, common.ErrPerm
	}

	cmd := system.NewKillCommand(nil, nil, nil, testDialer)
	_, err := testing.RunCommand(c, cmd, "test1", "-y")
	c.Assert(err, gc.ErrorMatches, "cannot destroy system: permission denied")
	c.Assert(s.api.ignoreBlocks, jc.IsFalse)
	checkSystemExistsInStore(c, "test1", s.store)
}
示例#5
0
func (s *KillSuite) TestKillNoDialer(c *gc.C) {
	cmd := system.NewKillCommand(nil, nil, nil, nil)
	_, err := testing.RunCommand(c, cmd, "test1", "-y")
	c.Assert(err, gc.ErrorMatches, "no api dialer specified")
}
示例#6
0
func (s *KillSuite) newKillCommand() *system.KillCommand {
	return system.NewKillCommand(s.api, s.clientapi, s.apierror, juju.NewAPIFromName)
}
示例#7
0
func (s *KillSuite) runKillCommand(c *gc.C, args ...string) (*cmd.Context, error) {
	cmd := system.NewKillCommand(s.api, s.clientapi, s.apierror, juju.NewAPIFromName)
	return testing.RunCommand(c, cmd, args...)
}