示例#1
0
	"github.com/cloudfoundry-incubator/receptor"
	"github.com/cloudfoundry-incubator/receptor/serialization"
	"github.com/cloudfoundry-incubator/runtime-schema/bbs/shared"
	"github.com/cloudfoundry-incubator/runtime-schema/models"
	"github.com/tedsuo/ifrit/ginkgomon"

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

var _ = Describe("Cell API", func() {
	var cellPresence models.CellPresence

	BeforeEach(func() {
		capacity := models.NewCellCapacity(128, 1024, 6)
		cellPresence = models.NewCellPresence("cell-0", "1.2.3.4", "the-zone", capacity, []string{}, []string{})
		value, err := models.ToJSON(cellPresence)

		_, err = consulSession.SetPresence(shared.CellSchemaPath(cellPresence.CellID), value)
		Expect(err).NotTo(HaveOccurred())

		receptorProcess = ginkgomon.Invoke(receptorRunner)
	})

	AfterEach(func() {
		ginkgomon.Kill(receptorProcess)
	})

	Describe("GET /v1/cells", func() {
		var cellResponses []receptor.CellResponse
		var getErr error
	"github.com/cloudfoundry-incubator/runtime-schema/models"
)

var _ = Describe("CellPresence", func() {
	var cellPresence models.CellPresence

	var payload string

	var capacity models.CellCapacity

	BeforeEach(func() {
		capacity = models.NewCellCapacity(128, 1024, 3)
		rootfsProviders := []string{"provider-1"}
		preloadedRootFSes := []string{"provider-2"}
		cellPresence = models.NewCellPresence("some-id", "some-address", "some-zone", capacity, rootfsProviders, preloadedRootFSes)

		payload = `{
    "cell_id":"some-id",
    "rep_address": "some-address",
    "zone": "some-zone",
    "capacity": {
       "memory_mb": 128,
       "disk_mb": 1024,
       "containers": 3
		 },
		 "rootfs_providers": {
			 "provider-1": [],
			 "preloaded": ["provider-2"]
		 }
   }`
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/cloudfoundry-incubator/runtime-schema/models"
)

var _ = Describe("CellPresence", func() {
	var cellPresence models.CellPresence

	var payload string

	var capacity models.CellCapacity

	BeforeEach(func() {
		capacity = models.NewCellCapacity(128, 1024, 3)
		cellPresence = models.NewCellPresence("some-id", "some-address", "some-zone", capacity)

		payload = `{
    "cell_id":"some-id",
    "rep_address": "some-address",
    "zone": "some-zone",
    "capacity": {
       "memory_mb": 128,
       "disk_mb": 1024,
       "containers": 3
    }
  }`
	})

	Describe("Validate", func() {
		Context("when cell presence is valid", func() {
	BeforeEach(func() {
		fakeBBS = new(fake_bbs.FakeReceptorBBS)
		logger = lager.NewLogger("test")
		logger.RegisterSink(lager.NewWriterSink(GinkgoWriter, lager.DEBUG))
		responseRecorder = httptest.NewRecorder()
		handler = handlers.NewCellHandler(fakeBBS, logger)
	})

	Describe("GetAll", func() {
		var cellPresences []models.CellPresence

		BeforeEach(func() {
			capacity := models.NewCellCapacity(128, 1024, 6)
			cellPresences = []models.CellPresence{
				models.NewCellPresence("cell-id-0", "1.2.3.4", "the-zone", capacity),
				models.NewCellPresence("cell-id-1", "4.5.6.7", "the-zone", capacity),
			}
		})

		JustBeforeEach(func() {
			handler.GetAll(responseRecorder, newTestRequest(""))
		})

		Context("when reading Cells from BBS succeeds", func() {
			BeforeEach(func() {
				fakeBBS.CellsReturns(cellPresences, nil)
			})

			It("call the BBS to retrieve the actual LRPs", func() {
				Expect(fakeBBS.CellsCallCount()).To(Equal(1))
示例#5
0
import (
	"github.com/cloudfoundry-incubator/receptor"
	"github.com/cloudfoundry-incubator/receptor/serialization"
	"github.com/cloudfoundry-incubator/runtime-schema/models"

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

var _ = Describe("CellPresence Serialization", func() {
	Describe("CellPresenceToCellResponse", func() {
		var cellPresence models.CellPresence

		BeforeEach(func() {
			capacity := models.NewCellCapacity(128, 1024, 6)
			cellPresence = models.NewCellPresence("cell-id-0", "1.2.3.4", "the-zone", capacity)
		})

		It("serializes all the fields", func() {
			expectedResponse := receptor.CellResponse{
				CellID: "cell-id-0",
				Zone:   "the-zone",
				Capacity: receptor.CellCapacity{
					MemoryMB:   128,
					DiskMB:     1024,
					Containers: 6,
				},
			}

			actualResponse := serialization.CellPresenceToCellResponse(cellPresence)
			Expect(actualResponse).To(Equal(expectedResponse))
示例#6
0
import (
	"github.com/cloudfoundry-incubator/receptor"
	"github.com/cloudfoundry-incubator/receptor/serialization"
	"github.com/cloudfoundry-incubator/runtime-schema/models"

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

var _ = Describe("CellPresence Serialization", func() {
	Describe("CellPresenceToCellResponse", func() {
		var cellPresence models.CellPresence

		BeforeEach(func() {
			capacity := models.NewCellCapacity(128, 1024, 6)
			cellPresence = models.NewCellPresence("cell-id-0", "1.2.3.4", "the-zone", capacity, []string{"provider-1", "provider-2"}, []string{"stack-1"})
		})

		It("serializes all the fields", func() {
			expectedResponse := receptor.CellResponse{
				CellID: "cell-id-0",
				Zone:   "the-zone",
				Capacity: receptor.CellCapacity{
					MemoryMB:   128,
					DiskMB:     1024,
					Containers: 6,
				},
				RootFSProviders: map[string][]string{
					"provider-1": []string{},
					"provider-2": []string{},
					"preloaded":  []string{"stack-1"},