Ejemplo n.º 1
0
func createContainer(gardenClient garden.Client) (string, error) {
	container, err := gardenClient.Create(garden.ContainerSpec{})
	if err != nil {
		return "", err
	}

	processSpec := garden.ProcessSpec{
		Path: "sleep",
		Args: []string{"1000000"},
		User: "******",
	}
	processIO := garden.ProcessIO{}
	_, err = container.Run(processSpec, processIO)
	if err != nil {
		panic(err)
	}

	handle := container.Handle()
	fmt.Println(handle)

	return handle, nil
}
func createContainer(client garden.Client, spec garden.ContainerSpec) garden.Container {
	container, err := client.Create(spec)
	Ω(err).ShouldNot(HaveOccurred(), fmt.Sprintf("Error while creating container with spec: %+v", spec))
	return container
}
Ejemplo n.º 3
0
		})
	})

	Context("and the client sends a CreateRequest", func() {
		var fakeContainer *fakes.FakeContainer

		BeforeEach(func() {
			fakeContainer = new(fakes.FakeContainer)
			fakeContainer.HandleReturns("some-handle")

			serverBackend.CreateReturns(fakeContainer, nil)
		})

		It("returns a container with the created handle", func() {
			container, err := apiClient.Create(garden.ContainerSpec{
				Handle: "some-handle",
			})
			Ω(err).ShouldNot(HaveOccurred())

			Ω(container.Handle()).Should(Equal("some-handle"))
		})

		It("creates the container with the spec from the request", func() {
			_, err := apiClient.Create(garden.ContainerSpec{
				Handle:     "some-handle",
				GraceTime:  42 * time.Second,
				Network:    "some-network",
				RootFSPath: "/path/to/rootfs",
				BindMounts: []garden.BindMount{
					{
						SrcPath: "/bind/mount/src",
Ejemplo n.º 4
0
				finishCreating = make(chan struct{})

				fakeBackend.CreateStub = func(garden.ContainerSpec) (garden.Container, error) {
					close(creating)
					<-finishCreating
					return new(fakes.FakeContainer), nil
				}
			})

			It("waits for it to complete and stops accepting requests", func() {
				created := make(chan garden.Container, 1)

				go func() {
					defer GinkgoRecover()

					container, err := apiClient.Create(garden.ContainerSpec{})
					Ω(err).ShouldNot(HaveOccurred())

					created <- container
				}()

				Eventually(creating).Should(BeClosed())

				stopExited := make(chan struct{})
				go func() {
					apiServer.Stop()
					close(stopExited)
				}()

				Consistently(stopExited).ShouldNot(BeClosed())