本文整理匯總了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)
}