Skip to content

Commit

Permalink
Merge pull request #2488 from sgayangi/test-branch
Browse files Browse the repository at this point in the history
Update integration tests for gRPC APIs
  • Loading branch information
sgayangi authored Sep 30, 2024
2 parents e5bd577 + a9de55f commit 6ec8e10
Show file tree
Hide file tree
Showing 43 changed files with 2,201 additions and 2,364 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
2 changes: 0 additions & 2 deletions adapter/internal/operator/controllers/dp/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"strings"
"sync"

"github.com/sirupsen/logrus"
"github.com/wso2/apk/adapter/config"
"github.com/wso2/apk/adapter/internal/controlplane"
"github.com/wso2/apk/adapter/internal/discovery/xds"
Expand Down Expand Up @@ -1529,7 +1528,6 @@ func (apiReconciler *APIReconciler) getAPIForGRPCRoute(ctx context.Context, obj
}

apiList := &dpv1alpha3.APIList{}
logrus.Info("=============GETTING API FOR GRPC ROUTE================")

if err := apiReconciler.client.List(ctx, apiList, &k8client.ListOptions{
FieldSelector: fields.OneTermEqualSelector(grpcRouteAPIIndex, utils.NamespacedName(grpcRoute).String()),
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 @@ -1760,7 +1760,7 @@ spec:
ports:
- protocol: TCP
port: 6565
targetPort: 6565
targetPort: 9090
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -1781,20 +1781,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 6ec8e10

Please sign in to comment.