當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。