Example #1
0
			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{
Example #2
0
					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 {

							}
						})
					}
Example #3
0
		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())
		})
	})
})
Example #4
0
			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())