Exemple #1
0
func newCellPresence(cellID string) *models.CellPresence {
	presence := models.NewCellPresence(
		cellID,
		"cell.example.com",
		"the-zone",
		models.NewCellCapacity(128, 1024, 6),
		[]string{},
		nil,
		nil,
		nil,
	)
	return &presence
}
	})

	Describe("stopping extra LRPs", func() {
		var (
			cellPresence models.CellPresence
		)

		Context("when the cell", func() {
			Context("is present", func() {
				BeforeEach(func() {
					cellPresence = models.NewCellPresence(
						cellID,
						"cell1.addr",
						"",
						"the-zone",
						models.NewCellCapacity(128, 1024, 6),
						[]string{},
						[]string{},
						[]string{},
						[]string{},
					)

					fakeServiceClient.CellByIdReturns(&cellPresence, nil)
				})

				It("stops the LRPs", func() {
					Expect(fakeRepClientFactory.CreateClientCallCount()).To(Equal(2))
					Expect(fakeRepClientFactory.CreateClientArgsForCall(0)).To(Equal(cellPresence.RepAddress))
					Expect(fakeRepClientFactory.CreateClientArgsForCall(1)).To(Equal(cellPresence.RepAddress))

					Expect(fakeServiceClient.CellByIdCallCount()).To(Equal(2))
Exemple #3
0
import (
	"code.cloudfoundry.org/bbs/models"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("CellPresence", func() {
	var (
		cellPresence         models.CellPresence
		capacity             models.CellCapacity
		expectedProviderList []*models.Provider
	)

	BeforeEach(func() {
		capacity = models.NewCellCapacity(128, 1024, 3)
		rootfsProviders := []string{"provider-1"}
		preloadedRootFSes := []string{"provider-2", "provider-3"}
		placementTags := []string{"tag-1", "tag-2"}
		optionalPlacementTags := []string{"optional-tag-1", "optional-tag-2"}
		cellPresence = models.NewCellPresence("some-id", "some-address", "some-zone", capacity, rootfsProviders, preloadedRootFSes, placementTags, optionalPlacementTags)
		expectedProviderList = []*models.Provider{
			&models.Provider{"preloaded", []string{"provider-2", "provider-3"}},
			&models.Provider{"provider-1", []string{}},
		}
	})

	Describe("Validate", func() {
		Context("when cell presence is valid", func() {
			It("does not return an error", func() {
				Expect(cellPresence.Validate()).NotTo(HaveOccurred())