本文整理汇总了Golang中gopkg/in/check/v1.C.Fatal方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Fatal方法的具体用法?Golang C.Fatal怎么用?Golang C.Fatal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.Fatal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestWorkerWontCallPruneBeforeFiringTimer
func (s *statusHistoryPrunerSuite) TestWorkerWontCallPruneBeforeFiringTimer(c *gc.C) {
fakeTimer := newMockTimer(coretesting.LongWait)
fakeTimerFunc := func(d time.Duration) worker.PeriodicTimer {
// construction of timer should be with 0 because we intend it to
// run once before waiting.
c.Assert(d, gc.Equals, 0*time.Nanosecond)
return fakeTimer
}
facade := newFakeFacade()
conf := statushistorypruner.Config{
Facade: facade,
MaxHistoryTime: 1 * time.Second,
MaxHistoryMB: 3,
PruneInterval: coretesting.ShortWait,
NewTimer: fakeTimerFunc,
}
pruner, err := statushistorypruner.New(conf)
c.Check(err, jc.ErrorIsNil)
s.AddCleanup(func(*gc.C) {
c.Assert(worker.Stop(pruner), jc.ErrorIsNil)
})
select {
case <-facade.passedMaxHistoryMB:
c.Fatal("called before firing timer.")
case <-time.After(coretesting.LongWait):
}
}
示例2: 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}},
},
))
}
示例3: assertNoSignal
func assertNoSignal(c *gc.C, signal <-chan struct{}) {
select {
case <-signal:
c.Fatal("unexpected signal")
case <-time.After(coretesting.ShortWait):
}
}
示例4: assertSignal
func assertSignal(c *gc.C, signal <-chan struct{}) {
select {
case <-signal:
case <-time.After(coretesting.LongWait):
c.Fatal("timed out waiting for signal")
}
}
示例5: TestChangeConfig
func (s *UnitSuite) TestChangeConfig(c *gc.C) {
config := FakeAgentConfig{}
configChanged := voyeur.NewValue(true)
a := UnitAgent{
AgentConf: config,
configChangedVal: configChanged,
}
var mutateCalled bool
mutate := func(config agent.ConfigSetter) error {
mutateCalled = true
return nil
}
configChangedCh := make(chan bool)
watcher := configChanged.Watch()
watcher.Next() // consume initial event
go func() {
configChangedCh <- watcher.Next()
}()
err := a.ChangeConfig(mutate)
c.Assert(err, jc.ErrorIsNil)
c.Check(mutateCalled, jc.IsTrue)
select {
case result := <-configChangedCh:
c.Check(result, jc.IsTrue)
case <-time.After(coretesting.LongWait):
c.Fatal("timed out waiting for config changed signal")
}
}
示例6: TestStartWithStateOpenPortsBroken
func (s *InstanceModeSuite) TestStartWithStateOpenPortsBroken(c *gc.C) {
svc := s.AddTestingService(c, "wordpress", s.charm)
err := svc.SetExposed()
c.Assert(err, jc.ErrorIsNil)
u, m := s.addUnit(c, svc)
inst := s.startInstance(c, m)
err = u.OpenPort("tcp", 80)
c.Assert(err, jc.ErrorIsNil)
// Nothing open without firewaller.
s.assertPorts(c, inst, m.Id(), nil)
dummy.SetInstanceBroken(inst, "OpenPorts")
// Starting the firewaller should attempt to open the ports,
// and fail due to the method being broken.
fw, err := firewaller.NewFirewaller(s.firewaller)
c.Assert(err, jc.ErrorIsNil)
errc := make(chan error, 1)
go func() { errc <- fw.Wait() }()
s.BackingState.StartSync()
select {
case err := <-errc:
c.Assert(err, gc.ErrorMatches,
`cannot respond to units changes for "machine-1": dummyInstance.OpenPorts is broken`)
case <-time.After(coretesting.LongWait):
fw.Kill()
fw.Wait()
c.Fatal("timed out waiting for firewaller to stop")
}
}
示例7: waitForClock
func waitForClock(c *gc.C, clock *testing.Clock) {
select {
case <-clock.Alarms():
case <-time.After(coretesting.LongWait):
c.Fatal("timed out waiting for clock")
}
}
示例8: assertNoHooks
func assertNoHooks(c *gc.C, hooks <-chan hook.Info) {
select {
case <-hooks:
c.Fatal("unexpected hook")
case <-time.After(testing.ShortWait):
}
}
示例9: waitForWorkers
// waitForWorkers waits for a given worker to be started, returning all
// workers started while waiting.
func (r *fakeSingularRunner) waitForWorkers(c *gc.C, targets []string) []string {
var seen []string
seenTargets := make(map[string]bool)
numSeenTargets := 0
timeout := time.After(coretesting.LongWait)
for {
select {
case workerName := <-r.startC:
c.Logf("worker %q started; workers seen so far: %+v (len: %d, len(targets): %d)", workerName, seen, len(seen), len(targets))
if seenTargets[workerName] == true {
c.Fatal("worker started twice: " + workerName)
}
seenTargets[workerName] = true
numSeenTargets++
seen = append(seen, workerName)
if numSeenTargets == len(targets) {
c.Logf("all expected target workers started: %+v", seen)
return seen
}
c.Logf("still waiting for workers %+v to start; numSeenTargets=%d", targets, numSeenTargets)
case <-timeout:
c.Fatalf("timed out waiting for %v", targets)
}
}
}
示例10: TestConcurrentLockers
func (s *ManifoldSuite) TestConcurrentLockers(c *gc.C) {
worker, err := s.manifold.Start(s.getResource)
c.Assert(err, jc.ErrorIsNil)
c.Check(worker, gc.NotNil)
defer kill(worker)
var locker charmdir.Locker
err = s.manifold.Output(worker, &locker)
c.Check(err, jc.ErrorIsNil)
nlockers := 10
ch := make(chan struct{}, nlockers)
for i := 0; i < nlockers; i++ {
go func() {
locker.SetAvailable(true)
locker.SetAvailable(false)
ch <- struct{}{}
}()
}
for i := 0; i < nlockers; i++ {
select {
case <-ch:
case <-time.After(coretesting.LongWait):
c.Fatal("timed out waiting to confirm locker worker exit")
}
}
}
示例11: TestPrunesOldLogs
func (s *suite) TestPrunesOldLogs(c *gc.C) {
maxLogAge := 24 * time.Hour
noPruneMB := int(1e9)
s.StartWorker(c, maxLogAge, noPruneMB)
now := time.Now()
addLogsToPrune := func(count int) {
// Add messages beyond the prune threshold.
tPrune := now.Add(-maxLogAge - 1)
s.addLogs(c, tPrune, "prune", count)
}
addLogsToKeep := func(count int) {
// Add messages within the prune threshold.
s.addLogs(c, now, "keep", count)
}
for i := 0; i < 10; i++ {
addLogsToKeep(5)
addLogsToPrune(5)
}
// Wait for all logs with the message "prune" to be removed.
for attempt := testing.LongAttempt.Start(); attempt.Next(); {
pruneRemaining, err := s.logsColl.Find(bson.M{"x": "prune"}).Count()
c.Assert(err, jc.ErrorIsNil)
if pruneRemaining == 0 {
// All the "keep" messages should still be there.
keepCount, err := s.logsColl.Find(bson.M{"x": "keep"}).Count()
c.Assert(err, jc.ErrorIsNil)
c.Assert(keepCount, gc.Equals, 50)
return
}
}
c.Fatal("pruning didn't happen as expected")
}
示例12: TestBootstrapBuildAgent
func (s *bootstrapSuite) TestBootstrapBuildAgent(c *gc.C) {
if runtime.GOOS == "windows" {
c.Skip("issue 1403084: Currently does not work because of jujud problems")
}
// Patch out HostArch and FindTools to allow the test to pass on other architectures,
// such as s390.
s.PatchValue(&arch.HostArch, func() string { return arch.ARM64 })
s.PatchValue(bootstrap.FindTools, func(environs.Environ, int, int, string, tools.Filter) (tools.List, error) {
c.Fatal("should not call FindTools if BuildAgent is specified")
return nil, errors.NotFoundf("tools")
})
env := newEnviron("foo", useDefaultKeys, nil)
err := bootstrap.Bootstrap(envtesting.BootstrapContext(c), env, bootstrap.BootstrapParams{
BuildAgent: true,
AdminSecret: "admin-secret",
CAPrivateKey: coretesting.CAKey,
ControllerConfig: coretesting.FakeControllerConfig(),
BuildAgentTarball: func(build bool, ver *version.Number, _ string) (*sync.BuiltAgent, error) {
c.Logf("BuildAgentTarball version %s", ver)
c.Assert(build, jc.IsTrue)
return &sync.BuiltAgent{Dir: c.MkDir()}, nil
},
})
c.Assert(err, jc.ErrorIsNil)
// Check that the model config has the correct version set.
cfg := env.instanceConfig.Bootstrap.ControllerModelConfig
agentVersion, valid := cfg.AgentVersion()
c.Check(valid, jc.IsTrue)
c.Check(agentVersion.String(), gc.Equals, "1.99.0.1")
}
示例13: syncClockAlarm
func (s *KillSuite) syncClockAlarm(c *gc.C) {
select {
case <-s.clock.Alarms():
case <-time.After(coretesting.LongWait):
c.Fatal("timed out waiting for test clock After call")
}
}
示例14: TestWatchAllModels
func (s *controllerSuite) TestWatchAllModels(c *gc.C) {
watcherId, err := s.controller.WatchAllModels()
c.Assert(err, jc.ErrorIsNil)
watcherAPI_, err := apiserver.NewAllWatcher(facadetest.Context{
State_: s.State,
Resources_: s.resources,
Auth_: s.authorizer,
ID_: watcherId.AllWatcherId,
})
c.Assert(err, jc.ErrorIsNil)
watcherAPI := watcherAPI_.(*apiserver.SrvAllWatcher)
defer func() {
err := watcherAPI.Stop()
c.Assert(err, jc.ErrorIsNil)
}()
resultC := make(chan params.AllWatcherNextResults)
go func() {
result, err := watcherAPI.Next()
c.Assert(err, jc.ErrorIsNil)
resultC <- result
}()
select {
case result := <-resultC:
// Expect to see the initial environment be reported.
deltas := result.Deltas
c.Assert(deltas, gc.HasLen, 1)
envInfo := deltas[0].Entity.(*multiwatcher.ModelInfo)
c.Assert(envInfo.ModelUUID, gc.Equals, s.State.ModelUUID())
case <-time.After(testing.LongWait):
c.Fatal("timed out")
}
}
示例15: sendRecord
func (s *syslogSuite) sendRecord(c *gc.C, rec *logsender.LogRecord) {
select {
case s.logsCh <- rec:
case <-time.After(coretesting.LongWait):
c.Fatal(`timed out "sending" message`)
}
}