Skip to content

Commit

Permalink
Added cell capacity as part of cell response
Browse files Browse the repository at this point in the history
[#87156638]

Signed-off-by: Ted Young <[email protected]>
  • Loading branch information
atulkc committed Jan 30, 2015
1 parent 2288a27 commit 094515a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cmd/receptor/cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ var _ = Describe("Cell API", func() {

BeforeEach(func() {
heartbeatInterval = 100 * time.Millisecond
cellPresence = models.NewCellPresence("cell-0", "stack-0", "1.2.3.4", "the-zone")
capacity := models.NewCellCapacity(128, 1024, 6)
cellPresence = models.NewCellPresence("cell-0", "stack-0", "1.2.3.4", "the-zone", capacity)
heartbeatRunner := bbs.NewCellHeartbeat(cellPresence, heartbeatInterval)
heartbeatProcess = ginkgomon.Invoke(heartbeatRunner)
receptorProcess = ginkgomon.Invoke(receptorRunner)
Expand Down
5 changes: 3 additions & 2 deletions handlers/cell_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ var _ = Describe("Cell Handlers", func() {
var cellPresences []models.CellPresence

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

Expand Down
12 changes: 10 additions & 2 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,16 @@ type ActualLRPResponse struct {
}

type CellResponse struct {
CellID string `json:"cell_id"`
Stack string `json:"stack"`
CellID string `json:"cell_id"`
Stack string `json:"stack"`
Zone string `json:"zone"`
Capacity CellCapacity
}

type CellCapacity struct {
MemoryMB int `json:"memory_mb"`
DiskMB int `json:"disk_mb"`
Containers int `json:"containers"`
}

type Event interface {
Expand Down
6 changes: 6 additions & 0 deletions serialization/cells.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,11 @@ func CellPresenceToCellResponse(cellPresence models.CellPresence) receptor.CellR
return receptor.CellResponse{
CellID: cellPresence.CellID,
Stack: cellPresence.Stack,
Zone: cellPresence.Zone,
Capacity: receptor.CellCapacity{
MemoryMB: cellPresence.Capacity.MemoryMB,
DiskMB: cellPresence.Capacity.DiskMB,
Containers: cellPresence.Capacity.Containers,
},
}
}
9 changes: 8 additions & 1 deletion serialization/cells_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ var _ = Describe("CellPresence Serialization", func() {
var cellPresence models.CellPresence

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

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

actualResponse := serialization.CellPresenceToCellResponse(cellPresence)
Expand Down

0 comments on commit 094515a

Please sign in to comment.