Example #1
0
)

var _ = Describe("Linux containers", func() {
	var fakeCgroups *fake_cgroups_manager.FakeCgroupsManager
	var fakeQuotaManager *fake_quota_manager.FakeQuotaManager
	var fakeBandwidthManager *fake_bandwidth_manager.FakeBandwidthManager
	var fakeRunner *fake_command_runner.FakeCommandRunner
	var fakeOomWatcher *fake_watcher.FakeWatcher
	var containerResources *linux_backend.Resources
	var container *linux_container.LinuxContainer
	var containerDir string

	BeforeEach(func() {
		fakeRunner = fake_command_runner.New()

		fakeCgroups = fake_cgroups_manager.New("/cgroups", "some-id")

		fakeQuotaManager = new(fake_quota_manager.FakeQuotaManager)
		fakeBandwidthManager = fake_bandwidth_manager.New()
		fakeOomWatcher = new(fake_watcher.FakeWatcher)

		var err error
		containerDir, err = ioutil.TempDir("", "depot")
		Expect(err).ToNot(HaveOccurred())

		_, subnet, _ := net.ParseCIDR("2.3.4.0/30")
		containerResources = linux_backend.NewResources(
			1235,
			&linux_backend.Network{
				IP:     net.ParseIP("1.2.3.4"),
				Subnet: subnet,
var _ = Describe("OomNotifier", func() {
	var (
		runner         *fake_command_runner.FakeCommandRunner
		cgroupsPath    string
		cgroupsManager linux_container.CgroupsManager
		oNoom          func()
		oomChan        chan struct{}
		containerPath  string
		oomNotifier    *linux_container.OomNotifier
	)

	BeforeEach(func() {
		runner = fake_command_runner.New()

		cgroupsPath = path.Join("path", "to", "cgroups")
		cgroupsManager = fake_cgroups_manager.New(cgroupsPath, "123456")

		containerPath = path.Join("path", "to", "container")

		oomChan = make(chan struct{})
		oNoom = func() {
			close(oomChan)
		}
	})

	JustBeforeEach(func() {
		oomNotifier = linux_container.NewOomNotifier(
			runner,
			containerPath,
			cgroupsManager,
		)