本文整理汇总了Golang中launchpad/net/gocheck.C.Fatalf方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Fatalf方法的具体用法?Golang C.Fatalf怎么用?Golang C.Fatalf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/gocheck.C
的用法示例。
在下文中一共展示了C.Fatalf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: assertNotReplied
func assertNotReplied(c *gc.C, req *request) {
select {
case v := <-req.reply:
c.Fatalf("request was unexpectedly replied to (got %v)", v)
default:
}
}
示例2: TestContainerCommitRemovesOldImages
func (s *S) TestContainerCommitRemovesOldImages(c *gocheck.C) {
appName := "commit-remove-test-app"
cont, err := s.newContainer(&newContainerOpts{AppName: appName})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(cont)
imageId, err := cont.commit()
c.Assert(err, gocheck.IsNil)
repoNamespace, _ := config.GetString("docker:repository-namespace")
repository := repoNamespace + "/" + cont.AppName
c.Assert(imageId, gocheck.Equals, repository)
images, err := dockerCluster().ListImages(true)
c.Assert(err, gocheck.IsNil)
var toEraseID string
for _, image := range images {
if len(image.RepoTags) > 0 && image.RepoTags[0] == "tsuru/"+appName {
toEraseID = image.ID
break
}
}
c.Assert(toEraseID, gocheck.Not(gocheck.Equals), "")
cont, err = s.newContainer(&newContainerOpts{AppName: appName})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(cont)
_, err = cont.commit()
c.Assert(err, gocheck.IsNil)
images, err = dockerCluster().ListImages(true)
c.Assert(err, gocheck.IsNil)
for _, image := range images {
if image.ID == toEraseID {
c.Fatalf("Image id %q shouldn't be in images list.", toEraseID)
}
}
}
示例3: TestAgentEnsuresAPIInfoOnWorkers
// Test that MachineAgent enforces the API password on startup even for machine>0
func (s *UpgradeValidationMachineSuite) TestAgentEnsuresAPIInfoOnWorkers(c *gc.C) {
// create a machine-0, then create a new machine-1
_, _ = s.Create1_10Machine(c)
m1, _ := s.Create1_10Machine(c)
a := &MachineAgent{}
s.initAgent(c, a, "--machine-id", m1.Id())
agentStates := make(chan *state.State, 1000)
undo := sendOpenedStates(agentStates)
defer undo()
done := make(chan error)
go func() {
done <- a.Run(nil)
}()
select {
case agentState := <-agentStates:
c.Assert(agentState, gc.NotNil)
c.Assert(a.Conf.Conf.APIInfo.Password, gc.Equals, "machine-password")
case <-time.After(testing.LongWait):
c.Fatalf("state not opened")
}
err := a.Stop()
c.Assert(err, gc.IsNil)
c.Assert(<-done, gc.IsNil)
}
示例4: TestMachineAgentRunsAPIAddressUpdaterWorker
func (s *MachineSuite) TestMachineAgentRunsAPIAddressUpdaterWorker(c *gc.C) {
// Start the machine agent.
m, _, _ := s.primeAgent(c, version.Current, state.JobHostUnits)
a := s.newAgent(c, m)
go func() { c.Check(a.Run(nil), gc.IsNil) }()
defer func() { c.Check(a.Stop(), gc.IsNil) }()
// Update the API addresses.
updatedServers := [][]instance.HostPort{instance.AddressesWithPort(
instance.NewAddresses("localhost"), 1234,
)}
err := s.BackingState.SetAPIHostPorts(updatedServers)
c.Assert(err, gc.IsNil)
// Wait for config to be updated.
s.BackingState.StartSync()
for attempt := coretesting.LongAttempt.Start(); attempt.Next(); {
addrs, err := a.CurrentConfig().APIAddresses()
c.Assert(err, gc.IsNil)
if reflect.DeepEqual(addrs, []string{"localhost:1234"}) {
return
}
}
c.Fatalf("timeout while waiting for agent config to change")
}
示例5: TestShareEnvironmentExistingUser
func (s *clientSuite) TestShareEnvironmentExistingUser(c *gc.C) {
client := s.APIState.Client()
user := s.Factory.MakeEnvUser(c, nil)
cleanup := api.PatchClientFacadeCall(client,
func(request string, paramsIn interface{}, response interface{}) error {
if users, ok := paramsIn.(params.ModifyEnvironUsers); ok {
c.Assert(users.Changes, gc.HasLen, 1)
c.Logf(string(users.Changes[0].Action), gc.Equals, string(params.AddEnvUser))
c.Logf(users.Changes[0].UserTag, gc.Equals, user.UserTag().String())
} else {
c.Fatalf("wrong input structure")
}
if result, ok := response.(*params.ErrorResults); ok {
err := ¶ms.Error{Message: "failed to create environment user: env user already exists"}
*result = params.ErrorResults{Results: []params.ErrorResult{{Error: err}}}
} else {
c.Fatalf("wrong input structure")
}
return nil
},
)
defer cleanup()
result, err := client.ShareEnvironment([]names.UserTag{user.UserTag()})
c.Assert(err, gc.IsNil)
c.Assert(result.OneError().Error(), gc.Matches, "failed to create environment user: env user already exists")
c.Assert(result.Results, gc.HasLen, 1)
c.Assert(result.Results[0].Error, gc.ErrorMatches, `failed to create environment user: env user already exists`)
}
示例6: waitProvisioned
func (s *MachineSuite) waitProvisioned(c *gc.C, unit *state.Unit) (*state.Machine, instance.Id) {
c.Logf("waiting for unit %q to be provisioned", unit)
machineId, err := unit.AssignedMachineId()
c.Assert(err, gc.IsNil)
m, err := s.State.Machine(machineId)
c.Assert(err, gc.IsNil)
w := m.Watch()
defer w.Stop()
timeout := time.After(coretesting.LongWait)
for {
select {
case <-timeout:
c.Fatalf("timed out waiting for provisioning")
case _, ok := <-w.Changes():
c.Assert(ok, jc.IsTrue)
err := m.Refresh()
c.Assert(err, gc.IsNil)
if instId, err := m.InstanceId(); err == nil {
c.Logf("unit provisioned with instance %s", instId)
return m, instId
} else {
c.Check(err, jc.Satisfies, state.IsNotProvisionedError)
}
}
}
panic("watcher died")
}
示例7: TestMachineAgentRunsAuthorisedKeysWorker
func (s *MachineSuite) TestMachineAgentRunsAuthorisedKeysWorker(c *gc.C) {
// Start the machine agent.
m, _, _ := s.primeAgent(c, version.Current, state.JobHostUnits)
a := s.newAgent(c, m)
go func() { c.Check(a.Run(nil), gc.IsNil) }()
defer func() { c.Check(a.Stop(), gc.IsNil) }()
// Update the keys in the environment.
sshKey := sshtesting.ValidKeyOne.Key + " [email protected]"
err := s.BackingState.UpdateEnvironConfig(map[string]interface{}{"authorized-keys": sshKey}, nil, nil)
c.Assert(err, gc.IsNil)
// Wait for ssh keys file to be updated.
s.State.StartSync()
timeout := time.After(coretesting.LongWait)
sshKeyWithCommentPrefix := sshtesting.ValidKeyOne.Key + " Juju:[email protected]"
for {
select {
case <-timeout:
c.Fatalf("timeout while waiting for authorised ssh keys to change")
case <-time.After(coretesting.ShortWait):
keys, err := ssh.ListKeys(authenticationworker.SSHUser, ssh.FullKeys)
c.Assert(err, gc.IsNil)
keysStr := strings.Join(keys, "\n")
if sshKeyWithCommentPrefix != keysStr {
continue
}
return
}
}
}
示例8: waitForPostSetup
func (s *MachineEnvironmentWatcherSuite) waitForPostSetup(c *gc.C) {
select {
case <-time.After(testing.LongWait):
c.Fatalf("timeout while waiting for setup")
case <-s.started:
}
}
示例9: waitForUnitStarted
func waitForUnitStarted(stateConn *state.State, unit *state.Unit, c *gc.C) {
timeout := time.After(5 * time.Second)
for {
select {
case <-timeout:
c.Fatalf("no activity detected")
case <-time.After(coretesting.ShortWait):
err := unit.Refresh()
c.Assert(err, gc.IsNil)
st, info, data, err := unit.Status()
c.Assert(err, gc.IsNil)
switch st {
case params.StatusPending, params.StatusInstalled:
c.Logf("waiting...")
continue
case params.StatusStarted:
c.Logf("started!")
return
case params.StatusDown:
stateConn.StartSync()
c.Logf("unit is still down")
default:
c.Fatalf("unexpected status %s %s %v", st, info, data)
}
}
}
}
示例10: TestFindAllBeings
func (s *PresenceSuite) TestFindAllBeings(c *gc.C) {
w := presence.NewWatcher(s.presence)
p := presence.NewPinger(s.presence, "a")
defer w.Stop()
defer p.Stop()
ch := make(chan presence.Change)
w.Watch("a", ch)
assertChange(c, ch, presence.Change{"a", false})
c.Assert(p.Start(), gc.IsNil)
done := make(chan bool)
go func() {
w.Sync()
done <- true
}()
assertChange(c, ch, presence.Change{"a", true})
results, err := presence.FindAllBeings(w)
c.Assert(err, gc.IsNil)
c.Assert(results, gc.HasLen, 1)
select {
case <-done:
case <-time.After(testing.LongWait):
c.Fatalf("Sync failed to returned")
}
}
示例11: assertNoChange
func assertNoChange(c *gc.C, watch <-chan presence.Change) {
select {
case got := <-watch:
c.Fatalf("watch reported %v, want nothing", got)
case <-time.After(testing.ShortWait):
}
}
示例12: TestStartSync
func (s *PresenceSuite) TestStartSync(c *gc.C) {
w := presence.NewWatcher(s.presence)
p := presence.NewPinger(s.presence, "a")
defer w.Stop()
defer p.Stop()
ch := make(chan presence.Change)
w.Watch("a", ch)
assertChange(c, ch, presence.Change{"a", false})
c.Assert(p.Start(), gc.IsNil)
done := make(chan bool)
go func() {
w.StartSync()
w.StartSync()
w.StartSync()
done <- true
}()
select {
case <-done:
case <-time.After(testing.LongWait):
c.Fatalf("StartSync failed to return")
}
assertChange(c, ch, presence.Change{"a", true})
}
示例13: TestHash
// Tests
func (s *S) TestHash(c *check.C) {
var (
err error
f *os.File
md5hash []byte
)
// FIXME: This will not work with MacOS.
if _, err = exec.LookPath("md5sum"); err != nil {
c.Skip(err.Error())
}
md5sum := exec.Command("md5sum", "./files_test.go")
b := &bytes.Buffer{}
md5sum.Stdout = b
if err = md5sum.Run(); err != nil {
c.Fatal(err)
}
if f, err = os.Open("./files_test.go"); err != nil {
c.Fatalf("%v %s", md5sum, err)
}
if md5hash, err = Hash(md5.New(), f); err != nil {
c.Fatal(err)
}
md5string := fmt.Sprintf("%x .*\n", md5hash)
c.Check(string(b.Bytes()), check.Matches, md5string)
}
示例14: TestExtraResultsAreClosed
func (*trySuite) TestExtraResultsAreClosed(c *gc.C) {
try := parallel.NewTry(0, nil)
begin := make([]chan struct{}, 4)
results := make([]*closeResult, len(begin))
for i := range begin {
begin[i] = make(chan struct{})
results[i] = &closeResult{make(chan struct{})}
i := i
try.Start(func(<-chan struct{}) (io.Closer, error) {
<-begin[i]
return results[i], nil
})
}
begin[0] <- struct{}{}
val, err := try.Result()
c.Assert(err, gc.IsNil)
c.Assert(val, gc.Equals, results[0])
timeout := time.After(shortWait)
for i, r := range results[1:] {
begin[i+1] <- struct{}{}
select {
case <-r.closed:
case <-timeout:
c.Fatalf("timed out waiting for close")
}
}
select {
case <-results[0].closed:
c.Fatalf("result was inappropriately closed")
case <-time.After(shortWait):
}
}
示例15: TestAcquireWaitBlocksUntilRelease
func (*limiterSuite) TestAcquireWaitBlocksUntilRelease(c *gc.C) {
l := utils.NewLimiter(2)
calls := make([]string, 0, 10)
start := make(chan bool, 0)
waiting := make(chan bool, 0)
done := make(chan bool, 0)
go func() {
<-start
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
waiting <- true
l.AcquireWait()
calls = append(calls, "waited")
calls = append(calls, fmt.Sprintf("%v", l.Acquire()))
done <- true
}()
// Start the routine, and wait for it to get to the first checkpoint
start <- true
select {
case <-waiting:
case <-time.After(longWait):
c.Fatalf("timed out waiting for 'waiting' to trigger")
}
c.Check(l.Acquire(), jc.IsFalse)
l.Release()
select {
case <-done:
case <-time.After(longWait):
c.Fatalf("timed out waiting for 'done' to trigger")
}
c.Check(calls, gc.DeepEquals, []string{"true", "true", "false", "waited", "false"})
}