本文整理汇总了Golang中github.com/juju/juju/worker/workertest.DirtyKill函数的典型用法代码示例。如果您正苦于以下问题:Golang DirtyKill函数的具体用法?Golang DirtyKill怎么用?Golang DirtyKill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DirtyKill函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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}},
},
))
}
开发者ID:bac,项目名称:juju,代码行数:33,代码来源:worker_test.go
示例2: TestDirtyKillTimeout
func (s *Suite) TestDirtyKillTimeout(c *gc.C) {
w := workertest.NewForeverWorker(nil)
defer w.ReallyKill()
workertest.DirtyKill(c, w)
s.CheckFailed(c)
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:workertest_test.go
示例3: cleanup
func (fix fixture) cleanup(c *gc.C, w worker.Worker) {
if fix.dirty {
workertest.DirtyKill(c, w)
} else {
workertest.CleanKill(c, w)
}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:mock_test.go
示例4: newTrackerDirtyKill
func (s *TrackerSuite) newTrackerDirtyKill() *leadership.Tracker {
tracker := s.newTrackerInner()
s.AddCleanup(func(c *gc.C) {
workertest.DirtyKill(c, tracker)
})
return tracker
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:tracker_test.go
示例5: kill
func (fix *engineFixture) kill(c *gc.C, engine *dependency.Engine) {
if fix.dirty {
workertest.DirtyKill(c, engine)
} else {
workertest.CleanKill(c, engine)
}
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:util_test.go
示例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
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:apiserver_test.go
示例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)
}
开发者ID:exekias,项目名称:juju,代码行数:8,代码来源:workertest_test.go
示例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)
}
开发者ID:exekias,项目名称:juju,代码行数:9,代码来源:workertest_test.go
示例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)
}
开发者ID:exekias,项目名称:juju,代码行数:10,代码来源:fixture_test.go
示例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)
}
开发者ID:makyo,项目名称:juju,代码行数:10,代码来源:flag_test.go
示例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)
})
}
开发者ID:kat-co,项目名称:juju,代码行数:13,代码来源:fixture_test.go
示例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)
})
}
开发者ID:kat-co,项目名称:juju,代码行数:14,代码来源:fixture_test.go
示例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)
})
}
开发者ID:kat-co,项目名称:juju,代码行数:15,代码来源:fixture_test.go
示例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},
})
}
开发者ID:bac,项目名称:juju,代码行数:13,代码来源:logforwarder_test.go
示例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)
})
}
开发者ID:kat-co,项目名称:juju,代码行数:16,代码来源:fixture_test.go
示例16: checkInvalidRestartConfig
func checkInvalidRestartConfig(c *gc.C, config workers.RestartConfig, match string) {
check := func(err error) {
c.Check(err, jc.Satisfies, errors.IsNotValid)
c.Check(err, gc.ErrorMatches, match)
}
err := config.Validate()
check(err)
rw, err := workers.NewRestartWorkers(config)
if !c.Check(rw, gc.IsNil) {
workertest.DirtyKill(c, rw)
}
check(err)
}
开发者ID:kat-co,项目名称:juju,代码行数:15,代码来源:restart_test.go
示例17: TestWatchCloses
func (s *TrackerSuite) TestWatchCloses(c *gc.C) {
fix := &fixture{}
fix.Run(c, func(context *runContext) {
tracker, err := environ.NewTracker(environ.Config{
Observer: context,
})
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, tracker)
context.CloseNotify()
err = workertest.CheckKilled(c, tracker)
c.Check(err, gc.ErrorMatches, "environ config watch closed")
context.CheckCallNames(c, "EnvironConfig", "WatchForEnvironConfigChanges")
})
}
开发者ID:felicianotech,项目名称:juju,代码行数:15,代码来源:environ_test.go
示例18: TestOccupySuccess
func (*HousingSuite) TestOccupySuccess(c *gc.C) {
expectWorker := workertest.NewErrorWorker(errors.New("ignored"))
defer workertest.DirtyKill(c, expectWorker)
manifold := util.Housing{
Occupy: "fortress",
}.Decorate(dependency.Manifold{
Start: func(dependency.Context) (worker.Worker, error) {
return expectWorker, nil
},
})
guest := newGuest(true)
context := dt.StubContext(nil, map[string]interface{}{
"fortress": guest,
})
// wait for the start func to complete
started := make(chan struct{})
go func() {
defer close(started)
worker, err := manifold.Start(context)
c.Check(worker, gc.Equals, expectWorker)
c.Check(err, jc.ErrorIsNil)
}()
select {
case <-started:
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out")
}
// check the worker's alive
workertest.CheckAlive(c, expectWorker)
// check the visit keeps running...
select {
case <-time.After(coretesting.ShortWait):
case <-guest.done:
c.Fatalf("visit finished early")
}
// ...until the worker stops
expectWorker.Kill()
select {
case <-guest.done:
case <-time.After(coretesting.LongWait):
c.Fatalf("timed out")
}
}
开发者ID:makyo,项目名称:juju,代码行数:47,代码来源:housing_test.go
示例19: TestStreamError
func (s *LogForwarderSuite) TestStreamError(c *gc.C) {
failure := errors.New("<failure>")
s.stream.stub.SetErrors(nil, failure)
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)
err = workertest.CheckKilled(c, lf)
c.Check(errors.Cause(err), gc.Equals, failure)
s.sender.stub.CheckCalls(c, []testing.StubCall{
{"Send", []interface{}{[]logfwd.Record{s.rec}}},
{"Close", nil},
})
}
开发者ID:bac,项目名称:juju,代码行数:17,代码来源:logforwarder_test.go
示例20: Run
func (fix fixture) Run(c *gc.C, test TestFunc) *testing.Stub {
stub := &testing.Stub{}
stub.SetErrors(fix.errors...)
clock := testing.NewClock(time.Now())
facade := newMockFacade(stub)
worker, err := resumer.NewResumer(resumer.Config{
Facade: facade,
Interval: time.Hour,
Clock: clock,
})
c.Assert(err, jc.ErrorIsNil)
defer workertest.DirtyKill(c, worker)
test(clock, worker)
return stub
}
开发者ID:bac,项目名称:juju,代码行数:18,代码来源:resumer_test.go
注:本文中的github.com/juju/juju/worker/workertest.DirtyKill函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论