Skip to content

Commit

Permalink
Update go integration test for gRPC API
Browse files Browse the repository at this point in the history
  • Loading branch information
sgayangi committed Sep 25, 2024
1 parent 183905b commit 66ba3ed
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 444 deletions.
4 changes: 2 additions & 2 deletions test/integration/integration/tests/grpc-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var GRPCAPI = suite.IntegrationTest{
{
ExpectedResponse: grpcutils.ExpectedResponse{
Out: &student.StudentResponse{
Name: "Dineth",
Name: "Student",
Age: 10,
},
Err: nil,
Expand All @@ -55,7 +55,7 @@ var GRPCAPI = suite.IntegrationTest{
{
ExpectedResponse: grpcutils.ExpectedResponse{
Out: &student_default_version.StudentResponse{
Name: "Dineth",
Name: "Student",
Age: 10,
},
Err: nil,
Expand Down
20 changes: 5 additions & 15 deletions test/integration/integration/tests/resources/base/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
ports:
- protocol: TCP
port: 6565
targetPort: 6565
targetPort: 9090
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -142,21 +142,11 @@ spec:
app: grpc-backend-v1
spec:
containers:
- name: grpc-backend-v1
image: ddh13/dineth-grpc-demo-server:1.0.0
- name: grpc-backend
image: sega1234/student-service:1.0.0
imagePullPolicy: Always
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
resources:
requests:
cpu: 10m
ports:
- containerPort: 9090
---
apiVersion: v1
kind: Service
Expand Down
10 changes: 5 additions & 5 deletions test/integration/integration/tests/resources/tests/grpc-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
apiName: GRPC API
apiType: GRPC
apiVersion: v1
basePath: /dineth.grpc.api.v1
basePath: /org.apk.v1
isDefaultVersion: true
production:
- routeRefs:
Expand All @@ -47,31 +47,31 @@ spec:
rules:
- matches:
- method:
service: student.StudentService
service: student_service.StudentService
method: GetStudent
backendRefs:
- name: grpc-backend-v1
kind: Backend
port: 6565
- matches:
- method:
service: student.StudentService
service: student_service.StudentService
method: SendStudentStream
backendRefs:
- name: grpc-backend-v1
kind: Backend
port: 6565
- matches:
- method:
service: student.StudentService
service: student_service.StudentService
method: GetStudentStream
backendRefs:
- name: grpc-backend-v1
kind: Backend
port: 6565
- matches:
- method:
service: student.StudentService
service: student_service.StudentService
method: SendAndGetStudentStream
backendRefs:
- name: grpc-backend-v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ type StudentResponseSatisfier struct{}

// IsSatisfactory checks if the given response is satisfactory based on the expected response.
func (srs StudentResponseSatisfier) IsSatisfactory(response any, expectedResponse grpcutils.ExpectedResponse) bool {
// Type assert the response to *student.StudentResponse
// Type assert the response to *student_service.StudentResponse
resp, respOk := response.(*StudentResponse)
if !respOk {
log.Println("Failed to assert response as *student.StudentResponse")
log.Println("Failed to assert response as *student_service.StudentResponse")
return false
}
// Type assert the expected output to *student.StudentResponse
// Type assert the expected output to *student_service.StudentResponse
expectedResp, expOk := expectedResponse.Out.(*StudentResponse)
if !expOk {
log.Println("Failed to assert expectedResponse.Out as *student.StudentResponse")
log.Println("Failed to assert expectedResponse.Out as *student_service.StudentResponse")
return false
}

Expand Down
86 changes: 43 additions & 43 deletions test/integration/integration/utils/grpc-code/student/student.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 66ba3ed

Please sign in to comment.