本文整理匯總了Golang中github.com/cloudfoundry-incubator/garden/warden.Container.Info方法的典型用法代碼示例。如果您正苦於以下問題:Golang Container.Info方法的具體用法?Golang Container.Info怎麽用?Golang Container.Info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/garden/warden.Container
的用法示例。
在下文中一共展示了Container.Info方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
Properties: warden.Properties{
"foo": "bar",
"a": "b",
},
})
Expect(err).ToNot(HaveOccurred())
})
AfterEach(func() {
err := client.Destroy(container.Handle())
Expect(err).ToNot(HaveOccurred())
})
Describe("when reporting the container's info", func() {
It("includes the properties", func() {
info, err := container.Info()
Ω(err).ShouldNot(HaveOccurred())
Ω(info.Properties["foo"]).Should(Equal("bar"))
Ω(info.Properties["a"]).Should(Equal("b"))
Ω(info.Properties).Should(HaveLen(2))
})
})
Describe("when listing container info", func() {
var undesiredHandles []string
BeforeEach(func() {
undesiredContainer, err := client.Create(warden.ContainerSpec{
Properties: warden.Properties{
示例2:
Expect(err).ToNot(HaveOccurred())
})
Measure("it should not adversely affect the rest of the API", func(b Benchmarker) {
var newContainer warden.Container
b.Time("creating another container", func() {
var err error
newContainer, err = client.Create(warden.ContainerSpec{})
Expect(err).ToNot(HaveOccurred())
})
for i := 0; i < 10; i++ {
b.Time("getting container info (10x)", func() {
_, err := newContainer.Info()
Expect(err).ToNot(HaveOccurred())
})
}
for i := 0; i < 10; i++ {
b.Time("running a job (10x)", func() {
_, stream, err := newContainer.Run(warden.ProcessSpec{Script: "ls"})
Expect(err).ToNot(HaveOccurred())
for _ = range stream {
}
})
}
示例3:
Expect(err).ToNot(HaveOccurred())
})
AfterEach(func() {
err := runner.Stop()
Expect(err).ToNot(HaveOccurred())
err = runner.Start()
Expect(err).ToNot(HaveOccurred())
})
Context("when a request takes longer than the grace time", func() {
It("is not destroyed after the request is over", func() {
_, _, err := container.Run(warden.ProcessSpec{Script: "sleep 6"})
Expect(err).ToNot(HaveOccurred())
_, err = container.Info()
Expect(err).ToNot(HaveOccurred())
})
})
Context("when no requests are made for longer than the grace time", func() {
It("is destroyed", func() {
time.Sleep(6 * time.Second)
_, err := container.Info()
Expect(err).To(HaveOccurred())
})
})
})
示例4:
unblockedListener warden.Container
unblockedListenerIP string
allowedListener warden.Container
allowedListenerIP string
sender warden.Container
)
BeforeEach(func() {
var err error
// create a listener to which we deny network access
blockedListener, err = client.Create(warden.ContainerSpec{})
Expect(err).ToNot(HaveOccurred())
info, err := blockedListener.Info()
Expect(err).ToNot(HaveOccurred())
blockedListenerIP = info.ContainerIP
// create a listener to which we do not deny access
unblockedListener, err = client.Create(warden.ContainerSpec{})
Expect(err).ToNot(HaveOccurred())
info, err = unblockedListener.Info()
Expect(err).ToNot(HaveOccurred())
unblockedListenerIP = info.ContainerIP
// create a listener to which we exclicitly allow access
allowedListener, err = client.Create(warden.ContainerSpec{})
Expect(err).ToNot(HaveOccurred())
info, err = allowedListener.Info()
Expect(err).ToNot(HaveOccurred())