コード例 #1
0
ファイル: lxc_test.go プロジェクト: makyo/juju
func (s *LxcSuite) TestCreateContainerFailsWithInjectedCreateError(c *gc.C) {
	errorChannel := make(chan error, 1)
	cleanup := mock.PatchCreateTransientErrorInjectionChannel(errorChannel)
	defer cleanup()

	errorChannel <- errors.New("lxc-create error")

	manager := s.makeManager(c, "test")
	_, err := containertesting.CreateContainerTest(c, manager, "1/lxc/0")
	c.Assert(err, gc.NotNil)

	// this should be a retryable error
	isRetryable := instance.IsRetryableCreationError(errors.Cause(err))
	c.Assert(isRetryable, jc.IsTrue)
	c.Assert(err, gc.ErrorMatches, "lxc container creation failed.*")
}
コード例 #2
0
ファイル: lxc_test.go プロジェクト: makyo/juju
func (s *LxcSuite) TestCreateContainerFailsWithInjectedStartError(c *gc.C) {
	errorChannel := make(chan error, 1)
	cleanup := mock.PatchStartTransientErrorInjectionChannel(errorChannel)
	defer cleanup()

	// One injected error means the container creation will fail
	// but the destroy function will clean up the remaining container
	// resulting in a RetryableCreationError
	errorChannel <- errors.New("start error")

	manager := s.makeManager(c, "test")
	_, err := containertesting.CreateContainerTest(c, manager, "1/lxc/0")
	c.Assert(err, gc.NotNil)

	// this should be a retryable error
	isRetryable := instance.IsRetryableCreationError(errors.Cause(err))
	c.Assert(isRetryable, jc.IsTrue)
}
コード例 #3
0
ファイル: lxc_test.go プロジェクト: makyo/juju
func (s *LxcSuite) TestCreateContainerWithInjectedErrorDestroyFails(c *gc.C) {
	errorChannel := make(chan error, 2)
	cleanup := mock.PatchStartTransientErrorInjectionChannel(errorChannel)
	defer cleanup()

	// Two injected errors mean that the container creation and subsequent
	// destroy will fail. This should not result in a RetryableCreationError
	// as the container was left in an error state
	errorChannel <- errors.New("create error")
	errorChannel <- errors.New("destroy error")

	manager := s.makeManager(c, "test")
	_, err := containertesting.CreateContainerTest(c, manager, "1/lxc/0")
	c.Assert(err, gc.NotNil)

	// this should not be a retryable error
	isRetryable := instance.IsRetryableCreationError(errors.Cause(err))
	c.Assert(isRetryable, jc.IsFalse)
}