本文整理汇总了Golang中github.com/tsuru/tsuru/provision/docker/dockertest.StartMultipleServersCluster函数的典型用法代码示例。如果您正苦于以下问题:Golang StartMultipleServersCluster函数的具体用法?Golang StartMultipleServersCluster怎么用?Golang StartMultipleServersCluster使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StartMultipleServersCluster函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestClusterHookBeforeCreateContainerIgnoresExistingError
func (s *S) TestClusterHookBeforeCreateContainerIgnoresExistingError(c *check.C) {
_, err := InitializeBS()
c.Assert(err, check.IsNil)
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
var buf safe.Buffer
err = RecreateContainers(p, &buf)
c.Assert(err, check.IsNil)
nodes, err := p.Cluster().Nodes()
c.Assert(err, check.IsNil)
hook := ClusterHook{Provisioner: p}
err = hook.RunClusterHook(cluster.HookEventBeforeContainerCreate, &nodes[0])
c.Assert(err, check.IsNil)
c.Assert(nodes, check.HasLen, 2)
client, err := nodes[0].Client()
c.Assert(err, check.IsNil)
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err := client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, BsDefaultName)
client, err = nodes[1].Client()
c.Assert(err, check.IsNil)
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err = client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, BsDefaultName)
}
示例2: TestClusterHookBeforeCreateContainerIgnoresExistingError
func (s *S) TestClusterHookBeforeCreateContainerIgnoresExistingError(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
err = RecreateContainers(p)
c.Assert(err, check.IsNil)
nodes, err := p.Cluster().Nodes()
c.Assert(err, check.IsNil)
hook := ClusterHook{Provisioner: p}
err = hook.BeforeCreateContainer(nodes[0])
c.Assert(err, check.IsNil)
c.Assert(nodes, check.HasLen, 2)
client, err := nodes[0].Client()
c.Assert(err, check.IsNil)
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err := client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, "big-sibling")
client, err = nodes[1].Client()
c.Assert(err, check.IsNil)
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err = client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, "big-sibling")
}
示例3: TestEnsureContainersStartedOnlyChild
func (s *S) TestEnsureContainersStartedOnlyChild(c *check.C) {
err := nodecontainer.AddNewContainer("p1", &nodecontainer.NodeContainerConfig{
Name: "c1",
Config: docker.Config{
Image: "myregistry/tsuru/bs",
},
})
c.Assert(err, check.IsNil)
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
clust := p.Cluster()
nodes, err := clust.Nodes()
c.Assert(err, check.IsNil)
c.Assert(nodes, check.HasLen, 2)
nodes[0].Metadata["pool"] = "p1"
_, err = p.Cluster().UpdateNode(nodes[0])
c.Assert(err, check.IsNil)
nodes[1].Metadata["pool"] = "p2"
_, err = p.Cluster().UpdateNode(nodes[1])
c.Assert(err, check.IsNil)
buf := safe.NewBuffer(nil)
err = ensureContainersStarted(p, buf, true, nil)
c.Assert(err, check.IsNil)
client, err := docker.NewClient(nodes[0].Address)
c.Assert(err, check.IsNil)
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
client2, err := docker.NewClient(nodes[1].Address)
c.Assert(err, check.IsNil)
containers2, err := client2.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers2, check.HasLen, 0)
}
示例4: TestRunContainerHealerCreatedContainerNoProcess
func (s *S) TestRunContainerHealerCreatedContainerNoProcess(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
app := provisiontest.NewFakeApp("myapp", "python", 2)
containers, err := p.StartContainers(dockertest.StartContainersArgs{
Endpoint: p.Servers()[0].URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
notToMove := containers[1]
notToMove.MongoID = bson.NewObjectIdWithTime(time.Now().Add(-2 * time.Minute))
notToMove.ProcessName = ""
p.PrepareListResult([]container.Container{containers[0], notToMove}, nil)
healer := NewContainerHealer(ContainerHealerArgs{
Provisioner: p,
MaxUnresponsiveTime: time.Minute,
Locker: dockertest.NewFakeLocker(),
})
healer.runContainerHealerOnce()
movings := p.Movings()
c.Assert(movings, check.IsNil)
healingColl, err := healingCollection()
c.Assert(err, check.IsNil)
defer healingColl.Close()
n, err := healingColl.Count()
c.Assert(err, check.IsNil)
c.Assert(n, check.Equals, 0)
}
示例5: TestRunContainerHealerDoesntHealWhenContainerIsRestarting
func (s *S) TestRunContainerHealerDoesntHealWhenContainerIsRestarting(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
node1 := p.Servers()[0]
app := provisiontest.NewFakeApp("myapp", "python", 0)
cont, err := p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 1},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
node1.MutateContainer(cont[0].ID, docker.State{Running: false, Restarting: true})
toMoveCont := cont[0]
toMoveCont.LastSuccessStatusUpdate = time.Now().Add(-2 * time.Minute)
p.PrepareListResult([]container.Container{toMoveCont}, nil)
healer := NewContainerHealer(ContainerHealerArgs{
Provisioner: p,
MaxUnresponsiveTime: time.Minute,
Locker: dockertest.NewFakeLocker(),
})
healer.runContainerHealerOnce()
healingColl, err := healingCollection()
c.Assert(err, check.IsNil)
defer healingColl.Close()
var events []HealingEvent
err = healingColl.Find(nil).All(&events)
c.Assert(err, check.IsNil)
c.Assert(events, check.HasLen, 0)
}
示例6: TestRecreateBsContainers
func (s *S) TestRecreateBsContainers(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
err = RecreateContainers(p)
c.Assert(err, check.IsNil)
nodes, err := p.Cluster().Nodes()
c.Assert(err, check.IsNil)
c.Assert(nodes, check.HasLen, 2)
client, err := nodes[0].Client()
c.Assert(err, check.IsNil)
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err := client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, "big-sibling")
client, err = nodes[1].Client()
c.Assert(err, check.IsNil)
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err = client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, "big-sibling")
}
示例7: TestRunContainerHealerRemovedFromDB
func (s *S) TestRunContainerHealerRemovedFromDB(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
node1 := p.Servers()[0]
app := newFakeAppInDB("myapp", "python", 0)
_, err = p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 1},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
containers := p.AllContainers()
c.Assert(err, check.IsNil)
p.DeleteContainer(containers[0].ID)
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
toMoveCont := containers[0]
toMoveCont.LastSuccessStatusUpdate = time.Now().Add(-5 * time.Minute)
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
healer := NewContainerHealer(ContainerHealerArgs{Provisioner: p, Locker: dockertest.NewFakeLocker()})
err = healer.healContainerIfNeeded(toMoveCont)
c.Assert(err, check.IsNil)
}
示例8: TestRecreateBsContainersErrorInSomeContainers
func (s *S) TestRecreateBsContainersErrorInSomeContainers(c *check.C) {
_, err := nodecontainer.InitializeBS()
c.Assert(err, check.IsNil)
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
nodes, err := p.Cluster().Nodes()
c.Assert(err, check.IsNil)
c.Assert(nodes, check.HasLen, 2)
servers := p.Servers()
servers[0].PrepareFailure("failure-create", "/containers/create")
defer servers[1].ResetFailure("failure-create")
var buf safe.Buffer
err = recreateContainers(p, &buf)
c.Assert(err, check.ErrorMatches, `(?s)API error \(400\): failure-create.*failed to create container in .* \[.*\].*`)
sort.Sort(cluster.NodeList(nodes))
client, err := nodes[0].Client()
c.Assert(err, check.IsNil)
containers, err := client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 0)
client, err = nodes[1].Client()
c.Assert(err, check.IsNil)
containers, err = client.ListContainers(docker.ListContainersOptions{All: true})
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 1)
container, err := client.InspectContainer(containers[0].ID)
c.Assert(err, check.IsNil)
c.Assert(container.Name, check.Equals, nodecontainer.BsDefaultName)
}
示例9: TestRunContainerHealerWithError
func (s *S) TestRunContainerHealerWithError(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
node1 := p.Servers()[0]
app := newFakeAppInDB("myapp", "python", 0)
_, err = p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
containers := p.AllContainers()
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 2)
c.Assert(containers[0].HostAddr, check.Equals, net.URLToHost(node1.URL()))
c.Assert(containers[1].HostAddr, check.Equals, net.URLToHost(node1.URL()))
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
node1.MutateContainer(containers[1].ID, docker.State{Running: false, Restarting: false})
toMoveCont := containers[1]
toMoveCont.LastSuccessStatusUpdate = time.Now().Add(-2 * time.Minute)
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
p.FailMove(
errors.New("cannot move container"),
errors.New("cannot move container"),
errors.New("cannot move container"),
)
healer := NewContainerHealer(ContainerHealerArgs{
Provisioner: p,
MaxUnresponsiveTime: time.Minute,
Locker: dockertest.NewFakeLocker(),
})
healer.runContainerHealerOnce()
containers = p.AllContainers()
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 2)
hosts := []string{containers[0].HostAddr, containers[1].HostAddr}
c.Assert(hosts[0], check.Equals, net.URLToHost(node1.URL()))
c.Assert(hosts[1], check.Equals, net.URLToHost(node1.URL()))
c.Assert(eventtest.EventDesc{
Target: event.Target{Type: "container", Value: toMoveCont.ID},
Kind: "healer",
StartCustomData: map[string]interface{}{
"hostaddr": "127.0.0.1",
"id": toMoveCont.ID,
},
ErrorMatches: `.*Error trying to heal containers.*`,
EndCustomData: map[string]interface{}{
"hostaddr": "",
},
}, eventtest.HasEvent)
}
示例10: TestRunContainerHealerAlreadyHealed
func (s *S) TestRunContainerHealerAlreadyHealed(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
node1 := p.Servers()[0]
app := provisiontest.NewFakeApp("myapp", "python", 0)
_, err = p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
containers := p.AllContainers()
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 2)
c.Assert(containers[0].HostAddr, check.Equals, net.URLToHost(node1.URL()))
c.Assert(containers[1].HostAddr, check.Equals, net.URLToHost(node1.URL()))
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
node1.MutateContainer(containers[1].ID, docker.State{Running: false, Restarting: false})
toMoveCont := containers[1]
toMoveCont.LastSuccessStatusUpdate = time.Now().Add(-5 * time.Minute)
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
node1.PrepareFailure("createError", "/containers/create")
healer := NewContainerHealer(ContainerHealerArgs{Provisioner: p, Locker: dockertest.NewFakeLocker()})
healer.healContainerIfNeeded(toMoveCont)
healer.healContainerIfNeeded(toMoveCont)
expected := dockertest.ContainerMoving{
ContainerID: toMoveCont.ID,
HostFrom: toMoveCont.HostAddr,
HostTo: "",
}
movings := p.Movings()
c.Assert(movings, check.DeepEquals, []dockertest.ContainerMoving{expected})
healingColl, err := healingCollection()
c.Assert(err, check.IsNil)
defer healingColl.Close()
var events []HealingEvent
err = healingColl.Find(nil).All(&events)
c.Assert(err, check.IsNil)
c.Assert(events, check.HasLen, 1)
c.Assert(events[0].Action, check.Equals, "container-healing")
c.Assert(events[0].StartTime.IsZero(), check.Equals, false)
c.Assert(events[0].EndTime.IsZero(), check.Equals, false)
c.Assert(events[0].Error, check.Equals, "")
c.Assert(events[0].Successful, check.Equals, true)
c.Assert(events[0].FailingContainer.HostAddr, check.Equals, "127.0.0.1")
c.Assert(events[0].CreatedContainer.HostAddr, check.Equals, "127.0.0.1")
}
示例11: TestRunContainerHealerShutdown
func (s *S) TestRunContainerHealerShutdown(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
node1 := p.Servers()[0]
app := provisiontest.NewFakeApp("myapp", "python", 0)
_, err = p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
containers := p.AllContainers()
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 2)
c.Assert(containers[0].HostAddr, check.Equals, net.URLToHost(node1.URL()))
c.Assert(containers[1].HostAddr, check.Equals, net.URLToHost(node1.URL()))
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
node1.MutateContainer(containers[1].ID, docker.State{Running: false, Restarting: false})
toMoveCont := containers[1]
toMoveCont.LastSuccessStatusUpdate = time.Now().Add(-5 * time.Minute)
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
node1.PrepareFailure("createError", "/containers/create")
healer := NewContainerHealer(ContainerHealerArgs{
Provisioner: p,
MaxUnresponsiveTime: time.Minute,
Done: make(chan bool),
Locker: dockertest.NewFakeLocker(),
})
ch := make(chan bool)
go func() {
defer close(ch)
healer.RunContainerHealer()
}()
healer.Shutdown()
<-ch
expected := dockertest.ContainerMoving{
ContainerID: toMoveCont.ID,
HostFrom: toMoveCont.HostAddr,
HostTo: "",
}
movings := p.Movings()
c.Assert(movings, check.DeepEquals, []dockertest.ContainerMoving{expected})
}
示例12: TestRunContainerHealerCreatedContainer
func (s *S) TestRunContainerHealerCreatedContainer(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
app := provisiontest.NewFakeApp("myapp", "python", 2)
node1 := p.Servers()[0]
containers, err := p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
node1.MutateContainer(containers[1].ID, docker.State{Running: false, Restarting: false})
toMoveCont := containers[1]
toMoveCont.MongoID = bson.NewObjectIdWithTime(time.Now().Add(-2 * time.Minute))
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
node1.PrepareFailure("createError", "/containers/create")
healer := NewContainerHealer(ContainerHealerArgs{
Provisioner: p,
MaxUnresponsiveTime: time.Minute,
Locker: dockertest.NewFakeLocker(),
})
healer.runContainerHealerOnce()
expected := []dockertest.ContainerMoving{
{
ContainerID: toMoveCont.ID,
HostFrom: toMoveCont.HostAddr,
HostTo: "",
},
}
movings := p.Movings()
c.Assert(movings, check.DeepEquals, expected)
healingColl, err := healingCollection()
c.Assert(err, check.IsNil)
defer healingColl.Close()
var events []HealingEvent
err = healingColl.Find(nil).All(&events)
c.Assert(err, check.IsNil)
c.Assert(events, check.HasLen, 1)
c.Assert(events[0].Action, check.Equals, "container-healing")
c.Assert(events[0].StartTime.IsZero(), check.Equals, false)
c.Assert(events[0].EndTime.IsZero(), check.Equals, false)
c.Assert(events[0].Error, check.Equals, "")
c.Assert(events[0].Successful, check.Equals, true)
c.Assert(events[0].FailingContainer.HostAddr, check.Equals, "127.0.0.1")
c.Assert(events[0].CreatedContainer.HostAddr, check.Equals, "127.0.0.1")
}
示例13: TestRunContainerHealerAlreadyHealed
func (s *S) TestRunContainerHealerAlreadyHealed(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
node1 := p.Servers()[0]
app := newFakeAppInDB("myapp", "python", 0)
_, err = p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
containers := p.AllContainers()
c.Assert(err, check.IsNil)
c.Assert(containers, check.HasLen, 2)
c.Assert(containers[0].HostAddr, check.Equals, net.URLToHost(node1.URL()))
c.Assert(containers[1].HostAddr, check.Equals, net.URLToHost(node1.URL()))
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
node1.MutateContainer(containers[1].ID, docker.State{Running: false, Restarting: false})
toMoveCont := containers[1]
toMoveCont.LastSuccessStatusUpdate = time.Now().Add(-5 * time.Minute)
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
node1.PrepareFailure("createError", "/containers/create")
healer := NewContainerHealer(ContainerHealerArgs{Provisioner: p, Locker: dockertest.NewFakeLocker()})
err = healer.healContainerIfNeeded(toMoveCont)
c.Assert(err, check.IsNil)
err = healer.healContainerIfNeeded(toMoveCont)
c.Assert(err, check.IsNil)
expected := dockertest.ContainerMoving{
ContainerID: toMoveCont.ID,
HostFrom: toMoveCont.HostAddr,
HostTo: "",
}
movings := p.Movings()
c.Assert(movings, check.DeepEquals, []dockertest.ContainerMoving{expected})
c.Assert(eventtest.EventDesc{
Target: event.Target{Type: "container", Value: toMoveCont.ID},
Kind: "healer",
StartCustomData: map[string]interface{}{
"hostaddr": "127.0.0.1",
"id": toMoveCont.ID,
},
EndCustomData: map[string]interface{}{
"hostaddr": "127.0.0.1",
"id": bson.M{"$ne": ""},
},
}, eventtest.HasEvent)
}
示例14: TestRunContainerHealerStoppedContainer
func (s *S) TestRunContainerHealerStoppedContainer(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
app := newFakeAppInDB("myapp", "python", 2)
node1 := p.Servers()[0]
containers, err := p.StartContainers(dockertest.StartContainersArgs{
Endpoint: node1.URL(),
App: app,
Amount: map[string]int{"web": 2},
Image: "tsuru/python",
PullImage: true,
})
c.Assert(err, check.IsNil)
node1.MutateContainer(containers[0].ID, docker.State{Running: false, Restarting: false})
node1.MutateContainer(containers[1].ID, docker.State{Dead: true})
toMoveCont := containers[1]
err = toMoveCont.SetStatus(p, provision.StatusStopped, false)
c.Assert(err, check.IsNil)
toMoveCont.LastSuccessStatusUpdate = time.Now().UTC().Add(-5 * time.Minute)
p.PrepareListResult([]container.Container{containers[0], toMoveCont}, nil)
node1.PrepareFailure("createError", "/containers/create")
healer := NewContainerHealer(ContainerHealerArgs{
Provisioner: p,
MaxUnresponsiveTime: time.Minute,
Locker: dockertest.NewFakeLocker(),
})
healer.runContainerHealerOnce()
expected := []dockertest.ContainerMoving{
{
ContainerID: toMoveCont.ID,
HostFrom: toMoveCont.HostAddr,
HostTo: "",
},
}
movings := p.Movings()
c.Assert(movings, check.DeepEquals, expected)
c.Assert(eventtest.EventDesc{
Target: event.Target{Type: "container", Value: toMoveCont.ID},
Kind: "healer",
StartCustomData: map[string]interface{}{
"hostaddr": "127.0.0.1",
"id": toMoveCont.ID,
},
EndCustomData: map[string]interface{}{
"hostaddr": "127.0.0.1",
"id": bson.M{"$ne": ""},
},
}, eventtest.HasEvent)
}
示例15: TestListUnresponsiveContainersNoHostPort
func (s *S) TestListUnresponsiveContainersNoHostPort(c *check.C) {
p, err := dockertest.StartMultipleServersCluster()
c.Assert(err, check.IsNil)
defer p.Destroy()
var result []container.Container
coll := p.Collection()
defer coll.Close()
now := time.Now().UTC()
coll.Insert(
container.Container{ID: "c1", AppName: "app_time_test", LastSuccessStatusUpdate: now.Add(-10 * time.Minute)},
)
defer coll.RemoveAll(bson.M{"appname": "app_time_test"})
result, err = listUnresponsiveContainers(p, 3*time.Minute)
c.Assert(err, check.IsNil)
c.Assert(result, check.HasLen, 0)
}