本文整理汇总了Golang中github.com/tsuru/tsuru/app.GetName函数的典型用法代码示例。如果您正苦于以下问题:Golang GetName函数的具体用法?Golang GetName怎么用?Golang GetName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSetRouterHealthcheckBackward
func (s *S) TestSetRouterHealthcheckBackward(c *check.C) {
app := provisiontest.NewFakeApp("myapp", "python", 1)
imageName := "tsuru/img1"
customData := map[string]interface{}{
"healthcheck": map[string]interface{}{
"path": "/x/y",
"status": http.StatusCreated,
"match": "ignored",
"use_in_router": true,
},
}
err := image.SaveImageCustomData(imageName, customData)
c.Assert(err, check.IsNil)
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
args := changeUnitsPipelineArgs{
app: app,
provisioner: s.p,
imageId: imageName,
}
cont1 := container.Container{ID: "ble-1", AppName: app.GetName(), ProcessName: "web", HostAddr: "127.0.0.1", HostPort: "1234"}
context := action.FWContext{Previous: []container.Container{cont1}, Params: []interface{}{args}}
_, err = setRouterHealthcheck.Forward(context)
c.Assert(err, check.IsNil)
hcData := routertest.FakeRouter.GetHealthcheck(app.GetName())
c.Assert(hcData, check.DeepEquals, router.HealthcheckData{
Path: "/x/y",
Status: http.StatusCreated,
})
bwcontext := action.BWContext{Params: []interface{}{args}}
setRouterHealthcheck.Backward(bwcontext)
hcData = routertest.FakeRouter.GetHealthcheck(app.GetName())
c.Assert(hcData, check.DeepEquals, router.HealthcheckData{Path: "/"})
}
开发者ID:tsuru,项目名称:tsuru,代码行数:34,代码来源:actions_test.go
示例2: TestContainerCreate
func (s *S) TestContainerCreate(c *gocheck.C) {
app := testing.NewFakeApp("app-name", "brainfuck", 1)
app.Memory = 15
rtesting.FakeRouter.AddBackend(app.GetName())
defer rtesting.FakeRouter.RemoveBackend(app.GetName())
dockerCluster().PullImage(
docker.PullImageOptions{Repository: "tsuru/brainfuck"},
docker.AuthConfiguration{},
)
cont := container{Name: "myName", AppName: app.GetName(), Type: app.GetPlatform(), Status: "created"}
err := cont.create(app, getImage(app), []string{"docker", "run"})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(&cont)
c.Assert(cont.ID, gocheck.Not(gocheck.Equals), "")
c.Assert(cont, gocheck.FitsTypeOf, container{})
c.Assert(cont.AppName, gocheck.Equals, app.GetName())
c.Assert(cont.Type, gocheck.Equals, app.GetPlatform())
u, _ := url.Parse(s.server.URL())
host, _, _ := net.SplitHostPort(u.Host)
c.Assert(cont.HostAddr, gocheck.Equals, host)
user, err := config.GetString("docker:ssh:user")
c.Assert(err, gocheck.IsNil)
c.Assert(cont.User, gocheck.Equals, user)
dcli, _ := docker.NewClient(s.server.URL())
container, err := dcli.InspectContainer(cont.ID)
c.Assert(err, gocheck.IsNil)
c.Assert(container.Path, gocheck.Equals, "docker")
c.Assert(container.Args, gocheck.DeepEquals, []string{"run"})
c.Assert(container.Config.User, gocheck.Equals, user)
c.Assert(container.Config.Memory, gocheck.Equals, int64(app.Memory*1024*1024))
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:31,代码来源:docker_test.go
示例3: FilterAppsByUnitStatus
func (p *dockerProvisioner) FilterAppsByUnitStatus(apps []provision.App, status []string) ([]provision.App, error) {
if apps == nil {
return nil, fmt.Errorf("apps must be provided to FilterAppsByUnitStatus")
}
if status == nil {
return make([]provision.App, 0), nil
}
appNames := make([]string, len(apps))
for i, app := range apps {
appNames[i] = app.GetName()
}
containers, err := p.listContainersByAppAndStatus(appNames, status)
if err != nil {
return nil, err
}
result := make([]provision.App, 0)
for _, app := range apps {
for _, c := range containers {
if app.GetName() == c.AppName {
result = append(result, app)
break
}
}
}
return result, nil
}
开发者ID:ggarnier,项目名称:tsuru,代码行数:26,代码来源:provisioner.go
示例4: TestProvisionerAddUnitsWithErrorDoesntLeaveLostUnits
func (s *S) TestProvisionerAddUnitsWithErrorDoesntLeaveLostUnits(c *gocheck.C) {
callCount := 0
s.server.CustomHandler("/containers/create", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
callCount++
if callCount == 2 {
w.WriteHeader(http.StatusInternalServerError)
return
}
s.server.DefaultHandler().ServeHTTP(w, r)
}))
defer s.server.CustomHandler("/containers/create", s.server.DefaultHandler())
err := newImage("tsuru/python", s.server.URL())
c.Assert(err, gocheck.IsNil)
var p dockerProvisioner
app := testing.NewFakeApp("myapp", "python", 0)
p.Provision(app)
defer p.Destroy(app)
coll := collection()
defer coll.Close()
coll.Insert(container{ID: "c-89320", AppName: app.GetName(), Version: "a345fe", Image: "tsuru/python"})
defer coll.RemoveId(bson.M{"id": "c-89320"})
_, err = p.AddUnits(app, 3)
c.Assert(err, gocheck.NotNil)
count, err := coll.Find(bson.M{"appname": app.GetName()}).Count()
c.Assert(err, gocheck.IsNil)
c.Assert(count, gocheck.Equals, 1)
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:27,代码来源:provisioner_test.go
示例5: TestProvisionAddUnitsToHostForwardWithoutHost
func (s *S) TestProvisionAddUnitsToHostForwardWithoutHost(c *check.C) {
p, err := s.startMultipleServersCluster()
c.Assert(err, check.IsNil)
app := provisiontest.NewFakeApp("myapp-2", "python", 0)
defer p.Destroy(app)
p.Provision(app)
coll := p.Collection()
defer coll.Close()
imageId, err := appNewImageName(app.GetName())
c.Assert(err, check.IsNil)
err = s.newFakeImage(p, imageId, nil)
c.Assert(err, check.IsNil)
args := changeUnitsPipelineArgs{
app: app,
toAdd: map[string]*containersToAdd{"web": {Quantity: 3}},
imageId: imageId,
provisioner: p,
}
context := action.FWContext{Params: []interface{}{args}}
result, err := provisionAddUnitsToHost.Forward(context)
c.Assert(err, check.IsNil)
containers := result.([]container.Container)
c.Assert(containers, check.HasLen, 3)
addrs := []string{containers[0].HostAddr, containers[1].HostAddr, containers[2].HostAddr}
sort.Strings(addrs)
isValid := reflect.DeepEqual(addrs, []string{"127.0.0.1", "localhost", "localhost"}) ||
reflect.DeepEqual(addrs, []string{"127.0.0.1", "127.0.0.1", "localhost"})
if !isValid {
clusterNodes, _ := p.Cluster().UnfilteredNodes()
c.Fatalf("Expected multiple hosts, got: %#v\nAvailable nodes: %#v", containers, clusterNodes)
}
count, err := coll.Find(bson.M{"appname": app.GetName()}).Count()
c.Assert(err, check.IsNil)
c.Assert(count, check.Equals, 3)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:35,代码来源:actions_test.go
示例6: TestContainerCreateDoesNotAlocatesPortForDeploy
func (s *S) TestContainerCreateDoesNotAlocatesPortForDeploy(c *check.C) {
s.server.CustomHandler("/images/.*/json", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
response := docker.Image{
Config: &docker.Config{
ExposedPorts: map[docker.Port]struct{}{},
},
}
j, _ := json.Marshal(response)
w.Write(j)
}))
app := provisiontest.NewFakeApp("app-name", "brainfuck", 1)
app.Memory = 15
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
img := "tsuru/brainfuck:latest"
s.p.Cluster().PullImage(docker.PullImageOptions{Repository: img}, docker.AuthConfiguration{})
cont := Container{
Name: "myName",
AppName: app.GetName(),
Type: app.GetPlatform(),
Status: "created",
}
err := cont.Create(&CreateArgs{
Deploy: true,
App: app,
ImageID: img,
Commands: []string{"docker", "run"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
defer s.removeTestContainer(&cont)
info, err := cont.NetworkInfo(s.p)
c.Assert(err, check.IsNil)
c.Assert(info.HTTPHostPort, check.Equals, "")
}
开发者ID:pedrosnk,项目名称:tsuru,代码行数:35,代码来源:container_test.go
示例7: TestContainerCreateDoesNotAlocatesPortForDeploy
func (s *S) TestContainerCreateDoesNotAlocatesPortForDeploy(c *check.C) {
app := provisiontest.NewFakeApp("app-name", "brainfuck", 1)
app.Memory = 15
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
img := "tsuru/brainfuck:latest"
s.p.Cluster().PullImage(docker.PullImageOptions{Repository: img}, docker.AuthConfiguration{})
cont := Container{
Name: "myName",
AppName: app.GetName(),
Type: app.GetPlatform(),
Status: "created",
}
err := cont.Create(&CreateArgs{
Deploy: true,
App: app,
ImageID: img,
Commands: []string{"docker", "run"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
defer s.removeTestContainer(&cont)
info, err := cont.NetworkInfo(s.p)
c.Assert(err, check.IsNil)
c.Assert(info.HTTPHostPort, check.Equals, "")
}
开发者ID:kgrvamsi,项目名称:tsuru,代码行数:26,代码来源:container_test.go
示例8: TestContainerCreateUndefinedUser
func (s *S) TestContainerCreateUndefinedUser(c *check.C) {
oldUser, _ := config.Get("docker:user")
defer config.Set("docker:user", oldUser)
config.Unset("docker:user")
img := "tsuru/python:latest"
s.p.Cluster().PullImage(docker.PullImageOptions{Repository: img}, docker.AuthConfiguration{})
app := provisiontest.NewFakeApp("app-name", "python", 1)
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
cont := Container{
Name: "myName",
AppName: app.GetName(),
Type: app.GetPlatform(),
Status: "created",
}
err := cont.Create(&CreateArgs{
App: app,
ImageID: img,
Commands: []string{"docker", "run"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
defer s.removeTestContainer(&cont)
dcli, _ := docker.NewClient(s.server.URL())
container, err := dcli.InspectContainer(cont.ID)
c.Assert(err, check.IsNil)
c.Assert(container.Config.User, check.Equals, "")
}
开发者ID:kgrvamsi,项目名称:tsuru,代码行数:28,代码来源:container_test.go
示例9: TestProvisionAddUnitsToHostForward
func (s *S) TestProvisionAddUnitsToHostForward(c *check.C) {
p, err := s.startMultipleServersCluster()
c.Assert(err, check.IsNil)
app := provisiontest.NewFakeApp("myapp-2", "python", 0)
defer p.Destroy(app)
p.Provision(app)
coll := p.Collection()
defer coll.Close()
coll.Insert(container.Container{ID: "container-id", AppName: app.GetName(), Version: "container-version", Image: "tsuru/python"})
defer coll.RemoveAll(bson.M{"appname": app.GetName()})
imageId, err := appNewImageName(app.GetName())
c.Assert(err, check.IsNil)
err = s.newFakeImage(p, imageId, nil)
c.Assert(err, check.IsNil)
args := changeUnitsPipelineArgs{
app: app,
toHost: "localhost",
toAdd: map[string]*containersToAdd{"web": {Quantity: 2}},
imageId: imageId,
provisioner: p,
}
context := action.FWContext{Params: []interface{}{args}}
result, err := provisionAddUnitsToHost.Forward(context)
c.Assert(err, check.IsNil)
containers := result.([]container.Container)
c.Assert(containers, check.HasLen, 2)
c.Assert(containers[0].HostAddr, check.Equals, "localhost")
c.Assert(containers[1].HostAddr, check.Equals, "localhost")
count, err := coll.Find(bson.M{"appname": app.GetName()}).Count()
c.Assert(err, check.IsNil)
c.Assert(count, check.Equals, 3)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:32,代码来源:actions_test.go
示例10: TestInsertEmptyContainerInDBForward
func (s *S) TestInsertEmptyContainerInDBForward(c *check.C) {
app := provisiontest.NewFakeApp("myapp", "python", 1)
args := runContainerActionsArgs{
app: app,
imageID: "image-id",
buildingImage: "next-image",
provisioner: s.p,
}
context := action.FWContext{Params: []interface{}{args}}
r, err := insertEmptyContainerInDB.Forward(context)
c.Assert(err, check.IsNil)
cont := r.(container.Container)
c.Assert(cont, check.FitsTypeOf, container.Container{})
c.Assert(cont.AppName, check.Equals, app.GetName())
c.Assert(cont.Type, check.Equals, app.GetPlatform())
c.Assert(cont.Name, check.Not(check.Equals), "")
c.Assert(strings.HasPrefix(cont.Name, app.GetName()+"-"), check.Equals, true)
c.Assert(cont.Name, check.HasLen, 26)
c.Assert(cont.Status, check.Equals, "created")
c.Assert(cont.Image, check.Equals, "image-id")
c.Assert(cont.BuildingImage, check.Equals, "next-image")
coll := s.p.Collection()
defer coll.Close()
defer coll.Remove(bson.M{"name": cont.Name})
var retrieved container.Container
err = coll.Find(bson.M{"name": cont.Name}).One(&retrieved)
c.Assert(err, check.IsNil)
c.Assert(retrieved.Name, check.Equals, cont.Name)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:29,代码来源:actions_test.go
示例11: TestContainerCreateSecurityOptions
func (s *S) TestContainerCreateSecurityOptions(c *check.C) {
config.Set("docker:security-opts", []string{"label:type:svirt_apache", "ptrace [email protected]"})
defer config.Unset("docker:security-opts")
app := provisiontest.NewFakeApp("app-name", "brainfuck", 1)
app.Memory = 15
app.Swap = 15
app.CpuShare = 50
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
img := "tsuru/brainfuck:latest"
s.p.Cluster().PullImage(docker.PullImageOptions{Repository: img}, docker.AuthConfiguration{})
cont := Container{
Name: "myName",
AppName: app.GetName(),
Type: app.GetPlatform(),
Status: "created",
}
err := cont.Create(&CreateArgs{
App: app,
ImageID: img,
Commands: []string{"docker", "run"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
defer s.removeTestContainer(&cont)
dcli, _ := docker.NewClient(s.server.URL())
container, err := dcli.InspectContainer(cont.ID)
c.Assert(err, check.IsNil)
c.Assert(container.Config.SecurityOpts, check.DeepEquals, []string{"label:type:svirt_apache", "ptrace [email protected]"})
}
开发者ID:kgrvamsi,项目名称:tsuru,代码行数:30,代码来源:container_test.go
示例12: TestAddNewRouteBackward
func (s *S) TestAddNewRouteBackward(c *check.C) {
app := provisiontest.NewFakeApp("myapp", "python", 1)
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
cont1 := container.Container{ID: "ble-1", AppName: app.GetName(), ProcessName: "web", HostAddr: "127.0.0.1", HostPort: "1234"}
cont2 := container.Container{ID: "ble-2", AppName: app.GetName(), ProcessName: "web", HostAddr: "127.0.0.2", HostPort: "4321"}
cont3 := container.Container{ID: "ble-3", AppName: app.GetName(), ProcessName: "worker", HostAddr: "127.0.0.3", HostPort: "8080"}
defer cont1.Remove(s.p)
defer cont2.Remove(s.p)
defer cont3.Remove(s.p)
err := routertest.FakeRouter.AddRoute(app.GetName(), cont1.Address())
c.Assert(err, check.IsNil)
err = routertest.FakeRouter.AddRoute(app.GetName(), cont2.Address())
c.Assert(err, check.IsNil)
args := changeUnitsPipelineArgs{
app: app,
provisioner: s.p,
}
cont1.Routable = true
cont2.Routable = true
context := action.BWContext{FWResult: []container.Container{cont1, cont2, cont3}, Params: []interface{}{args}}
addNewRoutes.Backward(context)
hasRoute := routertest.FakeRouter.HasRoute(app.GetName(), cont1.Address().String())
c.Assert(hasRoute, check.Equals, false)
hasRoute = routertest.FakeRouter.HasRoute(app.GetName(), cont2.Address().String())
c.Assert(hasRoute, check.Equals, false)
hasRoute = routertest.FakeRouter.HasRoute(app.GetName(), cont3.Address().String())
c.Assert(hasRoute, check.Equals, false)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:29,代码来源:actions_test.go
示例13: TestArchiveDeployCanceledEvent
func (s *S) TestArchiveDeployCanceledEvent(c *check.C) {
err := s.newFakeImage(s.p, "tsuru/python:latest", nil)
c.Assert(err, check.IsNil)
app := provisiontest.NewFakeApp("myapp", "python", 1)
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
evt, err := event.New(&event.Opts{
Target: event.Target{Type: "app", Value: "myapp"},
Kind: permission.PermAppDeploy,
Owner: s.token,
Cancelable: true,
Allowed: event.Allowed(permission.PermApp),
AllowedCancel: event.Allowed(permission.PermApp),
})
c.Assert(err, check.IsNil)
done := make(chan bool)
go func() {
defer close(done)
img, depErr := s.p.archiveDeploy(app, image.GetBuildImage(app), "https://s3.amazonaws.com/wat/archive.tar.gz", evt)
c.Assert(depErr, check.ErrorMatches, "deploy canceled by user action")
c.Assert(img, check.Equals, "")
}()
time.Sleep(100 * time.Millisecond)
err = evt.TryCancel("because yes", "[email protected]")
c.Assert(err, check.IsNil)
<-done
}
开发者ID:tsuru,项目名称:tsuru,代码行数:27,代码来源:docker_test.go
示例14: TestProvisionerExecuteCommand
func (s *S) TestProvisionerExecuteCommand(c *gocheck.C) {
file, err := ioutil.TempFile("", "tsuru-docker-tests-cmd")
c.Assert(err, gocheck.IsNil)
defer os.Remove(file.Name())
defer file.Close()
file.Write([]byte("ashes in the flesh\n"))
server := newMockSSHServer(c, 5e9)
defer server.Shutdown()
app := testing.NewFakeApp("starbreaker", "python", 1)
container1, err := s.newContainer(&newContainerOpts{AppName: app.GetName()})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(container1)
container1.SSHHostPort = server.port
container1.HostAddr = "localhost"
container1.PrivateKey = string(fakeServerPrivateKey)
container1.User = sshUsername()
coll := collection()
defer coll.Close()
coll.Update(bson.M{"id": container1.ID}, container1)
container2, err := s.newContainer(&newContainerOpts{AppName: app.GetName()})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(container2)
container2.SSHHostPort = server.port
container2.HostAddr = "localhost"
container2.PrivateKey = string(fakeServerPrivateKey)
container2.User = sshUsername()
coll.Update(bson.M{"id": container2.ID}, container2)
var stdout, stderr bytes.Buffer
var p dockerProvisioner
err = p.ExecuteCommand(&stdout, &stderr, app, "cat", file.Name())
c.Assert(err, gocheck.IsNil)
c.Assert(stdout.String(), gocheck.Equals, "ashes in the flesh\nashes in the flesh\n")
}
开发者ID:rualatngua,项目名称:tsuru,代码行数:33,代码来源:provisioner_test.go
示例15: TestProvisionerStopSkipAlreadyStoppedContainers
func (s *S) TestProvisionerStopSkipAlreadyStoppedContainers(c *gocheck.C) {
dcli, _ := docker.NewClient(s.server.URL())
app := testing.NewFakeApp("almah", "static", 2)
p := dockerProvisioner{}
container, err := s.newContainer(&newContainerOpts{AppName: app.GetName()})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(container)
err = dcli.StartContainer(container.ID, nil)
c.Assert(err, gocheck.IsNil)
dockerContainer, err := dcli.InspectContainer(container.ID)
c.Assert(err, gocheck.IsNil)
c.Assert(dockerContainer.State.Running, gocheck.Equals, true)
container2, err := s.newContainer(&newContainerOpts{AppName: app.GetName()})
c.Assert(err, gocheck.IsNil)
defer s.removeTestContainer(container2)
err = dcli.StartContainer(container2.ID, nil)
c.Assert(err, gocheck.IsNil)
err = dcli.StopContainer(container2.ID, 1)
c.Assert(err, gocheck.IsNil)
container2.setStatus(provision.StatusStopped.String())
dockerContainer2, err := dcli.InspectContainer(container2.ID)
c.Assert(err, gocheck.IsNil)
c.Assert(dockerContainer2.State.Running, gocheck.Equals, false)
err = p.Stop(app)
c.Assert(err, gocheck.IsNil)
dockerContainer, err = dcli.InspectContainer(container.ID)
c.Assert(err, gocheck.IsNil)
c.Assert(dockerContainer.State.Running, gocheck.Equals, false)
dockerContainer2, err = dcli.InspectContainer(container2.ID)
c.Assert(err, gocheck.IsNil)
c.Assert(dockerContainer2.State.Running, gocheck.Equals, false)
}
开发者ID:rochacon,项目名称:tsuru,代码行数:32,代码来源:provisioner_test.go
示例16: TestContainerCreate
func (s *S) TestContainerCreate(c *check.C) {
config.Set("host", "my.cool.tsuru.addr:8080")
defer config.Unset("host")
app := provisiontest.NewFakeApp("app-name", "brainfuck", 1)
app.Memory = 15
app.Swap = 15
app.CpuShare = 50
app.SetEnv(bind.EnvVar{Name: "A", Value: "myenva"})
app.SetEnv(bind.EnvVar{Name: "ABCD", Value: "other env"})
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
img := "tsuru/brainfuck:latest"
s.p.Cluster().PullImage(docker.PullImageOptions{Repository: img}, docker.AuthConfiguration{})
cont := Container{
Name: "myName",
AppName: app.GetName(),
Type: app.GetPlatform(),
Status: "created",
ProcessName: "myprocess1",
}
err := cont.Create(&CreateArgs{
App: app,
ImageID: img,
Commands: []string{"docker", "run"},
Provisioner: s.p,
})
c.Assert(err, check.IsNil)
defer s.removeTestContainer(&cont)
c.Assert(cont.ID, check.Not(check.Equals), "")
c.Assert(cont.AppName, check.Equals, app.GetName())
c.Assert(cont.Type, check.Equals, app.GetPlatform())
u, _ := url.Parse(s.server.URL())
host, _, _ := net.SplitHostPort(u.Host)
c.Assert(cont.HostAddr, check.Equals, host)
user, err := config.GetString("docker:user")
c.Assert(err, check.IsNil)
c.Assert(cont.User, check.Equals, user)
dcli, _ := docker.NewClient(s.server.URL())
container, err := dcli.InspectContainer(cont.ID)
c.Assert(err, check.IsNil)
c.Assert(container.Path, check.Equals, "docker")
c.Assert(container.Args, check.DeepEquals, []string{"run"})
c.Assert(container.Config.User, check.Equals, user)
c.Assert(container.Config.Memory, check.Equals, app.Memory)
c.Assert(container.Config.MemorySwap, check.Equals, app.Memory+app.Swap)
c.Assert(container.Config.CPUShares, check.Equals, int64(app.CpuShare))
sort.Strings(container.Config.Env)
c.Assert(container.Config.Env, check.DeepEquals, []string{
"A=myenva",
"ABCD=other env",
"PORT=8888",
"TSURU_HOST=my.cool.tsuru.addr:8080",
"TSURU_PROCESSNAME=myprocess1",
"port=8888",
})
}
开发者ID:kgrvamsi,项目名称:tsuru,代码行数:56,代码来源:container_test.go
示例17: TestProvision
func (s *S) TestProvision(c *check.C) {
app := NewFakeApp("kid-gloves", "rush", 1)
p := NewFakeProvisioner()
err := p.Provision(app)
c.Assert(err, check.IsNil)
pApp := p.apps[app.GetName()]
c.Assert(pApp.app, check.DeepEquals, app)
c.Assert(pApp.units, check.HasLen, 0)
c.Assert(routertest.FakeRouter.HasBackend(app.GetName()), check.Equals, true)
}
开发者ID:tsuru,项目名称:tsuru,代码行数:10,代码来源:fake_provisioner_test.go
示例18: TestRemoveOldRoutesForward
func (s *S) TestRemoveOldRoutesForward(c *check.C) {
app := provisiontest.NewFakeApp("myapp", "python", 1)
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
cont1 := container.Container{ID: "ble-1", AppName: app.GetName(), ProcessName: "web", HostAddr: "127.0.0.1", HostPort: "1234"}
cont2 := container.Container{ID: "ble-2", AppName: app.GetName(), ProcessName: "web", HostAddr: "127.0.0.2", HostPort: "4321"}
cont3 := container.Container{ID: "ble-3", AppName: app.GetName(), ProcessName: "worker", HostAddr: "127.0.0.3", HostPort: "8080"}
defer cont1.Remove(s.p)
defer cont2.Remove(s.p)
defer cont3.Remove(s.p)
err := routertest.FakeRouter.AddRoute(app.GetName(), cont1.Address())
c.Assert(err, check.IsNil)
err = routertest.FakeRouter.AddRoute(app.GetName(), cont2.Address())
c.Assert(err, check.IsNil)
args := changeUnitsPipelineArgs{
app: app,
toRemove: []container.Container{cont1, cont2, cont3},
provisioner: s.p,
}
context := action.FWContext{Previous: []container.Container{}, Params: []interface{}{args}}
r, err := removeOldRoutes.Forward(context)
c.Assert(err, check.IsNil)
hasRoute := routertest.FakeRouter.HasRoute(app.GetName(), cont1.Address().String())
c.Assert(hasRoute, check.Equals, false)
hasRoute = routertest.FakeRouter.HasRoute(app.GetName(), cont2.Address().String())
c.Assert(hasRoute, check.Equals, false)
containers := r.([]container.Container)
c.Assert(containers, check.DeepEquals, []container.Container{})
c.Assert(args.toRemove[0].Routable, check.Equals, true)
c.Assert(args.toRemove[1].Routable, check.Equals, true)
c.Assert(args.toRemove[2].Routable, check.Equals, false)
}
开发者ID:nicolas2bonfils,项目名称:tsuru,代码行数:32,代码来源:actions_test.go
示例19: TestArchiveDeploy
func (s *S) TestArchiveDeploy(c *gocheck.C) {
go s.stopContainers(1)
err := newImage("tsuru/python", s.server.URL())
c.Assert(err, gocheck.IsNil)
app := testing.NewFakeApp("myapp", "python", 1)
rtesting.FakeRouter.AddBackend(app.GetName())
defer rtesting.FakeRouter.RemoveBackend(app.GetName())
var buf bytes.Buffer
_, err = archiveDeploy(app, "https://s3.amazonaws.com/wat/archive.tar.gz", &buf)
c.Assert(err, gocheck.IsNil)
}
开发者ID:WIZARD-CXY,项目名称:golang-devops-stuff,代码行数:11,代码来源:docker_test.go
示例20: TestCreateContainerForward
func (s *S) TestCreateContainerForward(c *check.C) {
config.Set("docker:user", "ubuntu")
defer config.Unset("docker:user")
err := s.newFakeImage(s.p, "tsuru/python", nil)
c.Assert(err, check.IsNil)
client, err := docker.NewClient(s.server.URL())
c.Assert(err, check.IsNil)
images, err := client.ListImages(docker.ListImagesOptions{All: true})
c.Assert(err, check.IsNil)
cmds := []string{"ps", "-ef"}
app := provisiontest.NewFakeApp("myapp", "python", 1)
cont := container.Container{Name: "myName", AppName: app.GetName(), Type: app.GetPlatform(), Status: "created"}
args := runContainerActionsArgs{
app: app,
imageID: images[0].ID,
commands: cmds,
provisioner: s.p,
buildingImage: images[0].ID,
isDeploy: true,
}
context := action.FWContext{Previous: cont, Params: []interface{}{args}}
r, err := createContainer.Forward(context)
c.Assert(err, check.IsNil)
cont = r.(container.Container)
defer cont.Remove(s.p)
c.Assert(cont, check.FitsTypeOf, container.Container{})
c.Assert(cont.ID, check.Not(check.Equals), "")
c.Assert(cont.HostAddr, check.Equals, "127.0.0.1")
dcli, err := docker.NewClient(s.server.URL())
c.Assert(err, check.IsNil)
cc, err := dcli.InspectContainer(cont.ID)
c.Assert(err, check.IsNil)
c.Assert(cc.State.Running, check.Equals, false)
c.Assert(cc.Config.User, check.Equals, "ubuntu")
args = runContainerActionsArgs{
app: app,
imageID: images[0].ID,
commands: cmds,
provisioner: s.p,
}
optsPull := docker.PullImageOptions{Repository: images[0].ID, OutputStream: nil}
err = s.p.Cluster().PullImage(optsPull, docker.AuthConfiguration{})
c.Assert(err, check.IsNil)
cont = container.Container{Name: "myName2", AppName: app.GetName(), Type: app.GetPlatform(), Status: "created"}
context = action.FWContext{Previous: cont, Params: []interface{}{args}}
r, err = createContainer.Forward(context)
c.Assert(err, check.IsNil)
cont = r.(container.Container)
defer cont.Remove(s.p)
cc, err = dcli.InspectContainer(cont.ID)
c.Assert(err, check.IsNil)
c.Assert(cc.Config.User, check.Equals, "")
}
开发者ID:tsuru,项目名称:tsuru,代码行数:53,代码来源:actions_test.go
注:本文中的github.com/tsuru/tsuru/app.GetName函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论