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 1 commit
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/claim_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func ClaimLock(
Key: lockKey,
Owner: lockOwner,
Value: lockValue,
TypeCode: models.LOCK,
TypeCode: models.TypeCode_LOCK,
},
TtlInSeconds: ttlInSeconds,
}
Expand Down
2 changes: 1 addition & 1 deletion commands/claim_lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("ClaimLock", func() {
Key: "key",
Owner: "owner",
Value: "value",
TypeCode: models.LOCK,
TypeCode: models.TypeCode_LOCK,
},
TtlInSeconds: 60,
}))
Expand Down
2 changes: 1 addition & 1 deletion commands/claim_presence.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func ClaimPresence(
Key: lockKey,
Owner: lockOwner,
Value: lockValue,
TypeCode: models.PRESENCE,
TypeCode: models.TypeCode_PRESENCE,
},
TtlInSeconds: ttlInSeconds,
}
Expand Down
2 changes: 1 addition & 1 deletion commands/claim_presence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("ClaimPresence", func() {
Key: "key",
Owner: "owner",
Value: "value",
TypeCode: models.PRESENCE,
TypeCode: models.TypeCode_PRESENCE,
},
TtlInSeconds: 60,
}))
Expand Down
2 changes: 1 addition & 1 deletion commands/locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Locks(stdout, stderr io.Writer, locketClient models.LocketClient) error {

encoder := json.NewEncoder(stdout)

req := &models.FetchAllRequest{TypeCode: models.LOCK}
req := &models.FetchAllRequest{TypeCode: models.TypeCode_LOCK}
resp, err := locketClient.FetchAll(context.Background(), req)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion commands/locks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("Locks", func() {
Expect(fakeLocketClient.FetchAllCallCount()).To(Equal(1))

_, req, _ := fakeLocketClient.FetchAllArgsForCall(0)
Expect(req).To(Equal(&models.FetchAllRequest{TypeCode: models.LOCK}))
Expect(req).To(Equal(&models.FetchAllRequest{TypeCode: models.TypeCode_LOCK}))

d, err := json.Marshal(resources.Resources[0])
Expect(err).NotTo(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion commands/presences.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func Presences(stdout, stderr io.Writer, locketClient models.LocketClient) error

encoder := json.NewEncoder(stdout)

req := &models.FetchAllRequest{TypeCode: models.PRESENCE}
req := &models.FetchAllRequest{TypeCode: models.TypeCode_PRESENCE}
resp, err := locketClient.FetchAll(context.Background(), req)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions commands/presences_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var _ = Describe("Presences", func() {
Key: "key",
Owner: "owner",
Value: "value",
TypeCode: models.PRESENCE,
TypeCode: models.TypeCode_PRESENCE,
},
},
}
Expand All @@ -50,7 +50,7 @@ var _ = Describe("Presences", func() {
Expect(fakeLocketClient.FetchAllCallCount()).To(Equal(1))

_, req, _ := fakeLocketClient.FetchAllArgsForCall(0)
Expect(req).To(Equal(&models.FetchAllRequest{TypeCode: models.PRESENCE}))
Expect(req).To(Equal(&models.FetchAllRequest{TypeCode: models.TypeCode_PRESENCE}))

d, err := json.Marshal(resources.Resources[0])
Expect(err).NotTo(HaveOccurred())
Expand Down
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
Loading