本文整理汇总了Golang中github.com/juju/juju/provider/dummy.PatchTransientErrorInjectionChannel函数的典型用法代码示例。如果您正苦于以下问题:Golang PatchTransientErrorInjectionChannel函数的具体用法?Golang PatchTransientErrorInjectionChannel怎么用?Golang PatchTransientErrorInjectionChannel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PatchTransientErrorInjectionChannel函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestProvisionerStopRetryingIfDying
func (s *ProvisionerSuite) TestProvisionerStopRetryingIfDying(c *gc.C) {
// Create the error injection channel and inject
// a retryable error
errorInjectionChannel := make(chan error, 1)
p := s.newEnvironProvisioner(c)
// Don't refer the stop. We will manually stop and verify the result.
// patch the dummy provider error injection channel
cleanup := dummy.PatchTransientErrorInjectionChannel(errorInjectionChannel)
defer cleanup()
retryableError := instance.NewRetryableCreationError("container failed to start and was destroyed")
errorInjectionChannel <- retryableError
m, err := s.addMachine()
c.Assert(err, jc.ErrorIsNil)
time.Sleep(coretesting.ShortWait)
stop(c, p)
statusInfo, err := m.Status()
c.Assert(err, jc.ErrorIsNil)
c.Assert(statusInfo.Status, gc.Equals, state.StatusPending)
s.checkNoOperations(c)
}
开发者ID:felicianotech,项目名称:juju,代码行数:26,代码来源:provisioner_test.go
示例2: TestProvisionerSucceedStartInstanceWithInjectedWrappedRetryableCreationError
func (s *ProvisionerSuite) TestProvisionerSucceedStartInstanceWithInjectedWrappedRetryableCreationError(c *gc.C) {
// Set the retry delay to 0, and retry count to 1 to keep tests short
s.PatchValue(provisioner.RetryStrategyDelay, 0*time.Second)
s.PatchValue(provisioner.RetryStrategyCount, 1)
// create the error injection channel
errorInjectionChannel := make(chan error, 1)
c.Assert(errorInjectionChannel, gc.NotNil)
p := s.newEnvironProvisioner(c)
defer stop(c, p)
// patch the dummy provider error injection channel
cleanup := dummy.PatchTransientErrorInjectionChannel(errorInjectionChannel)
defer cleanup()
// send the error message once
// - instance creation should succeed
retryableError := errors.Wrap(errors.New(""), instance.NewRetryableCreationError("container failed to start and was destroyed"))
errorInjectionChannel <- retryableError
m, err := s.addMachine()
c.Assert(err, jc.ErrorIsNil)
s.checkStartInstanceNoSecureConnection(c, m)
}
开发者ID:felicianotech,项目名称:juju,代码行数:25,代码来源:provisioner_test.go
示例3: TestProvisionerFailedStartInstanceWithInjectedCreationError
func (s *ProvisionerSuite) TestProvisionerFailedStartInstanceWithInjectedCreationError(c *gc.C) {
// Set the retry delay to 0, and retry count to 2 to keep tests short
s.PatchValue(provisioner.RetryStrategyDelay, 0*time.Second)
s.PatchValue(provisioner.RetryStrategyCount, 2)
// create the error injection channel
errorInjectionChannel := make(chan error, 3)
p := s.newEnvironProvisioner(c)
defer stop(c, p)
// patch the dummy provider error injection channel
cleanup := dummy.PatchTransientErrorInjectionChannel(errorInjectionChannel)
defer cleanup()
retryableError := instance.NewRetryableCreationError("container failed to start and was destroyed")
destroyError := errors.New("container failed to start and failed to destroy: manual cleanup of containers needed")
// send the error message three times, because the provisioner will retry twice as patched above.
errorInjectionChannel <- retryableError
errorInjectionChannel <- retryableError
errorInjectionChannel <- destroyError
m, err := s.addMachine()
c.Assert(err, jc.ErrorIsNil)
s.checkNoOperations(c)
t0 := time.Now()
for time.Since(t0) < coretesting.LongWait {
// And check the machine status is set to error.
statusInfo, err := m.Status()
c.Assert(err, jc.ErrorIsNil)
if statusInfo.Status == state.StatusPending {
time.Sleep(coretesting.ShortWait)
continue
}
c.Assert(statusInfo.Status, gc.Equals, state.StatusError)
// check that the status matches the error message
c.Assert(statusInfo.Message, gc.Equals, destroyError.Error())
return
}
c.Fatal("Test took too long to complete")
}
开发者ID:felicianotech,项目名称:juju,代码行数:42,代码来源:provisioner_test.go
示例4: TestProvisionerSucceedStartInstanceWithInjectedRetryableCreationError
func (s *ProvisionerSuite) TestProvisionerSucceedStartInstanceWithInjectedRetryableCreationError(c *gc.C) {
// create the error injection channel
errorInjectionChannel := make(chan error, 1)
c.Assert(errorInjectionChannel, gc.NotNil)
p := s.newEnvironProvisioner(c)
defer stop(c, p)
// patch the dummy provider error injection channel
cleanup := dummy.PatchTransientErrorInjectionChannel(errorInjectionChannel)
defer cleanup()
// send the error message once
// - instance creation should succeed
retryableError := instance.NewRetryableCreationError("container failed to start and was destroyed")
errorInjectionChannel <- retryableError
m, err := s.addMachine()
c.Assert(err, jc.ErrorIsNil)
s.checkStartInstanceNoSecureConnection(c, m)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:21,代码来源:provisioner_test.go
示例5: TestProvisionerFailedStartInstanceWithInjectedCreationError
func (s *ProvisionerSuite) TestProvisionerFailedStartInstanceWithInjectedCreationError(c *gc.C) {
// create the error injection channel
errorInjectionChannel := make(chan error, 2)
p := s.newEnvironProvisioner(c)
defer stop(c, p)
// patch the dummy provider error injection channel
cleanup := dummy.PatchTransientErrorInjectionChannel(errorInjectionChannel)
defer cleanup()
retryableError := instance.NewRetryableCreationError("container failed to start and was destroyed")
destroyError := errors.New("container failed to start and failed to destroy: manual cleanup of containers needed")
// send the error message TWICE, because the provisioner will retry only ONCE
errorInjectionChannel <- retryableError
errorInjectionChannel <- destroyError
m, err := s.addMachine()
c.Assert(err, jc.ErrorIsNil)
s.checkNoOperations(c)
t0 := time.Now()
for time.Since(t0) < coretesting.LongWait {
// And check the machine status is set to error.
statusInfo, err := m.Status()
c.Assert(err, jc.ErrorIsNil)
if statusInfo.Status == state.StatusPending {
time.Sleep(coretesting.ShortWait)
continue
}
c.Assert(statusInfo.Status, gc.Equals, state.StatusError)
// check that the status matches the error message
c.Assert(statusInfo.Message, gc.Equals, destroyError.Error())
break
}
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:37,代码来源:provisioner_test.go
示例6: TestProvisionerFailStartInstanceWithInjectedNonRetryableCreationError
func (s *ProvisionerSuite) TestProvisionerFailStartInstanceWithInjectedNonRetryableCreationError(c *gc.C) {
// create the error injection channel
errorInjectionChannel := make(chan error, 1)
c.Assert(errorInjectionChannel, gc.NotNil)
p := s.newEnvironProvisioner(c)
defer stop(c, p)
// patch the dummy provider error injection channel
cleanup := dummy.PatchTransientErrorInjectionChannel(errorInjectionChannel)
defer cleanup()
// send the error message once
nonRetryableError := errors.New("some nonretryable error")
errorInjectionChannel <- nonRetryableError
m, err := s.addMachine()
c.Assert(err, jc.ErrorIsNil)
s.checkNoOperations(c)
t0 := time.Now()
for time.Since(t0) < coretesting.LongWait {
// And check the machine status is set to error.
statusInfo, err := m.Status()
c.Assert(err, jc.ErrorIsNil)
if statusInfo.Status == state.StatusPending {
time.Sleep(coretesting.ShortWait)
continue
}
c.Assert(statusInfo.Status, gc.Equals, state.StatusError)
// check that the status matches the error message
c.Assert(statusInfo.Message, gc.Equals, nonRetryableError.Error())
return
}
c.Fatal("Test took too long to complete")
}
开发者ID:felicianotech,项目名称:juju,代码行数:36,代码来源:provisioner_test.go
注:本文中的github.com/juju/juju/provider/dummy.PatchTransientErrorInjectionChannel函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论