Beispiel #1
0
		client *api.Client
	)

	BeforeEach(func() {
		port = testhelpers.SelectPort(GinkgoParallelNode())

		fakeRegistry = new(fakes.FakeRegistry)
		fakeTransferCreator = new(fakes.FakeTransferCreator)
		server = api.NewServer(
			port,
			fakeRegistry,
			fakeTransferCreator,
		)

		client = api.NewClient("127.0.0.1", port, 0)
	})

	Context("when the server is not running", func() {
		Describe("Client#Ping", func() {
			It("should return an error", func() {
				Expect(client.Ping()).NotTo(Succeed())
			})
		})
	})

	Context("when the server is started", func() {
		var serverChan chan struct{}

		BeforeEach(func() {
			serverChan = make(chan struct{})
		if runtime.GOOS != "linux" {
			Skip("This test can only run with Linux.")
		}

		var err error

		srcTPort = testhelpers.SelectPort(GinkgoParallelNode())
		srcAPort = testhelpers.SelectPort(GinkgoParallelNode())
		srcClique, err = startClique(config.Config{
			TransferPort: srcTPort,
			APIPort:      srcAPort,
		})
		Expect(err).NotTo(HaveOccurred())

		srcClient = api.NewClient(
			"127.0.0.1", srcAPort, time.Millisecond*100,
		)

		destTPort = testhelpers.SelectPort(GinkgoParallelNode())
		destClique, err = startClique(config.Config{
			TransferPort: destTPort,
		})
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		Expect(srcClique.Stop()).To(Succeed())
		Expect(destClique.Stop()).To(Succeed())
	})

	It("should populate the RTT", func() {