Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion commands/update_desired_lrp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ = Describe("UpdateDesiredLRP", func() {

updatedInstanceCount := int32(4)
dlu := models.DesiredLRPUpdate{}
dlu.SetInstances(updatedInstanceCount)
dlu.SetInstances(&updatedInstanceCount)
updatedDesiredLRP = &dlu

spec, err = json.Marshal(updatedDesiredLRP)
Expand Down
87 changes: 46 additions & 41 deletions integration/actual_lrp_groups_for_guid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,29 @@ var _ = Describe("actual-lrp-groups-for-guid", func() {
})

JustBeforeEach(func() {
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
request := &models.ActualLRPGroupsByProcessGuidRequest{
ProcessGuid: "random-guid",
}
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
response := &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
State: "running",
},
},
},
}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrp_groups/list_by_process_guid"),
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(time.Duration(serverTimeout) * time.Second)
},
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ghttp.VerifyProtoRepresenting(&models.ActualLRPGroupsByProcessGuidRequest{
ProcessGuid: "random-guid",
}),
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ghttp.RespondWithProto(200, &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
State: "running",
},
},
},
}),
ghttp.VerifyProtoRepresenting(request.ToProto()),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
})
Expand Down Expand Up @@ -81,16 +83,17 @@ var _ = Describe("actual-lrp-groups-for-guid", func() {

Context("when the server returns an error", func() {
BeforeEach(func() {
response := &models.DomainsResponse{
Error: &models.Error{
Type: models.Error_Deadlock,
Message: "the request failed due to deadlock",
},
Domains: nil,
}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrp_groups/list_by_process_guid"),
ghttp.RespondWithProto(500, &models.DomainsResponse{
Error: &models.Error{
Type: models.Error_Deadlock,
Message: "the request failed due to deadlock",
},
Domains: nil,
}),
ghttp.RespondWithProto(500, response.ToProto()),
),
)
})
Expand All @@ -112,28 +115,30 @@ var _ = Describe("actual-lrp-groups-for-guid", func() {

Context("when passing index as filter", func() {
BeforeEach(func() {
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
request := &models.ActualLRPGroupByProcessGuidAndIndexRequest{
ProcessGuid: "test-process-guid",
Index: 1,
}
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
response := &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
ActualLrpKey: models.ActualLRPKey{
Index: 1,
},
State: "running",
},
},
},
}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrp_groups/get_by_process_guid_and_index"),
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ghttp.VerifyProtoRepresenting(&models.ActualLRPGroupByProcessGuidAndIndexRequest{
ProcessGuid: "test-process-guid",
Index: 1,
}),
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ghttp.RespondWithProto(200, &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - deprecated model used for testing deprecated functionality
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
ActualLRPKey: models.ActualLRPKey{
Index: 1,
},
State: "running",
},
},
},
}),
ghttp.VerifyProtoRepresenting(request.ToProto()),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
})
Expand Down
57 changes: 30 additions & 27 deletions integration/actual_lrp_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,24 @@ var _ = Describe("actual-lrp-groups", func() {
})

JustBeforeEach(func() {
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
response := &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
State: "running",
},
},
},
}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrp_groups/list"),
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(time.Duration(serverTimeout) * time.Second)
},
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ghttp.RespondWithProto(200, &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
State: "running",
},
},
},
}),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
})
Expand Down Expand Up @@ -79,25 +80,27 @@ var _ = Describe("actual-lrp-groups", func() {

Context("when passing filters", func() {
BeforeEach(func() {
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
request := &models.ActualLRPGroupsRequest{
Domain: "cf-apps",
CellId: "cell_z1-0",
}
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
response := &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
State: "running",
},
},
},
}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrp_groups/list"),
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ghttp.VerifyProtoRepresenting(&models.ActualLRPGroupsRequest{
Domain: "cf-apps",
CellId: "cell_z1-0",
}),
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ghttp.RespondWithProto(200, &models.ActualLRPGroupsResponse{
//lint:ignore SA1019 - calling deprecated model while unit testing deprecated method
ActualLrpGroups: []*models.ActualLRPGroup{
{
Instance: &models.ActualLRP{
State: "running",
},
},
},
}),
ghttp.VerifyProtoRepresenting(request.ToProto()),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
})
Expand Down
40 changes: 22 additions & 18 deletions integration/actual_lrps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ var _ = Describe("actual-lrps", func() {
})

