本文整理汇总了Golang中github.com/juju/juju/worker/workertest.DirtyKill函数的典型用法代码示例。如果您正苦于以下问题:Golang DirtyKill函数的具体用法?Golang DirtyKill怎么用?Golang DirtyKill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DirtyKill函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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}},
},
))
}
示例2: TestDirtyKillTimeout
func (s *Suite) TestDirtyKillTimeout(c *gc.C) {
w := workertest.NewForeverWorker(nil)
defer w.ReallyKill()
workertest.DirtyKill(c, w)
s.CheckFailed(c)
}
示例3: cleanup
func (fix fixture) cleanup(c *gc.C, w worker.Worker) {
if fix.dirty {
workertest.DirtyKill(c, w)
} else {
workertest.CleanKill(c, w)
}
}
示例4: newTrackerDirtyKill
func (s *TrackerSuite) newTrackerDirtyKill() *leadership.Tracker {
tracker := s.newTrackerInner()
s.AddCleanup(func(c *gc.C) {
workertest.DirtyKill(c, tracker)
})
return tracker
}
示例5: kill
func (fix *engineFixture) kill(c *gc.C, engine *dependency.Engine) {
if fix.dirty {
workertest.DirtyKill(c, engine)
} else {
workertest.CleanKill(c, engine)
}
}
示例6: newServerDirtyKill
func (s *apiserverBaseSuite) newServerDirtyKill(c *gc.C, config apiserver.ServerConfig) *apiserver.Server {
srv := s.newServerNoCleanup(c, config)
s.AddCleanup(func(c *gc.C) {
workertest.DirtyKill(c, srv)
})
return srv
}
示例7: TestCheckKillSuccess
func (s *Suite) TestCheckKillSuccess(c *gc.C) {
expect := errors.New("fledbon")
w := workertest.NewErrorWorker(expect)
defer workertest.DirtyKill(c, w)
err := workertest.CheckKill(c, w)
c.Check(err, gc.Equals, expect)
}
示例8: TestCheckKilledSuccess
func (s *Suite) TestCheckKilledSuccess(c *gc.C) {
expect := errors.New("snifplog")
w := workertest.NewErrorWorker(expect)
defer workertest.DirtyKill(c, w)
w.Kill()
err := workertest.CheckKilled(c, w)
c.Check(err, gc.Equals, expect)
}
示例9: Run
func (fix *fixture) Run(c *gc.C, test func(*runContext)) {
watcher := newNotifyWatcher(fix.watcherErr)
defer workertest.DirtyKill(c, watcher)
context := &runContext{
config: newModelConfig(c, fix.initialConfig),
watcher: watcher,
}
context.stub.SetErrors(fix.observerErrs...)
test(context)
}
示例10: TestFlagUnlockError
func (*FlagSuite) TestFlagUnlockError(c *gc.C) {
lock := gate.NewLock()
worker, err := gate.NewFlag(lock)
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, worker)
workertest.CheckAlive(c, worker)
lock.Unlock()
err = workertest.CheckKilled(c, worker)
c.Check(err, gc.Equals, gate.ErrUnlocked)
}
示例11: RunDumb
// RunDumb starts a DumbWorkers inside a fresh Context and supplies it
// to a test func.
func (fix Fixture) RunDumb(c *gc.C, test func(Context, *workers.DumbWorkers)) {
fix.Run(c, func(ctx Context) {
dw, err := workers.NewDumbWorkers(workers.DumbConfig{
Factory: ctx.Factory(),
Logger: loggo.GetLogger("test"),
})
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, dw)
test(ctx, dw)
})
}
示例12: FailDumb
// FailDumb verifies that a DumbWorkers cannot start successfully, and
// checks that the returned error matches.
func (fix Fixture) FailDumb(c *gc.C, match string) {
fix.Run(c, func(ctx Context) {
dw, err := workers.NewDumbWorkers(workers.DumbConfig{
Factory: ctx.Factory(),
Logger: loggo.GetLogger("test"),
})
if !c.Check(dw, gc.IsNil) {
workertest.DirtyKill(c, dw)
}
c.Check(err, gc.ErrorMatches, match)
})
}
示例13: RunRestart
// RunRestart starts a RestartWorkers inside a fresh Context and
// supplies it to a test func.
func (fix Fixture) RunRestart(c *gc.C, test func(Context, *workers.RestartWorkers)) {
fix.Run(c, func(ctx Context) {
rw, err := workers.NewRestartWorkers(workers.RestartConfig{
Factory: ctx.Factory(),
Logger: loggo.GetLogger("test"),
Clock: ctx.Clock(),
Delay: fiveSeconds,
})
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, rw)
test(ctx, rw)
})
}
示例14: TestOne
func (s *LogForwarderSuite) TestOne(c *gc.C) {
s.stream.addRecords(c, s.rec)
lf, err := logforwarder.NewLogForwarder(s.newLogForwarderArgs(c, s.stream, s.sender))
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, lf)
s.sender.waitForSend(c)
workertest.CleanKill(c, lf)
s.sender.stub.CheckCalls(c, []testing.StubCall{
{"Send", []interface{}{[]logfwd.Record{s.rec}}},
{"Close", nil},
})
}
示例15: FailRestart
// FailRestart verifies that a RestartWorkers cannot start successfully, and
// checks that the returned error matches.
func (fix Fixture) FailRestart(c *gc.C, match string) {
fix.Run(c, func(ctx Context) {
rw, err := workers.NewRestartWorkers(workers.RestartConfig{
Factory: ctx.Factory(),
Logger: loggo.GetLogger("test"),
Clock: ctx.Clock(),
Delay: fiveSeconds,
})
if !c.Check(rw, gc.IsNil) {
workertest.DirtyKill(c, rw)
}
c.Check(err, gc.ErrorMatches, match)
})
}