예제 #1
0
func fetchCapacity(logger lager.Logger, gardenClient GardenClient.Client, config Configuration) executor.ExecutorResources {
	capacity, err := configuration.ConfigureCapacity(gardenClient, config.MemoryMB, config.DiskMB)
	if err != nil {
		logger.Error("failed-to-configure-capacity", err)
		os.Exit(1)
	}

	logger.Info("initial-capacity", lager.Data{
		"capacity": capacity,
	})

	return capacity
}
예제 #2
0
var _ = Describe("configuration", func() {
	var gardenClient *fakes.FakeGardenClient

	BeforeEach(func() {
		gardenClient = fakes.NewGardenClient()
	})

	Describe("ConfigureCapacity", func() {
		var capacity executor.ExecutorResources
		var err error
		var memLimit string
		var diskLimit string

		JustBeforeEach(func() {
			capacity, err = configuration.ConfigureCapacity(gardenClient, memLimit, diskLimit)
		})

		Context("when getting the capacity fails", func() {
			BeforeEach(func() {
				gardenClient.Connection.CapacityReturns(garden.Capacity{}, errors.New("uh oh"))
			})

			It("returns an error", func() {
				Expect(err).To(Equal(errors.New("uh oh")))
			})
		})

		Context("when getting the capacity succeeds", func() {
			BeforeEach(func() {
				memLimit = "99"