예제 #1
0
파일: cell_test.go 프로젝트: ihocho/auction
	"github.com/cloudfoundry-incubator/rep/repfakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cell", func() {
	var (
		client          *repfakes.FakeSimClient
		emptyCell, cell *auctionrunner.Cell
	)

	BeforeEach(func() {
		client = &repfakes.FakeSimClient{}
		emptyState := BuildCellState("the-zone", 100, 200, 50, false, 0, linuxOnlyRootFSProviders, nil)
		emptyCell = auctionrunner.NewCell(logger, "empty-cell", client, emptyState)

		state := BuildCellState("the-zone", 100, 200, 50, false, 10, linuxOnlyRootFSProviders, []rep.LRP{
			*BuildLRP("pg-1", "domain", 0, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-1", "domain", 1, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-2", "domain", 0, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-3", "domain", 0, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-4", "domain", 0, linuxRootFSURL, 10, 20),
		})
		cell = auctionrunner.NewCell(logger, "the-cell", client, state)
	})

	Describe("ScoreForLRP", func() {
		It("factors in memory usage", func() {
			bigInstance := BuildLRP("pg-big", "domain", 0, linuxRootFSURL, 20, 10)
			smallInstance := BuildLRP("pg-small", "domain", 0, linuxRootFSURL, 10, 10)
예제 #2
0
			Expect(failedTask.Attempts).To(Equal(taskAuction.Attempts + 1))
			Expect(failedLRPStart.PlacementError).To(Equal(auctiontypes.ErrorCellMismatch.Error()))
		})
	})

	Describe("handling start auctions", func() {
		var startAuction auctiontypes.LRPAuction

		BeforeEach(func() {
			clients["A-cell"] = &repfakes.FakeSimClient{}
			zones["A-zone"] = auctionrunner.Zone{
				auctionrunner.NewCell(
					logger,
					"A-cell",
					clients["A-cell"],
					BuildCellState("A-zone", 100, 100, 100, false, linuxOnlyRootFSProviders, []rep.LRP{
						*BuildLRP("pg-1", "domain", 0, "", 10, 10),
						*BuildLRP("pg-2", "domain", 0, "", 10, 10),
					}),
				),
			}

			clients["B-cell"] = &repfakes.FakeSimClient{}
			zones["B-zone"] = auctionrunner.Zone{
				auctionrunner.NewCell(
					logger,
					"B-cell",
					clients["B-cell"],
					BuildCellState("B-zone", 100, 100, 100, false, linuxOnlyRootFSProviders, []rep.LRP{
						*BuildLRP("pg-3", "domain", 0, "", 10, 10),
					}),
예제 #3
0
	"github.com/cloudfoundry-incubator/rep/repfakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Cell", func() {
	var (
		client          *repfakes.FakeSimClient
		emptyCell, cell *auctionrunner.Cell
	)

	BeforeEach(func() {
		client = &repfakes.FakeSimClient{}
		emptyState := BuildCellState("the-zone", 100, 200, 50, false, linuxOnlyRootFSProviders, nil)
		emptyCell = auctionrunner.NewCell(logger, "empty-cell", client, emptyState)

		state := BuildCellState("the-zone", 100, 200, 50, false, linuxOnlyRootFSProviders, []rep.LRP{
			*BuildLRP("pg-1", "domain", 0, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-1", "domain", 1, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-2", "domain", 0, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-3", "domain", 0, linuxRootFSURL, 10, 20),
			*BuildLRP("pg-4", "domain", 0, linuxRootFSURL, 10, 20),
		})
		cell = auctionrunner.NewCell(logger, "the-cell", client, state)
	})

	Describe("ScoreForLRP", func() {
		It("factors in memory usage", func() {
			bigInstance := BuildLRP("pg-big", "domain", 0, linuxRootFSURL, 20, 10)
			smallInstance := BuildLRP("pg-small", "domain", 0, linuxRootFSURL, 10, 10)