Exemplo n.º 1
0
	BeforeEach(func() {
		container = nil
		args = []string{}
	})

	JustBeforeEach(func() {
		if supplyDefaultRootfs {
			client = startGarden(args...)
		} else {
			client = startGardenWithoutDefaultRootfs(args...)
		}
	})

	AfterEach(func() {
		if container != nil {
			Expect(client.Destroy(container.Handle())).To(Succeed())
		}
	})

	Context("without a default rootfs", func() {
		BeforeEach(func() {
			supplyDefaultRootfs = false
		})

		It("fails if a rootfs is not supplied in container spec", func() {
			var err error

			container, err = client.Create(garden.ContainerSpec{RootFSPath: ""})
			Expect(err).To(HaveOccurred())
			Expect(err).To(MatchError(ContainSubstring("RootFSPath: is a required parameter, since no default rootfs was provided to the server.")))
		})
Exemplo n.º 2
0
					Expect(err).NotTo(HaveOccurred())
					Eventually(out).Should(gbytes.Say("hello"))

					Expect(process.Signal(garden.SignalKill)).To(Succeed())

					exited := make(chan struct{})
					go func() {
						process.Wait()
						close(exited)
					}()

					Eventually(exited).Should(BeClosed())
				})

				It("can still destroy the container", func() {
					Expect(client.Destroy(container.Handle())).To(Succeed())
				})

				It("can still be able to access the internet", func() {
					Expect(checkConnection(container, "8.8.8.8", 53)).To(Succeed())
				})

				It("can still be accessible from the outside", func() {
					Expect(listenInContainer(container, 8080)).To(Succeed())

					info, err := container.Info()
					Expect(err).NotTo(HaveOccurred())
					externalIP := info.ExternalIP

					// retry because listener process inside other container
					// may not start immediately
Exemplo n.º 3
0
		Expect(err).ToNot(HaveOccurred())
		mntFiles, err := ioutil.ReadDir(mntPath)
		Expect(err).ToNot(HaveOccurred())

		numLayerFiles := len(layerFiles)
		Expect(numLayerFiles).To(Equal(len(diffFiles)))
		Expect(numLayerFiles).To(Equal(len(mntFiles)))
		return numLayerFiles
	}

	expectLayerCountAfterGraphCleanupToBe := func(layerCount int) {
		nonPersistantRootfsContainer, err := client.Create(garden.ContainerSpec{
			RootFSPath: nonDefaultRootfsPath,
		})
		Expect(err).ToNot(HaveOccurred())
		Expect(client.Destroy(nonPersistantRootfsContainer.Handle())).To(Succeed())
		Expect(numLayersInGraph()).To(Equal(layerCount + 2)) // +2 for the layers created for the nondefaultrootfs container
	}

	BeforeEach(func() {
		var err error
		nonDefaultRootfsPath, err = ioutil.TempDir("", "tmpRootfs")
		Expect(err).ToNot(HaveOccurred())
		// temporary workaround as runc expects a /tmp dir to exist in the container rootfs
		err = os.Mkdir(filepath.Join(nonDefaultRootfsPath, "tmp"), 0700)
		Expect(err).ToNot(HaveOccurred())
	})

	JustBeforeEach(func() {
		for _, image := range persistentImages {
			args = append(args, "--persistent-image", image)
Exemplo n.º 4
0
	AfterEach(func() {
		Expect(client.DestroyAndStop()).To(Succeed())
	})

	It("should not leak goroutines", func() {
		handle := fmt.Sprintf("goroutine-leak-test-%d", GinkgoParallelNode())

		numGoroutinesBefore, err := client.NumGoroutines()
		Expect(err).NotTo(HaveOccurred())

		_, err = client.Create(garden.ContainerSpec{
			Handle: handle,
		})
		Expect(err).NotTo(HaveOccurred())

		client.Destroy(handle)

		Eventually(func() int {
			numGoroutinesAfter, err := client.NumGoroutines()
			Expect(err).NotTo(HaveOccurred())
			return numGoroutinesAfter
		}).Should(Equal(numGoroutinesBefore))
	})

	It("should destroy the container's rootfs", func() {
		container, err := client.Create(garden.ContainerSpec{})
		Expect(err).NotTo(HaveOccurred())

		info, err := container.Info()
		Expect(err).NotTo(HaveOccurred())
		containerRootfs := info.ContainerPath
Exemplo n.º 5
0
					SrcPath: srcPath,
					DstPath: dstPath,
					Mode:    bindMountMode,
					Origin:  bindMountOrigin,
				}},
				Network: fmt.Sprintf("10.0.%d.0/24", GinkgoParallelNode()),
			})
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		err := os.RemoveAll(srcPath)
		Expect(err).ToNot(HaveOccurred())

		if container != nil {
			err := client.Destroy(container.Handle())
			Expect(err).ToNot(HaveOccurred())
		}

		Expect(client.DestroyAndStop()).To(Succeed())
	})

	Context("which is read-only", func() {
		BeforeEach(func() {
			bindMountMode = garden.BindMountModeRO
			dstPath = "/home/alice/readonly"
		})

		Context("and with privileged=true", func() {
			BeforeEach(func() {
				privilegedContainer = true
Exemplo n.º 6
0
	})

	Context("when container handle is longer than 49 chars", func() {
		var (
			longHandle          string = "too-looooong-haaaaaaaaaaaaaannnnnndddle-1234456787889"
			longHandleContainer garden.Container
		)

		JustBeforeEach(func() {
			var err error
			longHandleContainer, err = client.Create(garden.ContainerSpec{Handle: longHandle})
			Expect(err).NotTo(HaveOccurred())
		})

		AfterEach(func() {
			client.Destroy(longHandle)
		})

		It("should lookup container ip using last 49 chars of handle as hostname", func() {
			buff := gbytes.NewBuffer()
			p, err := longHandleContainer.Run(garden.ProcessSpec{
				Path: "cat",
				Args: []string{"/etc/hosts"},
			}, garden.ProcessIO{
				Stdout: buff,
				Stderr: buff,
			})
			Expect(err).NotTo(HaveOccurred())

			code, err := p.Wait()
			Expect(err).NotTo(HaveOccurred())