Skip to content

Commit

Permalink
Update integration tests for gRPC APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
sgayangi committed Sep 25, 2024
1 parent 85449a1 commit 183905b
Show file tree
Hide file tree
Showing 31 changed files with 1,854 additions and 1,864 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ func createRoutes(params *routeCreateParams) (routes []*routev3.Route, err error
temp := removeFirstOccurrence(basePath, "."+version)
newRoutePath = "/" + strings.TrimPrefix(resourcePath, temp+".")
}
action.Route.RegexRewrite = generateRegexMatchAndSubstitute(rewritePath, newRoutePath, pathMatchType)
// action.Route.RegexRewrite = generateRegexMatchAndSubstitute(rewritePath, newRoutePath, pathMatchType)
}
route := generateRouteConfig(xWso2Basepath, match, action, nil, metaData, decorator, perRouteFilterConfigs,
nil, requestHeadersToRemove, nil, nil) // general headers to add and remove are included in this methods
Expand Down
18 changes: 4 additions & 14 deletions test/cucumber-tests/CRs/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ spec:
ports:
- protocol: TCP
port: 6565
targetPort: 6565
targetPort: 9090
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -1761,20 +1761,10 @@ spec:
spec:
containers:
- name: grpc-backend
image: ddh13/dineth-grpc-demo-server:1.0.0
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: dp.wso2.com/v1alpha3
Expand Down
2 changes: 2 additions & 0 deletions test/cucumber-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ dependencies {
implementation 'io.grpc:grpc-netty-shaded:1.57.0'
implementation 'io.grpc:grpc-protobuf:1.57.0'
implementation 'io.grpc:grpc-stub:1.57.0'
implementation 'io.grpc:grpc-stub:1.57.0'
implementation 'com.google.protobuf:protobuf-java:4.28.2'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@
import org.wso2.apk.integration.utils.Utils;
import org.wso2.apk.integration.utils.clients.SimpleGRPCStudentClient;
import org.wso2.apk.integration.utils.clients.SimpleHTTPClient;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.student_service.StudentResponse;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.ContentType;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.SimpleGRPCStudentClient;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -196,7 +195,29 @@ public void theStudentResponseBodyShouldContainNameAndAge(String arg0, int arg1)

@Then("the response body should contain endpoint definition for student.proto")
public void theResponseBodyShouldContainEndpointDefinition() throws IOException {
String expectedText = "{\"apiDefinition\":\"syntax = \\\"proto3\\\";\\n\\noption java_multiple_files = true;\\noption java_package = \\\"org.example\\\";\\npackage dineth.grpc.api.v1.student;\\n\\nservice StudentService {\\n rpc GetStudent(StudentRequest) returns (StudentResponse) {};\\n rpc GetStudentStream(StudentRequest) returns (stream StudentResponse) {};\\n rpc SendStudentStream(stream StudentRequest) returns (StudentResponse) {};\\n rpc SendAndGetStudentStream(stream StudentRequest) returns (stream StudentResponse) {}\\n}\\n\\nmessage StudentRequest {\\n int32 id = 3;\\n}\\n\\nmessage StudentResponse {\\n string name = 1;\\n int32 age = 2;\\n}\\n\"}";
String expectedText = "{\"apiDefinition\":\"syntax = \\\"proto3\\\";\\n" + //
"\\n" + //
"package org.apk.v1.student_service;\\n" + //
"\\n" + //
"option java_multiple_files = true;\\n" + //
"option java_package = \\\"org.apk.v1.student_service\\\";\\n" + //
"\\n" + //
"service StudentService {\\n" + //
" rpc GetStudent(StudentRequest) returns (StudentResponse) {};\\n" + //
" rpc GetStudentStream(StudentRequest) returns (stream StudentResponse) {};\\n" + //
" rpc SendStudentStream(stream StudentRequest) returns (StudentResponse) {};\\n" + //
" rpc SendAndGetStudentStream(stream StudentRequest) returns (stream StudentResponse) {}\\n" + //
"}\\n" + //
"\\n" + //
"message StudentRequest {\\n" + //
" int32 id = 3;\\n" + //
"}\\n" + //
"\\n" + //
"message StudentResponse {\\n" + //
" string name = 1;\\n" + //
" int32 age = 2;\\n" + //
"}\\n" + //
"\"}";
Assert.assertTrue(sharedContext.getResponseBody().contains(expectedText),
"Actual response body: " + sharedContext.getResponseBody());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.http.HttpResponse;
import org.wso2.apk.integration.utils.clients.SimpleHTTPClient;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.student_service.StudentResponse;

import java.security.KeyManagementException;
import java.security.KeyStoreException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import io.grpc.ManagedChannel;
import org.wso2.apk.integration.utils.GenericClientInterceptor;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentRequest;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentResponse;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentServiceDefaultVersionGrpc;
import org.wso2.apk.integration.utils.clients.studentGrpcClient.StudentServiceGrpc;
import org.wso2.apk.integration.utils.clients.student_service.StudentRequest;
import org.wso2.apk.integration.utils.clients.student_service.StudentResponse;
import org.wso2.apk.integration.utils.clients.student_service.StudentServiceDefaultVersionGrpc;
import org.wso2.apk.integration.utils.clients.student_service.StudentServiceGrpc;

import javax.net.ssl.SSLException;
import java.util.Map;
Expand Down

This file was deleted.

Loading

0 comments on commit 183905b

Please sign in to comment.