本文整理汇总了Golang中github.com/juju/juju/worker/workertest.CheckKilled函数的典型用法代码示例。如果您正苦于以下问题:Golang CheckKilled函数的具体用法?Golang CheckKilled怎么用?Golang CheckKilled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CheckKilled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestClosedChangesChannel
func (s *suite) TestClosedChangesChannel(c *gc.C) {
s.runDirtyTest(c, func(w worker.Worker, backend *mockBackend) {
backend.sendModelChange("uuid1", "uuid2")
workers := s.waitWorkers(c, 2)
close(backend.envWatcher.changes)
err := workertest.CheckKilled(c, w)
c.Check(err, gc.ErrorMatches, "changes stopped")
for _, worker := range workers {
workertest.CheckKilled(c, worker)
}
s.assertNoWorkers(c)
})
}
示例2: TestStopKills
func (*WorkerSuite) TestStopKills(c *gc.C) {
w := workertest.NewErrorWorker(nil)
defer workertest.CleanKill(c, w)
worker.Stop(w)
workertest.CheckKilled(c, w)
}
示例3: TestSUCCESSMinionWaitTimeout
func (s *Suite) TestSUCCESSMinionWaitTimeout(c *gc.C) {
// The SUCCESS phase is special in that even if some minions fail
// to report the migration should continue. There's no turning
// back from SUCCESS.
s.facade.queueStatus(s.makeStatus(coremigration.SUCCESS))
worker, err := migrationmaster.New(s.config)
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, worker)
select {
case <-s.clock.Alarms():
case <-time.After(coretesting.LongWait):
c.Fatal("timed out waiting for clock.After call")
}
// Move time ahead in order to trigger timeout.
s.clock.Advance(15 * time.Minute)
err = workertest.CheckKilled(c, worker)
c.Assert(err, gc.Equals, migrationmaster.ErrMigrated)
s.stub.CheckCalls(c, joinCalls(
watchStatusLockdownCalls,
[]jujutesting.StubCall{
{"facade.WatchMinionReports", nil},
{"facade.SetPhase", []interface{}{coremigration.LOGTRANSFER}},
{"facade.SetPhase", []interface{}{coremigration.REAP}},
{"facade.Reap", nil},
{"facade.SetPhase", []interface{}{coremigration.DONE}},
},
))
}
示例4: TestClosedWatcherChannel
func (s *Suite) TestClosedWatcherChannel(c *gc.C) {
close(s.client.watcher.changes)
w, err := migrationminion.New(s.config)
c.Assert(err, jc.ErrorIsNil)
err = workertest.CheckKilled(c, w)
c.Check(err, gc.ErrorMatches, "watcher channel closed")
}
示例5: TestStopWaits
func (*WorkerSuite) TestStopWaits(c *gc.C) {
w := workertest.NewForeverWorker(nil)
defer workertest.CheckKilled(c, w)
defer w.ReallyKill()
done := make(chan struct{})
go func() {
defer close(done)
worker.Stop(w)
}()
select {
case <-time.After(coretesting.ShortWait):
case <-done:
c.Fatalf("Stop returned early")
}
w.ReallyKill()
select {
case <-done:
case <-time.After(coretesting.LongWait):
c.Fatalf("Stop never returned")
}
}
示例6: TestWorstError
// TestWorstError starts an engine with two manifolds that always error
// with fatal errors. We test that the most important error is the one
// returned by the engine.
//
// This test uses manifolds whose workers ignore kill requests. We want
// this (dangerous!) behaviour so that we don't race over which fatal
// error is seen by the engine first.
func (s *EngineSuite) TestWorstError(c *gc.C) {
worstErr := errors.New("awful error")
callCount := 0
s.fix.worstError = func(err1, err2 error) error {
callCount++
return worstErr
}
s.fix.isFatal = alwaysFatal
s.fix.dirty = true
s.fix.run(c, func(engine dependency.Engine) {
mh1 := newErrorIgnoringManifoldHarness()
err := engine.Install("task", mh1.Manifold())
c.Assert(err, jc.ErrorIsNil)
mh1.AssertOneStart(c)
mh2 := newErrorIgnoringManifoldHarness()
err = engine.Install("another task", mh2.Manifold())
c.Assert(err, jc.ErrorIsNil)
mh2.AssertOneStart(c)
mh1.InjectError(c, errors.New("ping"))
mh2.InjectError(c, errors.New("pong"))
err = workertest.CheckKilled(c, engine)
c.Check(errors.Cause(err), gc.Equals, worstErr)
c.Check(callCount, gc.Equals, 2)
})
}
示例7: cleanup
// cleanup checks that every expected worker has already been stopped by
// the SUT. (i.e.: don't set up more workers than your fixture needs).
func (wl *workerList) cleanup(c *gc.C) {
for _, w := range wl.workers {
if w != nil {
workertest.CheckKilled(c, w)
}
}
}
示例8: TestProcessDyingModelErrorRetried
func (s *UndertakerSuite) TestProcessDyingModelErrorRetried(c *gc.C) {
s.fix.errors = []error{
nil, // ModelInfo
nil, // SetStatus
nil, // WatchModelResources,
errors.New("meh, will retry"), // ProcessDyingModel,
errors.New("will retry again"), // ProcessDyingModel,
nil, // ProcessDyingModel,
nil, // SetStatus
nil, // Destroy,
nil, // RemoveModel
}
stub := s.fix.run(c, func(w worker.Worker) {
workertest.CheckKilled(c, w)
})
stub.CheckCallNames(c,
"ModelInfo",
"SetStatus",
"WatchModelResources",
"ProcessDyingModel",
"ProcessDyingModel",
"ProcessDyingModel",
"SetStatus",
"Destroy",
"RemoveModel",
)
}
示例9: TestImportFailure
func (s *Suite) TestImportFailure(c *gc.C) {
masterClient := newStubMasterClient(s.stub)
worker, err := migrationmaster.New(migrationmaster.Config{
Facade: masterClient,
Guard: newStubGuard(s.stub),
})
c.Assert(err, jc.ErrorIsNil)
s.connection.importErr = errors.New("boom")
s.triggerMigration(masterClient)
err = workertest.CheckKilled(c, worker)
c.Assert(err, gc.Equals, migrationmaster.ErrDoneForNow)
s.stub.CheckCalls(c, []jujutesting.StubCall{
{"masterClient.Watch", nil},
{"masterClient.GetMigrationStatus", nil},
{"guard.Lockdown", nil},
{"masterClient.SetPhase", []interface{}{migration.READONLY}},
{"masterClient.SetPhase", []interface{}{migration.PRECHECK}},
{"masterClient.SetPhase", []interface{}{migration.IMPORT}},
{"masterClient.Export", nil},
apiOpenCall,
importCall,
connCloseCall,
{"masterClient.SetPhase", []interface{}{migration.ABORT}},
apiOpenCall,
abortCall,
connCloseCall,
{"masterClient.SetPhase", []interface{}{migration.ABORTDONE}},
})
}
示例10: TestAlreadyDeadRemoves
func (s *UndertakerSuite) TestAlreadyDeadRemoves(c *gc.C) {
s.fix.info.Result.Life = "dead"
stub := s.fix.run(c, func(w worker.Worker) {
workertest.CheckKilled(c, w)
})
stub.CheckCallNames(c, "ModelInfo", "SetStatus", "Destroy", "RemoveModel")
}
示例11: TestWatchFailure
func (s *Suite) TestWatchFailure(c *gc.C) {
s.client.watchErr = errors.New("boom")
w, err := migrationminion.New(s.config)
c.Assert(err, jc.ErrorIsNil)
err = workertest.CheckKilled(c, w)
c.Check(err, gc.ErrorMatches, "setting up watcher: boom")
}
示例12: TestIsFatal
func (s *EngineSuite) TestIsFatal(c *gc.C) {
fatalErr := errors.New("KABOOM")
s.fix.isFatal = isFatalIf(fatalErr)
s.fix.dirty = true
s.fix.run(c, func(engine dependency.Engine) {
// Start two independent workers.
mh1 := newManifoldHarness()
err := engine.Install("some-task", mh1.Manifold())
c.Assert(err, jc.ErrorIsNil)
mh1.AssertOneStart(c)
mh2 := newManifoldHarness()
err = engine.Install("other-task", mh2.Manifold())
c.Assert(err, jc.ErrorIsNil)
mh2.AssertOneStart(c)
// Bounce one worker with Just Some Error; check that worker bounces.
mh1.InjectError(c, errors.New("splort"))
mh1.AssertOneStart(c)
mh2.AssertNoStart(c)
// Bounce another worker with the fatal error; check the engine exits with
// the right error.
mh2.InjectError(c, fatalErr)
mh1.AssertNoStart(c)
mh2.AssertNoStart(c)
err = workertest.CheckKilled(c, engine)
c.Assert(err, gc.Equals, fatalErr)
})
}
示例13: TestWatchErrorNonEmptyRunningActions
func (*WorkerSuite) TestWatchErrorNonEmptyRunningActions(c *gc.C) {
stub := &testing.Stub{}
stub.SetErrors(nil, errors.New("ignored"), errors.New("kuso"))
facade := &mockFacade{
stub: stub,
runningActions: fakeRunningActions,
}
config := machineactions.WorkerConfig{
Facade: facade,
MachineTag: fakeTag,
HandleAction: mockHandleAction(stub),
}
worker, err := machineactions.NewMachineActionsWorker(config)
c.Assert(err, jc.ErrorIsNil)
err = workertest.CheckKilled(c, worker)
c.Check(err, gc.ErrorMatches, "kuso")
stub.CheckCalls(c, []testing.StubCall{{
FuncName: "RunningActions",
Args: []interface{}{fakeTag},
}, {
FuncName: "ActionFinish",
Args: []interface{}{thirdActionTag, params.ActionFailed, "action cancelled"},
}, {
FuncName: "WatchActionNotifications",
Args: []interface{}{fakeTag},
}})
}
示例14: TestReportKeysError
func (s *Suite) TestReportKeysError(c *gc.C) {
s.facade.reportErr = errors.New("blam")
w, err := hostkeyreporter.New(s.config)
c.Assert(err, jc.ErrorIsNil)
err = workertest.CheckKilled(c, w)
c.Check(err, gc.ErrorMatches, "blam")
}
示例15: TestImmediateFailure
func (*ResumerSuite) TestImmediateFailure(c *gc.C) {
fix := newFixture(errors.New("zap"))
stub := fix.Run(c, func(_ *testing.Clock, worker *resumer.Resumer) {
err := workertest.CheckKilled(c, worker)
c.Check(err, gc.ErrorMatches, "cannot resume transactions: zap")
})
stub.CheckCallNames(c, "ResumeTransactions")
}