JustBeforeEach(func() {
request := &models.ActualLRPsRequest{}
response := &models.ActualLRPsResponse{
ActualLrps: []*models.ActualLRP{
&models.ActualLRP{
State: "running",
},
},
}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrps/list"),
ghttp.VerifyProtoRepresenting(&models.ActualLRPsRequest{}),
ghttp.VerifyProtoRepresenting(request.ToProto()),
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(time.Duration(serverTimeout) * time.Second)
},
ghttp.RespondWithProto(200, &models.ActualLRPsResponse{
ActualLrps: []*models.ActualLRP{
&models.ActualLRP{
State: "running",
},
},
}),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
})
Expand Down Expand Up @@ -75,24 +77,26 @@ var _ = Describe("actual-lrps", func() {

Context("when passing filters", func() {
BeforeEach(func() {
alr := models.ActualLRPsRequest{
request := models.ActualLRPsRequest{
Domain: "cf-apps",
CellId: "cell_z1-0",
ProcessGuid: "pg-0",
}
alr.SetIndex(int32(1))
index := int32(1)
request.SetIndex(&index)
response := &models.ActualLRPsResponse{
ActualLrps: []*models.ActualLRP{
&models.ActualLRP{
State: "running",
},
},
}

bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/actual_lrps/list"),
ghttp.VerifyProtoRepresenting(&alr),
ghttp.RespondWithProto(200, &models.ActualLRPsResponse{
ActualLrps: []*models.ActualLRP{
&models.ActualLRP{
State: "running",
},
},
}),
ghttp.VerifyProtoRepresenting(request.ToProto()),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
})
Expand Down
10 changes: 6 additions & 4 deletions integration/cancel_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ var _ = Describe("cancel-task", func() {

})
JustBeforeEach(func() {
request := &models.TaskGuidRequest{TaskGuid: "task-guid"}
bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/tasks/cancel"),
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(time.Duration(serverTimeout) * time.Second)
},
ghttp.VerifyProtoRepresenting(&models.TaskGuidRequest{TaskGuid: "task-guid"}),
ghttp.VerifyProtoRepresenting(request.ToProto()),
ghttp.RespondWith(200, nil),
),
)
Expand Down Expand Up @@ -68,12 +69,13 @@ var _ = Describe("cancel-task", func() {

Context("when the server responds with error", func() {
It("exits with status code 4", func() {
response := &models.TaskResponse{
Error: models.ErrUnknownError,
}
bbsServer.RouteToHandler(
"POST",
"/v1/tasks/cancel",
ghttp.RespondWithProto(200, &models.TaskResponse{
Error: models.ErrUnknownError,
}),
ghttp.RespondWithProto(200, response.ToProto()),
)

sess := RunCFDot("cancel-task", "task-guid")
Expand Down
29 changes: 17 additions & 12 deletions integration/cell_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ var _ = Describe("cell-state", func() {
Tasks: []rep.Task{},
}

response := &models.CellsResponse{
Cells: []*models.CellPresence{presence1, presence2},
}

bbsServer.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/cells/list.r1"),
ghttp.RespondWithProto(200, &models.CellsResponse{
Cells: []*models.CellPresence{presence1, presence2},
}),
ghttp.RespondWithProto(200, response.ToProto()),
),
)
rep1Server.RouteToHandler("GET", "/state", func(resp http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -113,15 +115,16 @@ var _ = Describe("cell-state", func() {
)

JustBeforeEach(func() {
response := &models.CellsResponse{
Cells: []*models.CellPresence{presence1, presence2},
}
bbsServer.SetHandler(0,
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/cells/list.r1"),
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(time.Duration(serverTimeout) * time.Second)
},
ghttp.RespondWithProto(200, &models.CellsResponse{
Cells: []*models.CellPresence{presence1, presence2},
}),
ghttp.RespondWithProto(200, response.ToProto()),
),
)

Expand Down Expand Up @@ -189,15 +192,16 @@ var _ = Describe("cell-state", func() {
)

JustBeforeEach(func() {
response := &models.CellsResponse{
Cells: []*models.CellPresence{presence1, presence2},
}
bbsServer.SetHandler(0,
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/cells/list.r1"),
func(w http.ResponseWriter, req *http.Request) {
time.Sleep(time.Duration(serverTimeout) * time.Second)
},
ghttp.RespondWithProto(200, &models.CellsResponse{
Cells: []*models.CellPresence{presence1, presence2},
}),
ghttp.RespondWithProto(200, response.ToProto()),
),
)

Expand Down Expand Up @@ -246,12 +250,13 @@ var _ = Describe("cell-state", func() {

Context("when the BBS request fails", func() {
BeforeEach(func() {
response := &models.CellsResponse{
Error: models.ErrUnknownError,
}
bbsServer.SetHandler(0,
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", "/v1/cells/list.r1"),
ghttp.RespondWithProto(503, &models.CellsResponse{
Error: models.ErrUnknownError,
}),
ghttp.RespondWithProto(503, response.ToProto()),
),
)
})
Expand Down
Loading