Beispiel #1
0
			})
			Expect(err).ToNot(HaveOccurred())

			Expect(string((<-stream).Data)).To(Equal("hello\n"))
			Expect(string((<-stream).Data)).To(Equal("goodbye\n"))
			Expect(*(<-stream).ExitStatus).To(Equal(uint32(42)))
		})

		Context("and then attaching to it", func() {
			It("sends output back in chunks until stopped", func(done Done) {
				processID, _, err := container.Run(warden.ProcessSpec{
					Script: "sleep 2; echo hello; sleep 0.5; echo goodbye; sleep 0.5; exit 42",
				})
				Expect(err).ToNot(HaveOccurred())

				stream, err := container.Attach(processID)

				Expect(string((<-stream).Data)).To(Equal("hello\n"))
				Expect(string((<-stream).Data)).To(Equal("goodbye\n"))
				Expect(*(<-stream).ExitStatus).To(Equal(uint32(42)))

				close(done)
			}, 10.0)
		})

		Context("and then sending a Stop request", func() {
			It("terminates all running processes", func() {
				_, stream, err := container.Run(warden.ProcessSpec{
					Script: `exec ruby -e 'trap("TERM") { exit 42 }; while true; sleep 1; end'`,
				})
Beispiel #2
0
				stream <- warden.ProcessStream{
					Source: warden.ProcessStreamSourceStderr,
					Data:   []byte("stderr data"),
				}

				exitStatus := uint32(123)
				stream <- warden.ProcessStream{
					ExitStatus: &exitStatus,
				}

				close(stream)

				return stream, nil
			}

			stream, err := container.Attach(42)
			Ω(err).ShouldNot(HaveOccurred())

			Ω(fakeConnection.AttachedProcesses("some-handle")).Should(ContainElement(uint32(42)))

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

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

			exitStatus := uint32(123)