Env: []string{ "BURST=256", fmt.Sprintf("RATE=%d", 128*8), }, }, )) }) Context("when net_rate.sh fails", func() { nastyError := errors.New("oh no!") BeforeEach(func() { fakeRunner.WhenRunning( fake_command_runner.CommandSpec{ Path: "/depot/some-id/net_rate.sh", }, func(*exec.Cmd) error { return nastyError }, ) }) It("returns the error", func() { err := bandwidthManager.SetLimits(backend.BandwidthLimits{ RateInBytesPerSecond: 128, BurstRateInBytesPerSecond: 256, }) Expect(err).To(Equal(nastyError)) }) }) })
1*time.Second, containerResources, fakePortPool, fakeRunner, fakeCgroups, fakeQuotaManager, fakeBandwidthManager, ) }) setupSuccessfulSpawn := func() { fakeRunner.WhenRunning( fake_command_runner.CommandSpec{ Path: "/depot/some-id/bin/iomux-spawn", }, func(cmd *exec.Cmd) error { cmd.Stdout.Write([]byte("ready\n")) cmd.Stdout.Write([]byte("active\n")) return nil }, ) } Describe("Snapshotting", func() { It("writes a JSON ContainerSnapshot", func() { var err error err = container.Start() Expect(err).ToNot(HaveOccurred()) memoryLimits := backend.MemoryLimits{ LimitInBytes: 1,
It("initiates a link to the job after spawn is ready", func(done Done) { fakeRunner.WhenRunning( fake_command_runner.CommandSpec{ Path: binPath("iomux-spawn"), }, func(cmd *exec.Cmd) error { go func() { time.Sleep(100 * time.Millisecond) Expect(fakeRunner).ToNot(HaveExecutedSerially( fake_command_runner.CommandSpec{ Path: binPath("iomux-link"), }, ), "Executed iomux-link too early!") Expect(cmd.Stdout).ToNot(BeNil()) cmd.Stdout.Write([]byte("xxx\n")) Eventually(fakeRunner).Should(HaveExecutedSerially( fake_command_runner.CommandSpec{ Path: binPath("iomux-link"), }, )) close(done) }() return nil }, )
) var _ = Describe("Linux Quota Manager initialization", func() { var fakeRunner *fake_command_runner.FakeCommandRunner BeforeEach(func() { fakeRunner = fake_command_runner.New() }) Context("when df fails", func() { disaster := errors.New("oh no!") BeforeEach(func() { fakeRunner.WhenRunning(fake_command_runner.CommandSpec{ Path: "df", }, func(*exec.Cmd) error { return disaster }) }) It("returns the error", func() { _, err := quota_manager.New("/bogus/path", "/root/path", fakeRunner) Expect(err).To(Equal(disaster)) }) }) }) var _ = Describe("Linux Quota manager", func() { var fakeRunner *fake_command_runner.FakeCommandRunner var quotaManager *quota_manager.LinuxQuotaManager
"DISK_QUOTA_ENABLED=true", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", }, }, )) }) Context("when setup.sh fails", func() { nastyError := errors.New("oh no!") BeforeEach(func() { fakeRunner.WhenRunning( fake_command_runner.CommandSpec{ Path: "/root/path/setup.sh", }, func(*exec.Cmd) error { return nastyError }, ) }) It("returns the error", func() { err := pool.Setup() Expect(err).To(Equal(nastyError)) }) }) }) Describe("creating", func() { It("returns containers with unique IDs", func() { container1, err := pool.Create(backend.ContainerSpec{})