当前位置: 首页>>代码示例>>Golang>>正文


Golang Container.Info方法代码示例

本文整理汇总了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{
开发者ID:vito,项目名称:warden-linux,代码行数:31,代码来源:properties_test.go

示例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 {

							}
						})
					}
开发者ID:vito,项目名称:warden-linux,代码行数:30,代码来源:stream_measure_test.go

示例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())
		})
	})
})
开发者ID:vito,项目名称:warden-linux,代码行数:30,代码来源:grace_time_test.go

示例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())
开发者ID:vito,项目名称:warden-linux,代码行数:31,代码来源:security_test.go


注:本文中的github.com/cloudfoundry-incubator/garden/warden.Container.Info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。