Exemple #1
0
		container, err = client.Create(warden.ContainerSpec{})
		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())
		})
	})
				var started time.Time
				var receivedBytes uint64

				numToSpawn := streams

				BeforeEach(func() {
					atomic.StoreUint64(&receivedBytes, 0)
					started = time.Now()

					spawned := make(chan bool)

					for j := 0; j < numToSpawn; j++ {
						go func() {
							defer GinkgoRecover()
							_, results, err := container.Run(warden.ProcessSpec{
								Script: "cat /dev/zero",
							})
							Expect(err).ToNot(HaveOccurred())

							go func(results <-chan warden.ProcessStream) {
								for {
									res, ok := <-results
									if !ok {
										break
									}

									atomic.AddUint64(&receivedBytes, uint64(len(res.Data)))
								}
							}(results)

							spawned <- true
Exemple #3
0
				exitStatus := uint32(123)
				stream <- warden.ProcessStream{
					ExitStatus: &exitStatus,
				}

				close(stream)

				return 42, stream, nil
			}

			spec := warden.ProcessSpec{
				Script: "some-script",
			}

			pid, stream, err := container.Run(spec)
			Ω(err).ShouldNot(HaveOccurred())
			Ω(pid).Should(Equal(uint32(42)))

			Ω(fakeConnection.SpawnedProcesses("some-handle")).Should(ContainElement(spec))

			Ω(<-stream).Should(Equal(warden.ProcessStream{
				Source: warden.ProcessStreamSourceStdout,
				Data:   []byte("stdout data"),
			}))

			Ω(<-stream).Should(Equal(warden.ProcessStream{
				Source: warden.ProcessStreamSourceStderr,
				Data:   []byte("stderr data"),
			}))
Exemple #4
0
	BeforeEach(func() {
		var err error

		container, err = client.Create(warden.ContainerSpec{})
		Expect(err).ToNot(HaveOccurred())
	})

	AfterEach(func() {
		err := client.Destroy(container.Handle())
		Expect(err).ToNot(HaveOccurred())
	})

	It("sources /etc/seed", func() {
		_, stream, err := container.Run(warden.ProcessSpec{
			Script: "test -e /tmp/ran-seed",
		})
		Expect(err).ToNot(HaveOccurred())

		for chunk := range stream {
			if chunk.ExitStatus != nil {
				Expect(*chunk.ExitStatus).To(Equal(uint32(0)))
			}
		}
	})

	It("should provide 64k of /dev/shm within the container", func() {
		command1 := "df|grep /dev/shm|grep 342678243768342867432"
		command2 := "mount|grep /dev/shm|grep tmpfs"
		_, _, err := container.Run(warden.ProcessSpec{
			Script: fmt.Sprintf("%s && %s", command1, command2),
Exemple #5
0
		err = runner.Start()
		Expect(err).ToNot(HaveOccurred())
	}

	It("retains the container list", func() {
		restartServer()

		handles := getContainerHandles()
		Expect(handles).To(ContainElement(container.Handle()))
	})

	Describe("a started job", func() {
		It("continues to stream", func() {
			processID, runStream, err := container.Run(warden.ProcessSpec{
				Script: "while true; do echo hi; sleep 0.5; done",
			})

			Expect(err).ToNot(HaveOccurred())

			restartServer()

			Eventually(runStream).Should(BeClosed())

			stream, err := container.Attach(processID)
			Expect(err).ToNot(HaveOccurred())

			var chunk warden.ProcessStream
			Eventually(stream).Should(Receive(&chunk))
			Expect(chunk.Data).To(ContainSubstring("hi\n"))
		})