package container_daemon_test

import (
	"syscall"

	"github.com/cloudfoundry-incubator/garden"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("RlimitsManager", func() {
	var rlimits garden.ResourceLimits
	var mgr *container_daemon.RlimitsManager
	var systemRlimits syscall.Rlimit
	var prevRlimit *syscall.Rlimit

	BeforeEach(func() {
		rlimits = garden.ResourceLimits{}
		mgr = new(container_daemon.RlimitsManager)
	})

	Describe("Init", func() {
		itSetRlimitValue := func(name string, id int, val uint64) {
			By("setting hard rlimit "+name, func() {
				Expect(syscall.Getrlimit(id, &systemRlimits)).To(Succeed())
				Expect(systemRlimits.Max).To(Equal(val))
			})
		}
Beispiel #2
0
	"github.com/cloudfoundry-incubator/garden"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon"
	"github.com/cloudfoundry-incubator/garden-linux/container_daemon/fake_rlimits_env_encoder"

	"os/exec"
	"os/user"

	"github.com/cloudfoundry-incubator/garden-linux/container_daemon/fake_user"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Preparing a command to run", func() {
	var (
		users          *fake_user.FakeUser
		preparer       *container_daemon.ProcessSpecPreparer
		rlimitsEncoder *fake_rlimits_env_encoder.FakeRlimitsEnvEncoder
		limits         garden.ResourceLimits
	)

	etcPasswd := map[string]*user.User{
		"a-user":       &user.User{Uid: "66", Gid: "99"},
		"another-user": &user.User{Uid: "77", Gid: "88", HomeDir: "/the/home/dir"},
		"root":         &user.User{Uid: "0", Gid: "0", HomeDir: "/root"},
		"missing-uid":  &user.User{},
		"missing-gid":  &user.User{Uid: "0"},
	}

	BeforeEach(func() {
		users = new(fake_user.FakeUser)

		users.LookupStub = func(name string) (*user.User, error) {