Beispiel #1
0
		gdnr = &gardener.Gardener{
			SysInfoProvider: sysinfoProvider,
			Containerizer:   containerizer,
			UidGenerator:    uidGenerator,
			Networker:       networker,
			VolumeCreator:   volumeCreator,
			Logger:          logger,
			PropertyManager: propertyManager,
		}
	})

	Describe("creating a container", func() {
		Context("when a handle is specified", func() {
			It("passes the created network to the containerizer", func() {
				networker.NetworkStub = func(_ lager.Logger, handle, spec string) (string, error) {
					return "/path/to/netns/" + handle, nil
				}

				_, err := gdnr.Create(garden.ContainerSpec{
					Handle:  "bob",
					Network: "10.0.0.2/30",
				})
				Expect(err).NotTo(HaveOccurred())

				Expect(containerizer.CreateCallCount()).To(Equal(1))
				_, spec := containerizer.CreateArgsForCall(0)
				Expect(spec.NetworkPath).To(Equal("/path/to/netns/bob"))
			})

			Context("when networker fails", func() {
				BeforeEach(func() {
Beispiel #2
0
		}
	})

	Describe("creating a container", func() {
		Context("when a handle is specified", func() {
			It("asks the containerizer to create a container", func() {
				_, err := gdnr.Create(garden.ContainerSpec{Handle: "bob"})

				Expect(err).NotTo(HaveOccurred())
				Expect(containerizer.CreateCallCount()).To(Equal(1))
				Expect(containerizer.CreateArgsForCall(0).Handle).To(Equal("bob"))
			})

			It("passes the created network to the containerizer", func() {
				networker.NetworkStub = func(spec string) (string, error) {
					return "/path/to/netns/" + spec, nil
				}

				_, err := gdnr.Create(garden.ContainerSpec{
					Handle:  "bob",
					Network: "10.0.0.2/30",
				})
				Expect(err).NotTo(HaveOccurred())

				Expect(containerizer.CreateCallCount()).To(Equal(1))
				Expect(containerizer.CreateArgsForCall(0).NetworkPath).To(Equal("/path/to/netns/10.0.0.2/30"))
			})

			Context("when networker fails", func() {
				BeforeEach(func() {
					networker.NetworkReturns("", errors.New("booom!"))