本文整理汇总了Golang中github.com/tsuru/tsuru/provision/docker/container.Container.Routable方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.Routable方法的具体用法?Golang Container.Routable怎么用?Golang Container.Routable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/provision/docker/container.Container
的用法示例。
在下文中一共展示了Container.Routable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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)
}
示例2: TestRemoveOldRoutesBackward
func (s *S) TestRemoveOldRoutesBackward(c *check.C) {
app := provisiontest.NewFakeApp("myapp", "python", 1)
routertest.FakeRouter.AddBackend(app.GetName())
defer routertest.FakeRouter.RemoveBackend(app.GetName())
cont := container.Container{ID: "ble-1", AppName: app.GetName(), ProcessName: "web"}
cont2 := container.Container{ID: "ble-2", AppName: app.GetName(), ProcessName: "web"}
defer cont.Remove(s.p)
defer cont2.Remove(s.p)
cont.Routable = true
cont2.Routable = true
args := changeUnitsPipelineArgs{
app: app,
toRemove: []container.Container{cont, cont2},
provisioner: s.p,
}
context := action.BWContext{Params: []interface{}{args}}
removeOldRoutes.Backward(context)
hasRoute := routertest.FakeRouter.HasRoute(app.GetName(), cont.Address().String())
c.Assert(hasRoute, check.Equals, true)
hasRoute = routertest.FakeRouter.HasRoute(app.GetName(), cont2.Address().String())
c.Assert(hasRoute, check.Equals, true)
}