コード例 #1
0
ファイル: db_provider_test.go プロジェクト: ACPK/atc
				var id Identifier
				var spec ResourceTypeContainerSpec

				JustBeforeEach(func() {
					id = Identifier{
						Name: "some-name",
					}

					spec = ResourceTypeContainerSpec{
						Type: "some-resource-a",
					}

					fakeContainer := new(gfakes.FakeContainer)
					fakeContainer.HandleReturns("created-handle")

					worker.CreateReturns(fakeContainer, nil)
					worker.LookupReturns(fakeContainer, nil)

					By("connecting to the worker")
					container, err := workers[0].CreateContainer(logger, id, spec)
					Expect(err).NotTo(HaveOccurred())

					err = container.Destroy()
					Expect(err).NotTo(HaveOccurred())

					By("restarting the worker with a new address")
					workerServer.Stop()

					Eventually(func() error {
						conn, err := net.Dial("tcp", workerAddr)
						if err == nil {
コード例 #2
0
ファイル: main_test.go プロジェクト: savaki/tsa
								return (<-stubs)()
							}
						})

						JustBeforeEach(func() {
							err := json.NewEncoder(sshStdin).Encode(workerPayload)
							Ω(err).ShouldNot(HaveOccurred())
						})

						It("forwards garden API calls through the tunnel", func() {
							registration := <-registered
							addr := registration.worker.Addr

							client := gclient.New(gconn.New("tcp", addr))

							fakeBackend.CreateReturns(new(gfakes.FakeContainer), nil)

							_, err := client.Create(garden.ContainerSpec{})
							Ω(err).ShouldNot(HaveOccurred())

							Ω(fakeBackend.CreateCallCount()).Should(Equal(1))
						})

						It("continuously registers it with the ATC as long as it works", func() {
							a := time.Now()
							registration := <-registered
							Ω(registration.ttl).Should(Equal(2 * heartbeatInterval))

							// shortcut for equality w/out checking addr
							expectedWorkerPayload := workerPayload
							expectedWorkerPayload.Addr = registration.worker.Addr
コード例 #3
0
			It("returns an error", func() {
				_, err := apiClient.Capacity()
				Ω(err).Should(HaveOccurred())
			})
		})
	})

	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,
コード例 #4
0
ファイル: server_test.go プロジェクト: nagyistoce/garden
					go func() {
						defer GinkgoRecover()

						_, err := io.Stdout.Write([]byte("msg 1\n"))
						Ω(err).ShouldNot(HaveOccurred())

						time.Sleep(time.Minute)

						_, err = io.Stdout.Write([]byte("msg 2\n"))
						Ω(err).ShouldNot(HaveOccurred())
					}()

					return process, nil
				}

				fakeBackend.CreateReturns(fakeContainer, nil)

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

				fakeBackend.LookupReturns(fakeContainer, nil)

				stdout := gbytes.NewBuffer()

				process, err := clientContainer.Run(garden.ProcessSpec{
					Path: "some-path",
					Args: []string{"arg1", "arg2"},
				}, garden.ProcessIO{
					Stdout: stdout,
				})
				Ω(err).ShouldNot(HaveOccurred())