本文整理汇总了Golang中github.com/flynn/go-check.C类的典型用法代码示例。如果您正苦于以下问题:Golang C类的具体用法?Golang C怎么用?Golang C使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了C类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: waitForJobEvents
func (s *DeployerSuite) waitForJobEvents(t *c.C, jobType string, events chan *ct.Job, expected []*ct.Job) {
debugf(t, "waiting for %d job events", len(expected))
actual := make([]*ct.Job, 0, len(expected))
loop:
for {
select {
case e, ok := <-events:
if !ok {
t.Fatal("unexpected close of job event stream")
}
// only track up and down events as we can't always
// predict the order of pending / starting / stopping
// events when scaling multiple jobs
if e.State != ct.JobStateUp && e.State != ct.JobStateDown {
continue
}
actual = append(actual, e)
if len(actual) == len(expected) {
break loop
}
case <-time.After(60 * time.Second):
t.Fatal("timed out waiting for job events")
}
}
for i, event := range expected {
t.Assert(actual[i].ReleaseID, c.Equals, event.ReleaseID)
t.Assert(actual[i].State, c.Equals, event.State)
t.Assert(actual[i].Type, c.Equals, jobType)
}
}
开发者ID:imjorge,项目名称:flynn,代码行数:30,代码来源:test_deployer.go
示例2: TestAttachFinishedInteractiveJob
func (s *HostSuite) TestAttachFinishedInteractiveJob(t *c.C) {
cluster := s.clusterClient(t)
// run a quick interactive job
cmd := exec.CommandUsingCluster(cluster, exec.DockerImage(imageURIs["test-apps"]), "/bin/true")
cmd.TTY = true
runErr := make(chan error)
go func() {
runErr <- cmd.Run()
}()
select {
case err := <-runErr:
t.Assert(err, c.IsNil)
case <-time.After(30 * time.Second):
t.Fatal("timed out waiting for interactive job")
}
h, err := cluster.Host(cmd.HostID)
t.Assert(err, c.IsNil)
// Getting the logs for the job should fail, as it has none because it was
// interactive
attachErr := make(chan error)
go func() {
_, err = h.Attach(&host.AttachReq{JobID: cmd.Job.ID, Flags: host.AttachFlagLogs}, false)
attachErr <- err
}()
select {
case err := <-attachErr:
t.Assert(err, c.NotNil)
case <-time.After(time.Second):
t.Error("timed out waiting for attach")
}
}
开发者ID:ably-forks,项目名称:flynn,代码行数:34,代码来源:test_host.go
示例3: TestResourceLimits
func (s *HostSuite) TestResourceLimits(t *c.C) {
cmd := exec.JobUsingCluster(
s.clusterClient(t),
exec.DockerImage(imageURIs["test-apps"]),
&host.Job{
Config: host.ContainerConfig{Args: []string{"sh", "-c", resourceCmd}},
Resources: testResources(),
},
)
var out bytes.Buffer
cmd.Stdout = &out
runErr := make(chan error)
go func() {
runErr <- cmd.Run()
}()
select {
case err := <-runErr:
t.Assert(err, c.IsNil)
case <-time.After(30 * time.Second):
t.Fatal("timed out waiting for resource limits job")
}
assertResourceLimits(t, out.String())
}
开发者ID:ably-forks,项目名称:flynn,代码行数:25,代码来源:test_host.go
示例4: TestExampleOutput
func (s *ControllerSuite) TestExampleOutput(t *c.C) {
examples := s.generateControllerExamples(t)
exampleKeys := make([]string, 0, len(examples))
skipExamples := []string{"migrate_cluster_domain"}
examplesLoop:
for key := range examples {
for _, skipKey := range skipExamples {
if key == skipKey {
continue examplesLoop
}
}
exampleKeys = append(exampleKeys, key)
}
sort.Strings(exampleKeys)
for _, key := range exampleKeys {
cacheKey := "https://flynn.io/schema/examples/controller/" + key
schema := s.schemaCache[cacheKey]
if schema == nil {
continue
}
data := examples[key]
errs := schema.Validate(nil, data)
var jsonData []byte
if len(errs) > 0 {
jsonData, _ = json.MarshalIndent(data, "", "\t")
}
t.Assert(errs, c.HasLen, 0, c.Commentf("%s validation errors: %v\ndata: %v\n", cacheKey, errs, string(jsonData)))
}
}
开发者ID:imjorge,项目名称:flynn,代码行数:29,代码来源:test_controller.go
示例5: TestLog
func (s *CLISuite) TestLog(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
t.Assert(app.flynn("run", "-d", "echo", "hello", "world"), Succeeds)
app.waitFor(ct.JobEvents{"": {ct.JobStateUp: 1, ct.JobStateDown: 1}})
t.Assert(app.flynn("log", "--raw-output"), Outputs, "hello world\n")
}
开发者ID:imjorge,项目名称:flynn,代码行数:7,代码来源:test_cli.go
示例6: TestWithoutChecker
func (s *HealthcheckSuite) TestWithoutChecker(t *c.C) {
// start app with a service but no checker
app, _ := s.createAppWithService(t, "ping", &host.Service{
Name: "ping-without-checker",
Create: true,
})
t.Assert(flynn(t, "/", "-a", app.Name, "scale", "ping=1"), Succeeds)
// make sure app is registered and unregistered when the process terminates
_, err := s.discoverdClient(t).Instances("ping-without-checker", 3*time.Second)
t.Assert(err, c.IsNil)
events := make(chan *discoverd.Event)
stream, err := s.discoverdClient(t).Service("ping-without-checker").Watch(events)
defer stream.Close()
t.Assert(err, c.IsNil)
t.Assert(flynn(t, "/", "-a", app.Name, "scale", "ping=0"), Succeeds)
outer:
for {
select {
case e := <-events:
if e.Kind != discoverd.EventKindDown {
continue
}
break outer
case <-time.After(time.Second * 30):
t.Error("Timed out waiting for a down event!")
}
}
}
开发者ID:imjorge,项目名称:flynn,代码行数:31,代码来源:test_healthcheck.go
示例7: TestTCPApp
func (s *SchedulerSuite) TestTCPApp(t *c.C) {
app, _ := s.createApp(t)
t.Assert(flynn(t, "/", "-a", app.Name, "scale", "echoer=1"), Succeeds)
newRoute := flynn(t, "/", "-a", app.Name, "route", "add", "tcp", "-s", "echo-service")
t.Assert(newRoute, Succeeds)
t.Assert(newRoute.Output, Matches, `.+ on port \d+`)
str := strings.Split(strings.TrimSpace(string(newRoute.Output)), " ")
port := str[len(str)-1]
// use Attempts to give the processes time to start
if err := Attempts.Run(func() error {
servAddr := routerIP + ":" + port
conn, err := net.Dial("tcp", servAddr)
if err != nil {
return err
}
defer conn.Close()
msg := []byte("hello there!\n")
_, err = conn.Write(msg)
if err != nil {
return err
}
reply := make([]byte, len(msg))
_, err = conn.Read(reply)
if err != nil {
return err
}
t.Assert(reply, c.DeepEquals, msg)
return nil
}); err != nil {
t.Fatal(err)
}
}
开发者ID:ably-forks,项目名称:flynn,代码行数:35,代码来源:test_scheduler.go
示例8: TestLogStderr
func (s *CLISuite) TestLogStderr(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
t.Assert(app.flynn("run", "-d", "sh", "-c", "echo hello && echo world >&2"), Succeeds)
app.waitFor(ct.JobEvents{"": {ct.JobStateUp: 1, ct.JobStateDown: 1}})
runLog := func(split bool) (stdout, stderr bytes.Buffer) {
args := []string{"log", "--raw-output"}
if split {
args = append(args, "--split-stderr")
}
args = append(args)
log := app.flynnCmd(args...)
log.Stdout = &stdout
log.Stderr = &stderr
t.Assert(log.Run(), c.IsNil, c.Commentf("STDERR = %q", stderr.String()))
return
}
stdout, stderr := runLog(false)
// non-deterministic order
t.Assert(stdout.String(), Matches, "hello")
t.Assert(stdout.String(), Matches, "world")
t.Assert(stderr.String(), c.Equals, "")
stdout, stderr = runLog(true)
t.Assert(stdout.String(), c.Equals, "hello\n")
t.Assert(stderr.String(), c.Equals, "world\n")
}
开发者ID:imjorge,项目名称:flynn,代码行数:26,代码来源:test_cli.go
示例9: TestInterhostVolumeTransmitAPI
func (s *VolumeSuite) TestInterhostVolumeTransmitAPI(t *c.C) {
hosts, err := s.clusterClient(t).Hosts()
t.Assert(err, c.IsNil)
if len(hosts) < 2 {
t.Skip("need multiple hosts for this test")
}
s.doVolumeTransmitAPI(hosts[0], hosts[1], t)
}
开发者ID:ably-forks,项目名称:flynn,代码行数:8,代码来源:test_volume.go
示例10: TestGetNonExistentJob
func (s *HostSuite) TestGetNonExistentJob(t *c.C) {
cluster := s.clusterClient(t)
hosts, err := cluster.Hosts()
t.Assert(err, c.IsNil)
// Getting a non-existent job should error
_, err = hosts[0].GetJob("i-dont-exist")
t.Assert(hh.IsObjectNotFoundError(err), c.Equals, true)
}
开发者ID:ably-forks,项目名称:flynn,代码行数:9,代码来源:test_host.go
示例11: TestAttachNonExistentJob
func (s *HostSuite) TestAttachNonExistentJob(t *c.C) {
cluster := s.clusterClient(t)
hosts, err := cluster.Hosts()
t.Assert(err, c.IsNil)
// Attaching to a non-existent job should error
_, err = hosts[0].Attach(&host.AttachReq{JobID: "none", Flags: host.AttachFlagLogs}, false)
t.Assert(err, c.NotNil)
}
开发者ID:ably-forks,项目名称:flynn,代码行数:9,代码来源:test_host.go
示例12: TestDeployTimeout
func (s *CLISuite) TestDeployTimeout(t *c.C) {
timeout := flynn(t, "/", "-a", "status", "deployment", "timeout")
t.Assert(timeout, Succeeds)
t.Assert(timeout.Output, c.Equals, "120\n")
t.Assert(flynn(t, "/", "-a", "status", "deployment", "timeout", "150"), Succeeds)
timeout = flynn(t, "/", "-a", "status", "deployment", "timeout")
t.Assert(timeout, Succeeds)
t.Assert(timeout.Output, c.Equals, "150\n")
}
开发者ID:imjorge,项目名称:flynn,代码行数:10,代码来源:test_cli.go
示例13: TestBlobstoreBackendAzure
func (s *BlobstoreSuite) TestBlobstoreBackendAzure(t *c.C) {
s3Config := os.Getenv("BLOBSTORE_AZURE_CONFIG")
if s3Config == "" {
// BLOBSTORE_AZURE_CONFIG should be set to a valid configuration like:
// backend=azure account_name=xxx account_key=xxx container=blobstore-ci
t.Skip("missing BLOBSTORE_AZURE_CONFIG env var")
}
s.testBlobstoreBackend(t, "azure", ".+blob.core.windows.net.+", `"BACKEND_AZURE=$BLOBSTORE_AZURE_CONFIG"`)
}
开发者ID:imjorge,项目名称:flynn,代码行数:10,代码来源:test_blobstore.go
示例14: TestBlobstoreBackendS3
func (s *BlobstoreSuite) TestBlobstoreBackendS3(t *c.C) {
s3Config := os.Getenv("BLOBSTORE_S3_CONFIG")
if s3Config == "" {
// BLOBSTORE_S3_CONFIG should be set to a valid configuration like:
// backend=s3 access_key_id=xxx secret_access_key=xxx bucket=blobstore-ci region=us-east-1
t.Skip("missing BLOBSTORE_S3_CONFIG env var")
}
s.testBlobstoreBackend(t, "s3", ".+s3.amazonaws.com.+", `"BACKEND_S3=$BLOBSTORE_S3_CONFIG"`)
}
开发者ID:imjorge,项目名称:flynn,代码行数:10,代码来源:test_blobstore.go
示例15: TestChecker
func (s *HealthcheckSuite) TestChecker(t *c.C) {
// start app with ping service, register with checker
app, _ := s.createAppWithService(t, "ping", &host.Service{
Name: "ping-checker",
Create: true,
Check: &host.HealthCheck{Type: "tcp"},
})
t.Assert(flynn(t, "/", "-a", app.Name, "scale", "ping=1"), Succeeds)
_, err := s.discoverdClient(t).Instances("ping-checker", 10*time.Second)
t.Assert(err, c.IsNil)
}
开发者ID:imjorge,项目名称:flynn,代码行数:11,代码来源:test_healthcheck.go
示例16: controllerClient
func (h *Helper) controllerClient(t *c.C) controller.Client {
h.controllerMtx.Lock()
defer h.controllerMtx.Unlock()
if h.controller == nil {
conf := h.clusterConf(t)
var err error
h.controller, err = conf.Client()
t.Assert(err, c.IsNil)
}
return h.controller
}
开发者ID:imjorge,项目名称:flynn,代码行数:11,代码来源:helper.go
示例17: clusterConf
func (h *Helper) clusterConf(t *c.C) *config.Cluster {
h.configMtx.Lock()
defer h.configMtx.Unlock()
if h.config == nil {
conf, err := config.ReadFile(flynnrc)
t.Assert(err, c.IsNil)
t.Assert(conf.Clusters, c.HasLen, 1)
h.config = conf.Clusters[0]
}
return h.config
}
开发者ID:imjorge,项目名称:flynn,代码行数:11,代码来源:helper.go
示例18: TestRunLimits
func (s *CLISuite) TestRunLimits(t *c.C) {
app := s.newCliTestApp(t)
defer app.cleanup()
cmd := app.flynn("run", "sh", "-c", resourceCmd)
t.Assert(cmd, Succeeds)
defaults := resource.Defaults()
limits := strings.Split(strings.TrimSpace(cmd.Output), "\n")
t.Assert(limits, c.HasLen, 3)
t.Assert(limits[0], c.Equals, strconv.FormatInt(*defaults[resource.TypeMemory].Limit, 10))
t.Assert(limits[1], c.Equals, strconv.FormatInt(1024, 10))
t.Assert(limits[2], c.Equals, strconv.FormatInt(*defaults[resource.TypeMaxFD].Limit, 10))
}
开发者ID:imjorge,项目名称:flynn,代码行数:12,代码来源:test_cli.go
示例19: TestFailure
func (s *HealthcheckSuite) TestFailure(t *c.C) {
// start an app that is failing checks
app, _ := s.createAppWithService(t, "printer", &host.Service{
Name: "healthcheck-failure",
Create: true,
Check: &host.HealthCheck{Type: "tcp"},
})
t.Assert(flynn(t, "/", "-a", app.Name, "scale", "printer=1"), Succeeds)
// confirm that it's never registered
_, err := s.discoverdClient(t).Instances("healthcheck-failure", 5*time.Second)
t.Assert(err, c.NotNil)
}
开发者ID:imjorge,项目名称:flynn,代码行数:12,代码来源:test_healthcheck.go
示例20: TestEmptyRelease
func (s *GitDeploySuite) TestEmptyRelease(t *c.C) {
r := s.newGitRepo(t, "empty-release")
t.Assert(r.flynn("create"), Succeeds)
t.Assert(r.flynn("env", "set", "BUILDPACK_URL=https://github.com/kr/heroku-buildpack-inline"), Succeeds)
push := r.git("push", "flynn", "master")
t.Assert(push, Succeeds)
run := r.flynn("run", "echo", "foo")
t.Assert(run, Succeeds)
t.Assert(run, Outputs, "foo\n")
}
开发者ID:imjorge,项目名称:flynn,代码行数:12,代码来源:test_git_deploy.go
注:本文中的github.com/flynn/go-check.C类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论