Exemplo n.º 1
0
				Ω(err).Should(Equal(disaster))
			})
		})
	})

	Describe("NetOut", func() {
		It("sends NetOut requests over the connection", func() {
			Ω(container.NetOut(garden.NetOutRule{
				Networks: []garden.IPRange{garden.IPRangeFromIP(net.ParseIP("1.2.3.4"))},
				Ports: []garden.PortRange{
					{Start: 12, End: 24},
				},
				Log: true,
			})).Should(Succeed())

			h, rule := fakeConnection.NetOutArgsForCall(0)
			Ω(h).Should(Equal("some-handle"))

			Ω(rule.Networks).Should(HaveLen(1))
			Ω(rule.Networks[0]).Should(Equal(garden.IPRange{Start: net.ParseIP("1.2.3.4"), End: net.ParseIP("1.2.3.4")}))

			Ω(rule.Ports).Should(HaveLen(1))
			Ω(rule.Ports[0]).Should(Equal(garden.PortRange{Start: 12, End: 24}))

			Ω(rule.Log).Should(Equal(true))
		})
	})

	Context("when the request fails", func() {
		disaster := errors.New("oh no!")
Exemplo n.º 2
0
			Ports: []garden.PortRange{
				garden.PortRangeFromPort(13253),
			},
		}

		itRetries(func() error {
			return conn.NetOut("la-contineur", netOutRule)
		}, func(err error) {
			innerConnection.NetOutReturns(err)
		}, func() int {
			return innerConnection.NetOutCallCount()
		}, func() {
			It("calls through to garden", func() {
				Ω(innerConnection.NetOutCallCount()).Should(Equal(1))

				handle, calledNetOutRule := innerConnection.NetOutArgsForCall(0)
				Ω(handle).Should(Equal("la-contineur"))
				Ω(calledNetOutRule).Should(Equal(netOutRule))
			})
		})
	})

	Describe("CurrentBandwidthLimits", func() {
		handle := "suitcase"

		limits := garden.BandwidthLimits{
			RateInBytesPerSecond: 234,
		}

		var gotLimits garden.BandwidthLimits